Skip to content

Commit f3e02ac

Browse files
authored
Add future annotations (#276)
1 parent 6a94a15 commit f3e02ac

File tree

9 files changed

+30
-4
lines changed

9 files changed

+30
-4
lines changed

pyproject.toml

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

353354
[tool.ruff.lint.per-file-ignores]
354355
"_version.py" = ["SIM108"]

src/ansible_creator/__main__.py

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

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

911

src/ansible_creator/compat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
here.
66
"""
77

8+
from __future__ import annotations
9+
810
import sys
911

1012

src/ansible_creator/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"""Definition of constants for this package."""
22

3+
from __future__ import annotations
4+
5+
36
GLOBAL_TEMPLATE_VARS = {
47
"DEV_CONTAINER_IMAGE": "ghcr.io/ansible/community-ansible-dev-tools:latest",
58
"DEV_FILE_IMAGE": "ghcr.io/ansible/ansible-workspace-env-reference:latest",

src/ansible_creator/types.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
"""A home for shared types."""
22

3-
from collections.abc import Sequence
3+
from __future__ import annotations
4+
45
from dataclasses import dataclass, field
6+
from typing import TYPE_CHECKING
57

68
from ansible_creator.constants import GLOBAL_TEMPLATE_VARS
79

810

11+
if TYPE_CHECKING:
12+
from collections.abc import Sequence
13+
14+
915
@dataclass
1016
class TemplateData:
1117
"""Dataclass representing the template data.

tests/defaults.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Constants with default values used throughout the tests."""
22

3+
from __future__ import annotations
4+
35
from pathlib import Path
46

57

tests/units/test_compat.py

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

3+
from __future__ import annotations
4+
35
from ansible_creator.compat import Traversable
46

57

tests/units/test_templar.py

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

3+
from __future__ import annotations
4+
35
from ansible_creator.templar import Templar
46
from ansible_creator.types import TemplateData
57

tests/units/test_utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
"""Test the utils module."""
22

3-
from pathlib import Path
3+
from __future__ import annotations
44

5-
import pytest
5+
from pathlib import Path
6+
from typing import TYPE_CHECKING
67

7-
from ansible_creator.output import Output
88
from ansible_creator.types import TemplateData
99
from ansible_creator.utils import Copier, expand_path
1010

1111

12+
if TYPE_CHECKING:
13+
import pytest
14+
15+
from ansible_creator.output import Output
16+
17+
1218
def test_expand_path() -> None:
1319
"""Test expand_path utils."""
1420
home = Path.home().resolve()

0 commit comments

Comments
 (0)