From c4616b99f8c87b234963db2fc2eb440bf5fa5391 Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Wed, 13 Aug 2025 15:07:56 -0400 Subject: [PATCH 1/9] Better ruff rules --- pyproject.toml | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6445d226..5cd95f33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -135,28 +135,35 @@ extend-exclude = [ ] [tool.ruff.lint] -extend-select = [ - "B", # flake8-bugbear - "BLE", # flake8-blind-except - "DTZ", # flake8-datetimez - "FA", # flake8-future-annotations - "G", # flake8-logging-format - "I", # isort - "PGH", # pygrep-hooks - "PIE", # flake8-pie - "PL", # pylint - "PT", # flake8-pytest-style - "PYI", # flake8-pyi - "RUF", # Ruff-specific rules - "SLOT", # flake8-slots - "T10", # flake8-debugger - "UP", # pyupgrade - "YTT", # flake8-2020 -] +select = ["ALL"] ignore = [ + # "D203", + # "D212", + # "COM812", "PLR0913", # Too many arguments in function definition "PLR2004", # Magic value used in comparison, consider replacing 3 with a constant variable ] +[tool.ruff.lint.per-file-ignores] +"tests/*.py" = [ + "ANN", # Disable all annotations + "D100", # Missing docstring in public module + "D101", # Missing docstring in public class + "D205", # 1 blank line required between summary line and description + "D102", # Missing docstring in public method + "D103", # Missing docstring in public function + "D401", # First line of docstring should be in imperative mood + "D404", # First word of the docstring should not be "This" + "FIX003", # Line contains XXX, consider resolving the issue + "N801", # Class name should use CapWords convention + "N802", # Function name should be lowercase + "S", # Disable all security checks + "TD001", # Invalid TODO tag + "TD002", # Missing author in TODO + "TD003", # Missing issue link for this TODO + + "D400", # First line should end with a period + "D415", # First line should end with a period, question mark, or exclamation points +] [tool.ruff.lint.isort] forced-separate = [ From 5029eaaa8a50532ad34ede4ff09c47542a9756b0 Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Thu, 14 Aug 2025 06:30:50 -0400 Subject: [PATCH 2/9] . --- pyproject.toml | 78 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5cd95f33..d91f53f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -135,23 +135,82 @@ extend-exclude = [ ] [tool.ruff.lint] -select = ["ALL"] -ignore = [ - # "D203", - # "D212", - # "COM812", - "PLR0913", # Too many arguments in function definition - "PLR2004", # Magic value used in comparison, consider replacing 3 with a constant variable +select = [ + "AIR", # Airflow + "ERA", # eradicate + "FAST", # FastAPI + "YTT", # flake8-2020 + "ANN", # flake8-annotations + "ASYNC", # flake8-async + "S", # flake8-bandit + "BLE", # flake8-blind-except + "FBT", # flake8-boolean-trap + "B", # flake8-bugbear + "A", # flake8-builtins + "COM", # flake8-commas + "C4", # flake8-comprehensions + "CPY", # flake8-copyright + "DTZ", # flake8-datetimez + "T10", # flake8-debugger + "DJ", # flake8-django + "EM", # flake8-errmsg + "EXE", # flake8-executable + "FIX", # flake8-fixme + "FA", # flake8-future-annotations + "INT", # flake8-gettext + "ISC", # flake8-implicit-str-concat + "ICN", # flake8-import-conventions + "LOG", # flake8-logging + "G", # flake8-logging-format + "INP", # flake8-no-pep420 + "PIE", # flake8-pie + "T20", # flake8-print + "PYI", # flake8-pyi + "PT", # flake8-pytest-style + "Q", # flake8-quotes + "RSE", # flake8-raise + "RET", # flake8-return + "SLF", # flake8-self + "SIM", # flake8-simplify + "SLOT", # flake8-slots + "TID", # flake8-tidy-imports + "TD", # flake8-todos + "TC", # flake8-type-checking + "ARG", # flake8-unused-arguments + "PTH", # flake8-use-pathlib + "FLY", # flynt + "I", # isort + "C90", # mccabe + "PD", # pandas-vet + "N", # pep8-naming + "PERF", # Perflint + "E", # pycodestyle Error + "W", # pycodestyle Warning + "DOC", # pydoclint + "D", # pydocstyle + "F", # Pyflakes + "PGH", # pygrep-hooks + "PL", # Pylint + "PLC", # Pylint Convention + "PLE", # Pylint Error + "PLR", # Pylint Refactor + "PLW", # Pylint Warning + "UP", # pyupgrade + "FURB", # refurb + "TRY", # tryceratops + "RUF", # Ruff-specific rules ] [tool.ruff.lint.per-file-ignores] "tests/*.py" = [ "ANN", # Disable all annotations "D100", # Missing docstring in public module "D101", # Missing docstring in public class - "D205", # 1 blank line required between summary line and description "D102", # Missing docstring in public method "D103", # Missing docstring in public function + "D205", # 1 blank line required between summary line and description + "D400", # First line should end with a period "D401", # First line of docstring should be in imperative mood + "D415", # First line should end with a period, question mark, or exclamation points "D404", # First word of the docstring should not be "This" "FIX003", # Line contains XXX, consider resolving the issue "N801", # Class name should use CapWords convention @@ -160,9 +219,6 @@ ignore = [ "TD001", # Invalid TODO tag "TD002", # Missing author in TODO "TD003", # Missing issue link for this TODO - - "D400", # First line should end with a period - "D415", # First line should end with a period, question mark, or exclamation points ] [tool.ruff.lint.isort] From ce09f5861cc74e879033655719b1653d307ab6c8 Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Thu, 14 Aug 2025 07:03:49 -0400 Subject: [PATCH 3/9] . --- pyproject.toml | 66 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d91f53f8..0df655c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -200,19 +200,65 @@ select = [ "TRY", # tryceratops "RUF", # Ruff-specific rules ] +ignore = [ + "D100", # Missing docstring in public module + "D101", # Missing docstring in public class + "D102", # Missing docstring in public method + "D103", # Missing docstring in public function + "D104", # Missing docstring in public package + "D105", # Missing docstring in magic method + "D107", # Missing docstring in __init__ + "D200", # One-line docstring should fit on one line + "D202", # No blank lines allowed after function docstring + "D205", # 1 blank line required between summary line and description + "D209", # Multi-line docstring closing quotes should be on a separate line + "D212", # Multi-line docstring summary should start at the first line + "D213", # Multi-line docstring summary should start at the second line + "D400", # First line should end with a period + "D401", # First line of docstring should be in imperative mood + "D404", # First word of the docstring should not be "This" + "D415", # First line should end with a period, question mark, or exclamation point + "S101", # Use of `assert` detected + + # TODO - need to fix these + "ANN001", # Missing type annotation for function argument + "ANN002", # Missing type annotation for public function + "ANN003", # Missing type annotation for public method + "ANN201", # Missing return type annotation for public function + "ANN202", # Missing return type annotation for private function + "ANN204", # Missing return type annotation for special method + "ANN401", # Dynamically typed expressions .. are disallowed + "ARG001", # Unused function argument + "ARG002", # Unused method argument + "C901", # .. is too complex + "COM812", # Trailing comma missing + "E501", # Line too long + "EM101", # Exception must not use a string literal, assign to variable first + "EM102", # Exception must not use an f-string literal, assign to variable first + "FBT001", # Boolean-typed positional argument in function definition + "FBT002", # Boolean default positional argument in function definition + "FBT003", # Boolean positional value in function call + "N802", # Function name `assertRedirects` should be lowercase + "N806", # Variable `UserModel` in function should be lowercase + "PLC0415", # `import` should be at the top-level of a file + "PLR0913", # Too many arguments in function definition + "PLR2004", # Magic value used in comparison, consider replacing .. with a constant variable + "RET504", # Unnecessary assignment to .. before `return` statement + "RET505", # Unnecessary `elif` after `return` statement + "S105", # Possible hardcoded password assigned + "SIM102", # Use a single `if` statement instead of nested `if` statements + "SIM108", # Use ternary operator .. instead of `if`-`else`-block + "SIM114", # Combine `if` branches using logical `or` operator + "SLF001", # Private member accessed + "TC002", # Move third-party import `django.contrib.messages.Message` into a type-checking block + "TC003", # Move standard library import `collections.abc.Sequence` into a type-checking block + "TRY003", # Avoid specifying long messages outside the exception class +] [tool.ruff.lint.per-file-ignores] -"tests/*.py" = [ +"tests/*.py,pytest_django_test/*.py" = [ "ANN", # Disable all annotations - "D100", # Missing docstring in public module - "D101", # Missing docstring in public class - "D102", # Missing docstring in public method - "D103", # Missing docstring in public function - "D205", # 1 blank line required between summary line and description - "D400", # First line should end with a period - "D401", # First line of docstring should be in imperative mood - "D415", # First line should end with a period, question mark, or exclamation points - "D404", # First word of the docstring should not be "This" "FIX003", # Line contains XXX, consider resolving the issue + "DJ008", # Model does not define .. method "N801", # Class name should use CapWords convention "N802", # Function name should be lowercase "S", # Disable all security checks From 7998021d4897898afc5262a60b7aa5c83167f96e Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Thu, 14 Aug 2025 07:12:04 -0400 Subject: [PATCH 4/9] . --- pyproject.toml | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0df655c2..4ab507f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -255,7 +255,7 @@ ignore = [ "TRY003", # Avoid specifying long messages outside the exception class ] [tool.ruff.lint.per-file-ignores] -"tests/*.py,pytest_django_test/*.py" = [ +"tests/*.py" = [ "ANN", # Disable all annotations "FIX003", # Line contains XXX, consider resolving the issue "DJ008", # Model does not define .. method @@ -265,6 +265,43 @@ ignore = [ "TD001", # Invalid TODO tag "TD002", # Missing author in TODO "TD003", # Missing issue link for this TODO + + # TODO - need to fix these + "ARG005", # Unused lambda argument + "D300", # Use triple double quotes `"""` + "D403", # First word of the docstring should be capitalized + "ERA001", # Found commented-out code + "SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements + "TC001", # Move application import .. into a type-checking block + "TC006", # Add quotes to type expression in `typing.cast()` + "PTH108", # `os.unlink()` should be replaced by `Path.unlink()` + "PTH110", # `os.path.exists()` should be replaced by `Path.exists()` + "RET503", # Missing explicit `return` at the end of function able to return non-`None` value + "RSE102", # Unnecessary parentheses on raised exception +] +"pytest_django_test/*.py" = [ + "ANN", # Disable all annotations + "FIX003", # Line contains XXX, consider resolving the issue + "DJ008", # Model does not define .. method + "N801", # Class name should use CapWords convention + "N802", # Function name should be lowercase + "S", # Disable all security checks + "TD001", # Invalid TODO tag + "TD002", # Missing author in TODO + "TD003", # Missing issue link for this TODO + + # TODO - need to fix these + "ARG005", # Unused lambda argument + "D300", # Use triple double quotes `"""` + "D403", # First word of the docstring should be capitalized + "ERA001", # Found commented-out code + "SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements + "TC001", # Move application import .. into a type-checking block + "TC006", # Add quotes to type expression in `typing.cast()` + "PTH108", # `os.unlink()` should be replaced by `Path.unlink()` + "PTH110", # `os.path.exists()` should be replaced by `Path.exists()` + "RET503", # Missing explicit `return` at the end of function able to return non-`None` value + "RSE102", # Unnecessary parentheses on raised exception ] [tool.ruff.lint.isort] From c5996a067e603b8559b2db777587dbed4f955624 Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Thu, 14 Aug 2025 07:23:01 -0400 Subject: [PATCH 5/9] ... done? --- .editorconfig-checker.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.editorconfig-checker.json b/.editorconfig-checker.json index de4ce198..22317f6c 100644 --- a/.editorconfig-checker.json +++ b/.editorconfig-checker.json @@ -3,6 +3,8 @@ "pytest_django/fixtures.py", ".tox/*", ".ruff_cache/*", + ".mypy_cache/*", + ".pytest_cache/*", "pytest_django.egg-info/*", "__pycache__/*", "zizmor.sarif", From d4c5ff9439d4caa4214eaa99c9a697e03e43d1bb Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Thu, 14 Aug 2025 07:34:37 -0400 Subject: [PATCH 6/9] . --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 4ab507f4..99530326 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -129,6 +129,7 @@ exclude_lines = [ ] [tool.ruff] +# preview = true # TODO - enable this when we have time to fix all the issues line-length = 99 extend-exclude = [ "pytest_django/_version.py", @@ -210,6 +211,7 @@ ignore = [ "D107", # Missing docstring in __init__ "D200", # One-line docstring should fit on one line "D202", # No blank lines allowed after function docstring + "D203", # Class definitions that are not preceded by a blank line "D205", # 1 blank line required between summary line and description "D209", # Multi-line docstring closing quotes should be on a separate line "D212", # Multi-line docstring summary should start at the first line From 5deed0f424ee8983ae7720ac39ba7a3d89ebf4f7 Mon Sep 17 00:00:00 2001 From: Javier Buzzi Date: Thu, 14 Aug 2025 07:40:13 -0400 Subject: [PATCH 7/9] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pyproject.toml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 99530326..291e5f18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -129,7 +129,7 @@ exclude_lines = [ ] [tool.ruff] -# preview = true # TODO - enable this when we have time to fix all the issues +# preview = true # TODO: Enable this after resolving all Ruff preview lint errors (see https://github.com/pytest-dev/pytest-django/issues/1234) line-length = 99 extend-exclude = [ "pytest_django/_version.py", @@ -192,10 +192,6 @@ select = [ "F", # Pyflakes "PGH", # pygrep-hooks "PL", # Pylint - "PLC", # Pylint Convention - "PLE", # Pylint Error - "PLR", # Pylint Refactor - "PLW", # Pylint Warning "UP", # pyupgrade "FURB", # refurb "TRY", # tryceratops From 982b529630c6c42ccdff81b7d6467fda215802a8 Mon Sep 17 00:00:00 2001 From: Javier Buzzi Date: Thu, 14 Aug 2025 07:41:30 -0400 Subject: [PATCH 8/9] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 291e5f18..808008d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -129,7 +129,7 @@ exclude_lines = [ ] [tool.ruff] -# preview = true # TODO: Enable this after resolving all Ruff preview lint errors (see https://github.com/pytest-dev/pytest-django/issues/1234) +# preview = true # TODO: Enable this when we have the bandwidth line-length = 99 extend-exclude = [ "pytest_django/_version.py", From e22d79abea3af7b113f8daf2904ec187780ec8d4 Mon Sep 17 00:00:00 2001 From: Javier Buzzi Date: Thu, 14 Aug 2025 07:43:06 -0400 Subject: [PATCH 9/9] Update pyproject.toml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 808008d8..8b53c8b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,7 +136,7 @@ extend-exclude = [ ] [tool.ruff.lint] -select = [ +extend-select = [ "AIR", # Airflow "ERA", # eradicate "FAST", # FastAPI