Skip to content

Commit 487b25d

Browse files
chore: Update pyproject.toml (#243)
* Allow ruff to add future annotations * chore: auto fixes from pre-commit.com hooks * Move TYPE_CHECKING --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent cace6c9 commit 487b25d

13 files changed

+72
-16
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ parametrize-values-type = "tuple"
340340
known-first-party = ["ansible_dev_environment"]
341341
lines-after-imports = 2 # Ensures consistency for cases when there's variable vs function/class definitions after imports
342342
lines-between-types = 1 # Separate import/from with 1 line
343+
required-imports = ["from __future__ import annotations"]
343344

344345
[tool.ruff.lint.per-file-ignores]
345346
"_version.py" = ["SIM108"]

src/ansible_dev_environment/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
via :command:`python -m ansible_dev_environment`.
55
"""
66

7+
from __future__ import annotations
8+
79
from ansible_dev_environment.cli import main
810

911

src/ansible_dev_environment/subcommands/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""The subcommands module contains all the subcommands for ansible-dev-environment."""
22

33
# ruff: noqa: F401
4+
from __future__ import annotations
45

56
from .checker import Checker as Check
67
from .inspector import Inspector as Inspect

tests/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
Tracing '/**/src/<package>/__init__.py'
1717
"""
1818

19+
from __future__ import annotations
20+
1921
import json
2022
import os
2123
import shutil
2224
import tarfile
2325
import tempfile
2426
import warnings
2527

26-
from collections.abc import Generator
2728
from pathlib import Path
29+
from typing import TYPE_CHECKING
2830
from urllib.request import HTTPError, urlopen
2931

3032
import pytest
@@ -33,7 +35,12 @@
3335
import ansible_dev_environment # noqa: F401
3436

3537
from ansible_dev_environment.cli import Cli
36-
from ansible_dev_environment.config import Config
38+
39+
40+
if TYPE_CHECKING:
41+
from collections.abc import Generator
42+
43+
from ansible_dev_environment.config import Config
3744

3845

3946
GALAXY_CACHE = Path(__file__).parent.parent / ".cache" / ".galaxy_cache"

tests/integration/test_basic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Basic smoke tests."""
22

3+
from __future__ import annotations
4+
35
import json
46

57
from pathlib import Path

tests/test_argparser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Tests for the arg_parser module."""
22

3+
from __future__ import annotations
4+
35
import pytest
46

57
from ansible_dev_environment.arg_parser import (

tests/unit/test_cli.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
"""Test cli functionality."""
22

3-
from collections.abc import Generator
3+
from __future__ import annotations
4+
45
from pathlib import Path
6+
from typing import TYPE_CHECKING
57

68
import pytest
79

810
from ansible_dev_environment.cli import Cli
911

1012

13+
if TYPE_CHECKING:
14+
from collections.abc import Generator
15+
16+
1117
def main(cli: Cli) -> None:
1218
"""Stub main function for testing.
1319

tests/unit/test_inspector.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
"""Tests for the inspector module."""
22

3+
from __future__ import annotations
4+
35
import copy
46
import importlib
57
import json
68
import re
79
import sys
810

9-
import pytest
11+
from typing import TYPE_CHECKING
1012

11-
from ansible_dev_environment.config import Config
1213
from ansible_dev_environment.subcommands import inspector
1314

1415

16+
if TYPE_CHECKING:
17+
import pytest
18+
19+
from ansible_dev_environment.config import Config
20+
21+
1522
def test_output_no_color(session_venv: Config, capsys: pytest.CaptureFixture[str]) -> None:
1623
"""Test the inspector output.
1724

tests/unit/test_installer.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
# pylint: disable=C0302
22
"""Tests for the installer."""
3+
from __future__ import annotations
34

45
import os
56
import shutil
67
import subprocess
78

89
from argparse import Namespace
910
from pathlib import Path
10-
from typing import Any
11+
from typing import TYPE_CHECKING, Any
1112

1213
import pytest
1314
import yaml
1415

1516
from ansible_dev_environment.arg_parser import parse
1617
from ansible_dev_environment.cli import Cli
17-
from ansible_dev_environment.collection import Collection
1818
from ansible_dev_environment.config import Config
19-
from ansible_dev_environment.output import Output
2019
from ansible_dev_environment.subcommands.installer import Installer
2120
from ansible_dev_environment.utils import subprocess_run
2221

2322

23+
if TYPE_CHECKING:
24+
from ansible_dev_environment.collection import Collection
25+
from ansible_dev_environment.output import Output
26+
27+
2428
NAMESPACE = Namespace()
2529
NAMESPACE.verbose = 0
2630

tests/unit/test_lister.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
"""Test the lister module."""
22

3+
from __future__ import annotations
4+
35
import copy
46
import tarfile
57

6-
from pathlib import Path
8+
from typing import TYPE_CHECKING
79

8-
import pytest
910
import yaml
1011

1112
from ansible_dev_environment.arg_parser import parse
1213
from ansible_dev_environment.config import Config
13-
from ansible_dev_environment.output import Output
1414
from ansible_dev_environment.subcommands.installer import Installer
1515
from ansible_dev_environment.subcommands.lister import Lister
1616
from ansible_dev_environment.utils import JSONVal, collect_manifests
1717

1818

19+
if TYPE_CHECKING:
20+
from pathlib import Path
21+
22+
import pytest
23+
24+
from ansible_dev_environment.output import Output
25+
26+
1927
def test_success(session_venv: Config, capsys: pytest.CaptureFixture[str]) -> None:
2028
"""Test the lister.
2129

tests/unit/test_main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test the main file."""
22

3+
from __future__ import annotations
4+
35
import runpy
46

57
import pytest

tests/unit/test_treemaker.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
"""Test the treemaker module."""
22

3+
from __future__ import annotations
4+
35
from argparse import Namespace
4-
from pathlib import Path
6+
from typing import TYPE_CHECKING
57
from venv import EnvBuilder
68

79
import pytest
810

911
from ansible_dev_environment.config import Config
10-
from ansible_dev_environment.output import Output
1112
from ansible_dev_environment.subcommands.treemaker import TreeMaker, TreeWithReqs, add_python_reqs
12-
from ansible_dev_environment.utils import JSONVal
13+
14+
15+
if TYPE_CHECKING:
16+
from pathlib import Path
17+
18+
from ansible_dev_environment.output import Output
19+
from ansible_dev_environment.utils import JSONVal
1320

1421

1522
def test_tree_empty(

tests/unit/test_uninstaller.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
"""Test the uninstaller module."""
22

3+
from __future__ import annotations
4+
35
import copy
46

5-
from pathlib import Path
7+
from typing import TYPE_CHECKING
68

79
import pytest
810

911
from ansible_dev_environment.arg_parser import parse
1012
from ansible_dev_environment.config import Config
11-
from ansible_dev_environment.output import Output
1213
from ansible_dev_environment.subcommands.installer import Installer
1314
from ansible_dev_environment.subcommands.uninstaller import UnInstaller
1415

1516

17+
if TYPE_CHECKING:
18+
from pathlib import Path
19+
20+
from ansible_dev_environment.output import Output
21+
22+
1623
def test_many(session_venv: Config, capsys: pytest.CaptureFixture[str]) -> None:
1724
"""Test the uninstaller with many collections.
1825

0 commit comments

Comments
 (0)