Skip to content

Commit c22a25d

Browse files
authored
Enable more Ruff rules (#845)
Aligns Ruff rules in this project with `django-stubs`.
1 parent 62af262 commit c22a25d

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

mypy_drf_plugin/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def _get_currently_defined_serializers(self) -> dict[str, int]:
2323
"serializer_bases", {fullnames.BASE_SERIALIZER_FULLNAME: 1}
2424
)
2525
return serializer_bases
26-
else:
27-
return {}
26+
return {}
2827

2928
def get_base_class_hook(self, fullname: str) -> Callable[[ClassDefContext], None] | None:
3029
if fullname in self._get_currently_defined_serializers():

pyproject.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,30 @@ select = [
8888
"B", # bugbear
8989
"E", # pycodestyle
9090
"F", # pyflakes
91+
"FURB", # refurb
9192
"INP", # flake8-tidy-imports
9293
"W", # pycodestyle
9394
"I", # isort
95+
"ISC001", # Implicitly concatenated string literals on one line
96+
"ISC002", # Implicitly concatenated string literals over multiple lines
9497
"UP", # pyupgrade
9598
"TID251", # Disallowed imports (flake8-tidy-imports.banned-api)
9699
"PYI", # flake8-pyi
97100
"RUF100", # Equivalent to flake8-noqa NQA103
98101
"PGH004", # Equivalent to flake8-noqa NQA104
99102
"PGH003", # Disallowed blanket `type: ignore` annotations.
103+
"RET504", # Unnecessary assignment to {name} before return statement
104+
"RET505", # Unnecessary {branch} after return statement
105+
"RET506", # Unnecessary {branch} after raise statement
106+
"RET507", # Unnecessary {branch} after continue statement
107+
"RET508", # Unnecessary {branch} after break statement
108+
"RUF", # Ruff specific rules
109+
"TC", # flake8-type-checking
110+
]
111+
ignore = [
112+
"PYI021", # We have a few meaningful docstrings for stubs only constructs/utilities.
113+
"PYI041", # This might not be obvious that `float | int` is mostly equivalent to `float` typing wise | int | str
100114
]
101-
ignore = ["PYI021", "PYI024", "PYI041", "PYI043"]
102115

103116
[tool.ruff.lint.per-file-ignores]
104117
"*.pyi" = [

rest_framework-stubs/compat.pyi

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,24 @@ LONG_SEPARATORS: tuple[str, str]
6060
INDENT_SEPARATORS: tuple[str, str]
6161

6262
__all__ = [
63+
"INDENT_SEPARATORS",
64+
"LONG_SEPARATORS",
65+
"SHORT_SEPARATORS",
66+
"CodeBlockPreprocessor",
67+
"Preprocessor",
68+
"QuerySet",
69+
"apply_markdown",
6370
"coreapi",
6471
"coreschema",
65-
"requests",
66-
"postgres_fields",
67-
"QuerySet",
68-
"uritemplate",
69-
"yaml",
7072
"inflection",
71-
"pygments",
7273
"markdown",
73-
"apply_markdown",
74-
"Preprocessor",
75-
"CodeBlockPreprocessor",
74+
"md_filter_add_syntax_highlight",
75+
"postgres_fields",
76+
"pygments",
7677
"pygments_css",
7778
"pygments_highlight",
78-
"md_filter_add_syntax_highlight",
79+
"requests",
7980
"unicode_http_header",
80-
"SHORT_SEPARATORS",
81-
"LONG_SEPARATORS",
82-
"INDENT_SEPARATORS",
81+
"uritemplate",
82+
"yaml",
8383
]

0 commit comments

Comments
 (0)