diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b6cfcc68..d8a24230 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -10,7 +10,7 @@ jobs: test: strategy: matrix: - python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] + python: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ] os: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.os }} steps: diff --git a/pyproject.toml b/pyproject.toml index 09525227..68373a90 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ generate = "python scripts/generate.py" format = "ruff format ." isort = "ruff check --select I . --fix" mypy = "mypy ." -ruff = "ruff check src" +ruff = "ruff check src tests --extend-exclude tests/models" safety = "poetry export -f requirements.txt | safety check --bare --stdin" test = "pytest tests" check = "task isort && task format && task mypy && task ruff && task test && task safety" diff --git a/tests/config/test_config.py b/tests/config/test_config.py index 89719b3e..6e576300 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -1,14 +1,16 @@ from __future__ import annotations import argparse -from pathlib import Path -from typing import MutableMapping +from typing import TYPE_CHECKING, MutableMapping import pytest from binarylane.config import DefaultConfig, OptionName, UserConfig from binarylane.config.sources import CommandlineSource, DefaultSource, EnvironmentSource, FileSource +if TYPE_CHECKING: + from pathlib import Path + def test_default_values() -> None: config = DefaultConfig() diff --git a/tests/config/test_repository.py b/tests/config/test_repository.py index 9cdb5fe4..5232d21f 100644 --- a/tests/config/test_repository.py +++ b/tests/config/test_repository.py @@ -1,14 +1,16 @@ from __future__ import annotations from argparse import Namespace -from pathlib import Path -from typing import MutableMapping, Optional +from typing import TYPE_CHECKING, MutableMapping, Optional import pytest from binarylane.config import OptionName, Repository from binarylane.config.sources import CommandlineSource, DefaultSource, EnvironmentSource, FileSource, RuntimeSource +if TYPE_CHECKING: + from pathlib import Path + def test_init_default_source() -> None: repo = Repository() diff --git a/tests/config/test_sources.py b/tests/config/test_sources.py index 1cf5b717..9e2cdd50 100644 --- a/tests/config/test_sources.py +++ b/tests/config/test_sources.py @@ -1,12 +1,14 @@ from __future__ import annotations import argparse -from pathlib import Path -from typing import MutableMapping +from typing import TYPE_CHECKING, MutableMapping from binarylane.config import OptionName from binarylane.config.sources import CommandlineSource, DefaultSource, EnvironmentSource, FileSource, RuntimeSource +if TYPE_CHECKING: + from pathlib import Path + def test_commandline_get() -> None: parser = argparse.ArgumentParser() diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index f2fc3f08..2266d8d9 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,9 +1,13 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import pytest from binarylane.console.app import App -from binarylane.console.runners import Context + +if TYPE_CHECKING: + from binarylane.console.runners import Context class AppWithContext(App): diff --git a/tests/integration/test_app.py b/tests/integration/test_app.py index df45c6f9..5104944c 100644 --- a/tests/integration/test_app.py +++ b/tests/integration/test_app.py @@ -1,9 +1,13 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import pytest -from _pytest.capture import CaptureFixture -from tests.integration.conftest import App, AppWithContext +if TYPE_CHECKING: + from _pytest.capture import CaptureFixture + + from tests.integration.conftest import App, AppWithContext def test_app_program_name(app: App, capsys: CaptureFixture[str]) -> None: diff --git a/tests/integration/test_curl.py b/tests/integration/test_curl.py index 398c5219..22b7a2ce 100644 --- a/tests/integration/test_curl.py +++ b/tests/integration/test_curl.py @@ -1,12 +1,15 @@ from __future__ import annotations -from _pytest.capture import CaptureFixture +from typing import TYPE_CHECKING from tests.runner import TypeRunner from binarylane.console.commands.api import get_v2_sizes as size_list from binarylane.console.runners.command import CommandRunner +if TYPE_CHECKING: + from _pytest.capture import CaptureFixture + def test_curl_size_list(capsys: CaptureFixture[str]) -> None: runner = TypeRunner[CommandRunner](size_list.Command) diff --git a/tests/integration/test_help.py b/tests/integration/test_help.py index b6de41a0..7e740d2a 100644 --- a/tests/integration/test_help.py +++ b/tests/integration/test_help.py @@ -1,12 +1,15 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import pytest from pytest import CaptureFixture -from tests.integration.conftest import App - from binarylane.console.metadata import program_description +if TYPE_CHECKING: + from tests.integration.conftest import App + def test_app_root_help(app: App, capsys: CaptureFixture[str]) -> None: with pytest.raises(SystemExit): diff --git a/tests/integration/test_list.py b/tests/integration/test_list.py index 8b663815..68d18497 100644 --- a/tests/integration/test_list.py +++ b/tests/integration/test_list.py @@ -1,13 +1,17 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import pytest -from _pytest.capture import CaptureFixture from tests.runner import TypeRunner from binarylane.console.commands.api import get_v2_sizes as size_list from binarylane.console.runners.command import CommandRunner +if TYPE_CHECKING: + from _pytest.capture import CaptureFixture + def test_list_invalid_format_value(capsys: CaptureFixture[str]) -> None: runner = TypeRunner[CommandRunner](size_list.Command) diff --git a/tests/integration/test_output_json.py b/tests/integration/test_output_json.py index 33c708be..54ba1eb1 100644 --- a/tests/integration/test_output_json.py +++ b/tests/integration/test_output_json.py @@ -1,7 +1,8 @@ from __future__ import annotations +from typing import TYPE_CHECKING + import pytest -from _pytest.capture import CaptureFixture from binarylane.models.meta import Meta from binarylane.models.route_entry import RouteEntry @@ -13,6 +14,9 @@ from binarylane.console.runners.command import CommandRunner from binarylane.console.runners.list import ListRunner +if TYPE_CHECKING: + from _pytest.capture import CaptureFixture + @pytest.fixture def vpc() -> Vpc: diff --git a/tests/integration/test_version.py b/tests/integration/test_version.py index 89b596e0..b4b129eb 100644 --- a/tests/integration/test_version.py +++ b/tests/integration/test_version.py @@ -1,9 +1,12 @@ from __future__ import annotations -from _pytest.capture import CaptureFixture +from typing import TYPE_CHECKING from binarylane.console.app import App +if TYPE_CHECKING: + from _pytest.capture import CaptureFixture + def test_version(capsys: CaptureFixture[str]) -> None: runner = App() diff --git a/tests/models/links.py b/tests/models/links.py index 66789dd2..3341af5c 100644 --- a/tests/models/links.py +++ b/tests/models/links.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, Dict import attr diff --git a/tests/models/network.py b/tests/models/network.py index 62c6247d..5c972ae7 100644 --- a/tests/models/network.py +++ b/tests/models/network.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Dict, List, Union +from typing import Any, Dict, Union import attr diff --git a/tests/models/server.py b/tests/models/server.py index 25fb331d..01eaf21b 100644 --- a/tests/models/server.py +++ b/tests/models/server.py @@ -1,7 +1,7 @@ from __future__ import annotations import datetime -from typing import Any, Dict, List, Union +from typing import Any, Dict, List import attr diff --git a/tests/parser/test_enum.py b/tests/parser/test_enum.py index 81722dd8..32ab121c 100644 --- a/tests/parser/test_enum.py +++ b/tests/parser/test_enum.py @@ -52,7 +52,7 @@ def test_single_value_enum_does_not_require_configuration() -> None: assert parser.parse([]).mapped_object.to_dict() == {"type": "ping"} # It is not a valid - with pytest.raises(ArgumentError) as exc: + with pytest.raises(ArgumentError): parser.parse(["--type", "ping"]) diff --git a/tests/printers/test_formatter.py b/tests/printers/test_formatter.py index 57126153..90a528bc 100644 --- a/tests/printers/test_formatter.py +++ b/tests/printers/test_formatter.py @@ -1,13 +1,15 @@ from __future__ import annotations -from typing import Any, Dict, List +from typing import TYPE_CHECKING, Any, Dict, List from tests.models.network import Network from tests.models.network_type import NetworkType -from tests.models.servers_response import ServersResponse from binarylane.console.printers import formatter +if TYPE_CHECKING: + from tests.models.servers_response import ServersResponse + def test_format_str() -> None: assert formatter.format_response("test", True) == [[formatter.DEFAULT_HEADING], ["test"]] diff --git a/tests/runners/test_action_runner.py b/tests/runners/test_action_runner.py index a25e05ef..417f824a 100644 --- a/tests/runners/test_action_runner.py +++ b/tests/runners/test_action_runner.py @@ -1,16 +1,19 @@ from __future__ import annotations -from http import HTTPStatus -from typing import Tuple +from typing import TYPE_CHECKING, Tuple -from pytest import CaptureFixture - -from binarylane.client import Client from tests.runner import TypeRunner from binarylane.console.parser.object_attribute import Mapping from binarylane.console.runners import action +if TYPE_CHECKING: + from http import HTTPStatus + + from pytest import CaptureFixture + + from binarylane.client import Client + class ActionRunner(action.ActionRunner): def create_mapping(self) -> Mapping: diff --git a/tests/runners/test_actionlink_runner.py b/tests/runners/test_actionlink_runner.py index 00d8b7c1..c545ae2d 100644 --- a/tests/runners/test_actionlink_runner.py +++ b/tests/runners/test_actionlink_runner.py @@ -1,16 +1,19 @@ from __future__ import annotations -from http import HTTPStatus -from typing import Tuple +from typing import TYPE_CHECKING, Tuple -from pytest import CaptureFixture - -from binarylane.client import Client from tests.runner import TypeRunner from binarylane.console.parser.object_attribute import Mapping from binarylane.console.runners import actionlink +if TYPE_CHECKING: + from http import HTTPStatus + + from pytest import CaptureFixture + + from binarylane.client import Client + class ActionLinkRunner(actionlink.ActionLinkRunner): def create_mapping(self) -> Mapping: diff --git a/tests/runners/test_command_runner.py b/tests/runners/test_command_runner.py index 5ba5d467..85bd26e4 100644 --- a/tests/runners/test_command_runner.py +++ b/tests/runners/test_command_runner.py @@ -1,19 +1,23 @@ from __future__ import annotations -from http import HTTPStatus -from typing import Tuple +from typing import TYPE_CHECKING, Tuple import pytest -from _pytest.capture import CaptureFixture -from binarylane.client import Client from binarylane.models.problem_details import ProblemDetails from binarylane.models.validation_problem_details import ValidationProblemDetails from tests.runner import TypeRunner -from binarylane.console.parser import Mapping, Namespace +from binarylane.console.parser import Mapping from binarylane.console.runners import command +if TYPE_CHECKING: + from http import HTTPStatus + + from _pytest.capture import CaptureFixture + + from binarylane.client import Client + class CommandRunner(command.CommandRunner): def create_mapping(self) -> Mapping: diff --git a/tests/runners/test_list.py b/tests/runners/test_list.py index f7bc7c01..bbca8143 100644 --- a/tests/runners/test_list.py +++ b/tests/runners/test_list.py @@ -1,16 +1,18 @@ from __future__ import annotations -from http import HTTPStatus -from typing import Dict, List, Tuple +from typing import TYPE_CHECKING, Dict, List, Tuple import pytest -from binarylane.client import Client - from binarylane.console.parser import Mapping from binarylane.console.runners import Context from binarylane.console.runners import list as list_runner +if TYPE_CHECKING: + from http import HTTPStatus + + from binarylane.client import Client + class ListRunner(list_runner.ListRunner): default_format_property: List[str]