Skip to content

Commit e27974c

Browse files
committed
update docs
1 parent 759797b commit e27974c

File tree

5 files changed

+41
-28
lines changed

5 files changed

+41
-28
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# https://verdantfox.com/blog/how-to-use-git-pre-commit-hooks-the-hard-way-and-the-easy-way
33
# https://docs.astral.sh/ruff/integrations/
44
# https://pre-commit.com/
5-
# Commands:
6-
# pre-commit run # Запустить pre-commit проверку для теста
7-
# pre-commit install # Создать файл в директории .git/hooks/pre-commit
8-
# После создания файла, при любом git commit будет запускаться pre-commit проверка.
9-
# Если возникли проблемы с pre-commit и нужно срочно сделать commit то можно
10-
# временно удалить проверку до выяснения проблемы с помощью:
11-
# pre-commit uninstall
5+
6+
# How to use it?
7+
# pre-commit run # Run the pre-commit check manually.
8+
# pre-commit install # Create a file in the directory to run automatically on commit: .git/hooks/pre-commit
9+
# pre-commit uninstall # Delete a file in the directory to disable automatic startup on commit.
10+
# git commit --no-verify -m "msg" # Disable startup for this commit (--no-verify OR -n)
11+
1212
repos:
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
1414
rev: v4.6.0
@@ -29,15 +29,15 @@ repos:
2929
- tomli
3030

3131
- repo: https://github.com/astral-sh/ruff-pre-commit
32-
rev: 'v0.4.1'
32+
rev: 'v0.8.0'
3333
hooks:
3434
- id: ruff
35-
name: Проверка кода ruff линтером.
35+
name: Check the codebase using the ruff linter.
3636
args: [
3737
--fix,
3838
--quiet,
3939
# --silent,
4040
]
4141

4242
- id: ruff-format
43-
name: Проверка кода ruff форматтером.
43+
name: Check the codebase using the ruff formatter.

pyproject.toml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ dev = [
4444
"pytest-django>=4.8.0",
4545

4646
"pre-commit>=3.5.0",
47-
"ruff==0.4.1",
47+
"ruff==0.8.0",
4848
"pytest>=7.0.1",
4949
"mypy>=1.10.0",
5050
"pytest-cov>=5.0.0",
5151
]
5252
ci = [
5353
"pytest-django>=4.8.0",
5454

55-
"ruff==0.4.1",
55+
"ruff==0.8.0",
5656
"pytest>=7.0.1",
5757
"mypy>=1.10.0",
5858
"pytest-cov>=5.0.0",
@@ -119,19 +119,23 @@ disable_error_code = [
119119

120120
[tool.coverage.run]
121121
concurrency = ["multiprocessing", "thread"]
122-
omit = ["*/tests/*"]
122+
omit = ["*/tests/*", "types.py", "_sqlite3_adapters_and_converters.py"] # Не проверять директории и(или) файлы
123123
parallel = true
124+
branch = true # Включать в замер результаты вхождения в условия
124125
source = ["src.capture_db_queries"]
125126

126127
[tool.coverage.report]
127128
fail_under = 80 # Тест упадёт если покрытие составит менее 80%
129+
skip_covered = true # Не включать в отчет информацию о файлах со 100% покрытием
130+
show_missing = true # Включать в отчет информацию о номерах не протестированных строк кода
131+
sort = "-Cover" # Сортировать отчет по уровню покрытия
128132

129133

130134
# https://docs.astral.sh/ruff/settings/
131135
# https://docs.astral.sh/ruff/configuration/#full-command-line-interface
132136
# cmd: ruff format # Отформатирует все файлы в `.` текущем каталоге.
133137
[tool.ruff]
134-
required-version = "<=0.5.7"
138+
required-version = "<=0.8.0"
135139
target-version = "py312" # Версия python которую будет обслуживать ruff
136140
line-length = 105 # Макс длина строки кода после которой будет выполнен автоперенос
137141
indent-width = 4
@@ -186,6 +190,7 @@ extend-select = [
186190
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
187191
"TID", # https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid
188192
"TCH", # https://docs.astral.sh/ruff/rules/#flake8-type-checking-tch
193+
"TD", # https://docs.astral.sh/ruff/rules/#flake8-todos-td
189194
"INT", # https://docs.astral.sh/ruff/rules/#flake8-gettext-int
190195
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
191196
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
@@ -196,11 +201,10 @@ extend-select = [
196201
]
197202
ignore = [
198203
# https://docs.astral.sh/ruff/rules/#pyflakes-f
199-
# "F401", # (не ругаться на неиспользуемые импорты)
200-
# "F841", # (не ругаться на неиспользуемые переменные)
201204
"F403", # (не ругаться на использование from ... import *)
202205
# https://docs.astral.sh/ruff/rules/#pyupgrade-up
203206
"UP031", # (не ругаться на форматирование с помощью %s)
207+
"UP036", # (не ругаться на использование sys.version_info если текущая версия не подпадает под условие)
204208
# https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
205209
"G004", # (не ругаться на использование f-строк для сообщения лога)
206210
# https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
@@ -212,6 +216,7 @@ ignore = [
212216
"PT009", # (не ругаться на unittest ассерты)
213217
"PT027", # (не ругаться на unittest ассерты)
214218
"PT001", # (не ругаться на отсутствие круглых скобок у декоратора fixture)
219+
"PT004", # (не ругаться на написание фикстур которые ничего не возвращают без префикса "_")
215220
# https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
216221
"ISC001", # (конфликт с `COM812`)
217222
# https://docs.astral.sh/ruff/rules/#flake8-commas-com
@@ -226,11 +231,16 @@ ignore = [
226231
"RET503", # (не ругаться на отсутствие return None в конце функций)
227232
# https://docs.astral.sh/ruff/rules/#flake8-blind-except-ble
228233
"BLE001", # (не ругаться на обработку обычного Exception)
229-
# https://docs.astral.sh/ruff/rules/#flake8-django-dj #! (ВРЕМЕННО)
234+
# https://docs.astral.sh/ruff/rules/#flake8-django-dj
235+
# https://docs.djangoproject.com/en/4.2/ref/models/fields/#null
236+
# https://sentry.io/answers/django-difference-between-null-and-blank/
237+
# https://www.django-rest-framework.org/api-guide/fields/#charfield
230238
"DJ001", # (не ругаться на использование null в моделях для текстовых полей)
231239
# https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
232240
# {} VS dict() # https://switowski.com/blog/dict-function-vs-literal-syntax/
233241
"C408", # (не ругаться на использование классов коллекций вместо их литералов)
242+
"TD001", # (не ругаться на использование FIXME и XXX)
243+
"TD003", # (не ругаться на отсутствие ссылки на issues)
234244
]
235245
# Не давать исправлять эти ошибки в тултипе, и в том числе автоматически при линте через команду
236246
unfixable = [

src/capture_db_queries/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import warnings
23

34
warnings.filterwarnings(
@@ -6,6 +7,8 @@
67
category=DeprecationWarning,
78
)
89

9-
from . import _sqlite3_adapters_and_converters # noqa: F401, E402
10+
if sys.version_info >= (3, 12):
11+
from . import _sqlite3_adapters_and_converters # noqa: F401
12+
1013
from ._logging import switch_logger, switch_trace # noqa: F401, E402
1114
from .decorators import CaptureQueries, ExtCaptureQueriesContext, capture_queries # noqa: F401, E402

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def intercept_output() -> Generator[StringIO, None, None]:
5050

5151

5252
@pytest.fixture
53-
def _ignore_deprecation() -> Generator[None, None, None]:
53+
def ignore_deprecation() -> Generator[None, None, None]:
5454
warnings.simplefilter('ignore', DeprecationWarning)
5555
yield
5656
warnings.resetwarnings()
5757

5858

5959
@pytest.fixture
60-
def _debug_true() -> Generator[None, None, None]:
60+
def debug_true() -> Generator[None, None, None]:
6161
switch_logger(True)
6262
# switch_trace(True)
6363
yield

tests/test_decorators.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def setup_method(self, method: Callable[..., Any]) -> None:
4949
def call_capture_queries(self, **kwargs: Any) -> CaptureQueries:
5050
raise NotImplementedError
5151

52-
# @pytest.mark.usefixtures('_debug_true')
52+
# @pytest.mark.usefixtures('debug_true')
5353
def test_basic_logic(self) -> None:
5454
obj = self.call_capture_queries()
5555

@@ -164,7 +164,7 @@ def call_capture_queries(self, **kwargs: Any) -> CaptureQueries:
164164
_select(self.reporter.pk, self.article.pk)
165165
return obj
166166

167-
# @pytest.mark.usefixtures('_debug_true')
167+
# @pytest.mark.usefixtures('debug_true')
168168
def test_param__number_runs(self) -> None:
169169
obj = self.call_capture_queries(number_runs=3)
170170

@@ -338,7 +338,7 @@ def test_without_requests(self) -> None:
338338
class TestOutputCaptureQueries:
339339
"""The -s argument must be passed when running py test to output output"""
340340

341-
# @pytest.mark.usefixtures('_debug_true')
341+
# @pytest.mark.usefixtures('debug_true')
342342
def test_capture_queries_loop(self, intercept_output: StringIO) -> None:
343343
date_now = timezone.now().date()
344344

@@ -352,7 +352,7 @@ def test_capture_queries_loop(self, intercept_output: StringIO) -> None:
352352
output,
353353
), f'incorrect output = {output}'
354354

355-
# @pytest.mark.usefixtures('_debug_true')
355+
# @pytest.mark.usefixtures('debug_true')
356356
def test_capture_queries_decorator(self, intercept_output: StringIO) -> None:
357357
date_now = timezone.now().date()
358358

@@ -367,7 +367,7 @@ def _() -> None:
367367
output,
368368
), f'incorrect output = {output}'
369369

370-
# @pytest.mark.usefixtures('_debug_true')
370+
# @pytest.mark.usefixtures('debug_true')
371371
def test_capture_queries_context_manager(self, intercept_output: StringIO) -> None:
372372
with CaptureQueries() as ctx: # noqa: F841
373373
request_to_db()
@@ -381,7 +381,7 @@ def test_capture_queries_context_manager(self, intercept_output: StringIO) -> No
381381

382382

383383
@pytest.mark.django_db(transaction=True)
384-
@pytest.mark.usefixtures('_ignore_deprecation')
384+
@pytest.mark.usefixtures('ignore_deprecation')
385385
def test_capture_queries(intercept_output: StringIO) -> None:
386386
"""Обязательно должен быть передан аргумент -s при запуске pytest, для вывода output"""
387387

@@ -398,7 +398,7 @@ def _() -> None:
398398

399399

400400
@pytest.mark.django_db(transaction=True)
401-
@pytest.mark.usefixtures('_ignore_deprecation')
401+
@pytest.mark.usefixtures('ignore_deprecation')
402402
def test_capture_queries_with_advanced_verb_and_queries(intercept_output: StringIO) -> None:
403403
"""Обязательно должен быть передан аргумент -s при запуске pytest, для вывода output"""
404404

@@ -433,7 +433,7 @@ def _() -> None:
433433

434434

435435
@pytest.mark.django_db(transaction=True)
436-
@pytest.mark.usefixtures('_ignore_deprecation')
436+
@pytest.mark.usefixtures('ignore_deprecation')
437437
def test_ext_capture_queries_context(intercept_output: StringIO) -> None:
438438
"""Обязательно должен быть передан аргумент -s при запуске pytest, для вывода output"""
439439

0 commit comments

Comments
 (0)