Skip to content

Commit 7a17e5a

Browse files
authored
fix: use FA instead of adding import via isort (#666)
* fix: use FA instead of adding import via isort Signed-off-by: Henry Schreiner <[email protected]> * fix: no future needed in pyi Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent cb83c41 commit 7a17e5a

File tree

14 files changed

+52
-26
lines changed

14 files changed

+52
-26
lines changed

docs/pages/guides/style.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,17 @@ extend-select = [
220220
"ARG", # flake8-unused-arguments
221221
"B", # flake8-bugbear
222222
"C4", # flake8-comprehensions
223+
"DTZ", # flake8-datetimez
223224
"EM", # flake8-errmsg
224225
"EXE", # flake8-executable
226+
"FA", # flake8-future-annotations
225227
"FURB", # refurb
226228
"G", # flake8-logging-format
227229
"I", # isort
228230
"ICN", # flake8-import-conventions
229231
"NPY", # NumPy specific rules
230232
"PD", # pandas-vet
233+
"PERF", # perflint
231234
"PGH", # pygrep-hooks
232235
"PIE", # flake8-pie
233236
"PL", # pylint
@@ -237,7 +240,9 @@ extend-select = [
237240
"RET", # flake8-return
238241
"RUF", # Ruff-specific
239242
"SIM", # flake8-simplify
243+
"SLOT", # flake8-slots
240244
"T20", # flake8-print
245+
"TC", # flake8-type-checking
241246
"UP", # pyupgrade
242247
"YTT", # flake8-2020
243248
]
@@ -246,7 +251,6 @@ ignore = [
246251
"PLR2004", # Magic value used in comparison
247252
]
248253
typing-modules = ["mypackage._compat.typing"]
249-
isort.required-imports = ["from __future__ import annotations"]
250254
251255
[tool.ruff.lint.per-file-ignores]
252256
"tests/**" = ["T20"]

helpers/cog_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import contextlib
55
import tempfile
66
import typing
7-
from collections.abc import Generator
87
from pathlib import Path
98
from types import SimpleNamespace
109

1110
if typing.TYPE_CHECKING:
11+
from collections.abc import Generator
1212
from typing import Self
1313

1414
from cookiecutter.main import cookiecutter

noxfile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
import urllib.error
2727
import urllib.request
2828
import zipfile
29-
from collections.abc import Callable
3029
from pathlib import Path
31-
from typing import Any
30+
from typing import TYPE_CHECKING, Any
3231

3332
import nox
3433

34+
if TYPE_CHECKING:
35+
from collections.abc import Callable
36+
3537
nox.needs_version = ">=2025.2.9"
3638
nox.options.default_venv_backend = "uv|virtualenv"
3739

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,12 @@ messages_control.disable = [
153153

154154
[tool.ruff.lint]
155155
extend-select = [
156-
"B", # flake8-bugbear
157-
"I", # isort
158156
"ARG", # flake8-unused-arguments
157+
"B", # flake8-bugbear
159158
"C4", # flake8-comprehensions
160159
"EM", # flake8-errmsg
160+
"FA", # flake8-future-annotations
161+
"I", # isort
161162
"ICN", # flake8-import-conventions
162163
"PGH", # pygrep-hooks
163164
"PIE", # flake8-pie
@@ -167,8 +168,9 @@ extend-select = [
167168
"RET", # flake8-return
168169
"RUF", # Ruff-specific
169170
"SIM", # flake8-simplify
170-
"TID251", # flake8-tidy-imports.banned-api
171171
"T20", # flake8-print
172+
"TC", # flake8-type-check
173+
"TID251", # flake8-tidy-imports.banned-api
172174
"UP", # pyupgrade
173175
"YTT", # flake8-2020
174176
]

src/sp_repo_review/checks/general.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from __future__ import annotations
22

3-
from typing import Any
3+
from typing import TYPE_CHECKING, Any
44

5-
from .._compat.importlib.resources.abc import Traversable
65
from . import mk_url
76

7+
if TYPE_CHECKING:
8+
from .._compat.importlib.resources.abc import Traversable
9+
810
# PY: Python Project
911
## 0xx: File existence
1012

src/sp_repo_review/checks/github.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
from __future__ import annotations
55

66
from pathlib import Path
7-
from typing import Any
7+
from typing import TYPE_CHECKING, Any
88

99
import yaml
1010

11-
from .._compat.importlib.resources.abc import Traversable
1211
from . import mk_url
1312

13+
if TYPE_CHECKING:
14+
from .._compat.importlib.resources.abc import Traversable
15+
1416

1517
def workflows(root: Traversable) -> dict[str, Any]:
1618
workflows_base_path = root.joinpath(".github/workflows")

src/sp_repo_review/checks/noxfile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
import ast
88
import dataclasses
99
import re
10-
from typing import Any
10+
from typing import TYPE_CHECKING, Any
1111

1212
from .._compat import tomllib
13-
from .._compat.importlib.resources.abc import Traversable
1413
from . import mk_url
1514

15+
if TYPE_CHECKING:
16+
from .._compat.importlib.resources.abc import Traversable
17+
1618
REGEX = re.compile(
1719
r"(?m)^# /// (?P<type>[a-zA-Z0-9-]+)$\s(?P<content>(^#(| .*)$\s)+)^# ///$"
1820
)

src/sp_repo_review/checks/precommit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
from __future__ import annotations
55

6-
from typing import Any, ClassVar
6+
from typing import TYPE_CHECKING, Any, ClassVar
77

88
import yaml
99

10-
from .._compat.importlib.resources.abc import Traversable
1110
from . import mk_url
1211

12+
if TYPE_CHECKING:
13+
from .._compat.importlib.resources.abc import Traversable
14+
1315

1416
def precommit(root: Traversable) -> dict[str, Any]:
1517
precommit_path = root.joinpath(".pre-commit-config.yaml")

src/sp_repo_review/checks/readthedocs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from __future__ import annotations
22

3-
from typing import Any
3+
from typing import TYPE_CHECKING, Any
44

55
import yaml
66

7-
from .._compat.importlib.resources.abc import Traversable
87
from . import mk_url
98

9+
if TYPE_CHECKING:
10+
from .._compat.importlib.resources.abc import Traversable
11+
1012

1113
class ReadTheDocs:
1214
family = "docs"

src/sp_repo_review/checks/ruff.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from __future__ import annotations
22

3-
from collections.abc import Generator
4-
from typing import Any, ClassVar, Protocol
3+
from typing import TYPE_CHECKING, Any, ClassVar, Protocol
54

65
from .._compat import tomllib
7-
from .._compat.importlib.resources.abc import Traversable
86
from . import mk_url
97

8+
if TYPE_CHECKING:
9+
from collections.abc import Generator
10+
11+
from .._compat.importlib.resources.abc import Traversable
12+
1013
## R0xx: Ruff general
1114
## R1xx: Ruff checks
1215
## R2xx: Ruff deprecations

0 commit comments

Comments
 (0)