Skip to content

Commit

Permalink
chore: Update pyproject.toml (#335)
Browse files Browse the repository at this point in the history
* Allow ruff to add future annotations

* chore: auto fixes from pre-commit.com hooks

* Move into TYPCE_CHECKING

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
cidrblock and pre-commit-ci[bot] authored Aug 9, 2024
1 parent 735d55f commit 4faaa6b
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 15 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ parametrize-values-type = "tuple"
known-first-party = ["ansible_dev_tools"]
lines-after-imports = 2 # Ensures consistency for cases when there's variable vs function/class definitions after imports
lines-between-types = 1 # Separate import/from with 1 line
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.per-file-ignores]
"_version.py" = ["SIM108"]
Expand Down
2 changes: 2 additions & 0 deletions src/ansible_dev_tools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
via :command:`python3 -m ansible_dev_tools`.
"""

from __future__ import annotations

from .cli import main


Expand Down
2 changes: 2 additions & 0 deletions src/ansible_dev_tools/arg_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Parse the command line arguments."""

from __future__ import annotations

import argparse

from .version_builder import version_builder
Expand Down
8 changes: 7 additions & 1 deletion src/ansible_dev_tools/server_utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
"""Utility functions requiring server dependencies."""

from __future__ import annotations

from importlib import resources as importlib_resources
from typing import TYPE_CHECKING

import yaml

from django.http import FileResponse, HttpRequest, HttpResponse
from openapi_core import OpenAPI
from openapi_core.contrib.django import DjangoOpenAPIRequest, DjangoOpenAPIResponse
from openapi_core.exceptions import OpenAPIError
from openapi_core.unmarshalling.request.datatypes import RequestUnmarshalResult


if TYPE_CHECKING:
from openapi_core.unmarshalling.request.datatypes import RequestUnmarshalResult


OPENAPI = OpenAPI.from_dict(
Expand Down
2 changes: 2 additions & 0 deletions src/ansible_dev_tools/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Utility function not requiring server dependencies."""

from __future__ import annotations


class Colors:
"""ANSI color codes.
Expand Down
2 changes: 2 additions & 0 deletions src/ansible_dev_tools/version_builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Build version text."""

from __future__ import annotations

import importlib.metadata


Expand Down
7 changes: 6 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<...>
Tracing '/**/src/<package>/__init__.py'
"""
from __future__ import annotations

import errno
import os
Expand All @@ -27,9 +28,9 @@
import time
import warnings

from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING

import pytest
import requests
Expand All @@ -39,6 +40,10 @@
from ansible_dev_tools.subcommands.server import Server


if TYPE_CHECKING:
from collections.abc import Callable


FIXTURES_DIR = Path(__file__).parent / "fixtures"


Expand Down
12 changes: 9 additions & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
"""Fixtures for integration tests."""

from __future__ import annotations

import time

from collections.abc import Generator
from typing import TYPE_CHECKING

import pytest

from libtmux import Pane, Session

from ..conftest import Infrastructure # noqa: TID252
if TYPE_CHECKING:
from collections.abc import Generator

from libtmux import Pane, Session

from tests.conftest import Infrastructure


@pytest.fixture()
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Some tests for the CLI module."""

from __future__ import annotations

from typing import Any

import pytest
Expand Down
18 changes: 13 additions & 5 deletions tests/integration/test_container.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
"""Run tests against the container."""

import subprocess
from __future__ import annotations

from collections.abc import Callable
from pathlib import Path
from typing import TYPE_CHECKING

import pytest

from ansible_dev_tools.version_builder import PKGS

from ..conftest import Infrastructure # noqa: TID252
from .conftest import ContainerTmux
from .test_server_creator import test_collection_v1 as tst_collection_v1
from .test_server_creator import test_error as tst_error
from .test_server_creator import test_playbook_v1 as tst_playbook_v1


if TYPE_CHECKING:
import subprocess

from collections.abc import Callable
from pathlib import Path

from tests.conftest import Infrastructure

from .conftest import ContainerTmux


@pytest.mark.container()
def test_versions(exec_container: Callable[[str], subprocess.CompletedProcess[str]]) -> None:
"""Test the versions.
Expand Down
8 changes: 7 additions & 1 deletion tests/integration/test_server_creator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
"""Test the dev tools server for creator."""

from __future__ import annotations

import tarfile

from pathlib import Path
from typing import TYPE_CHECKING

import pytest
import requests


if TYPE_CHECKING:
from pathlib import Path


@pytest.mark.parametrize("resource", ("playbook", "collection"))
def test_error(server_url: str, resource: str) -> None:
"""Test the error response.
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Some basic tests."""

from __future__ import annotations

import runpy

import pytest
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test the cli module."""

from __future__ import annotations

import pytest

from ansible_dev_tools.cli import Cli
Expand Down
10 changes: 7 additions & 3 deletions tests/unit/test_server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"""Test for the server module."""

from typing import Any
from __future__ import annotations

import pytest
from typing import TYPE_CHECKING, Any

from ansible_dev_tools.subcommands.server import Server

if TYPE_CHECKING:
import pytest

from ansible_dev_tools.subcommands.server import Server


def test_server_debug_options(monkeypatch: pytest.MonkeyPatch, adt_server: Server) -> None:
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_server_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
the Server instance configured with the Django settings.
"""

from __future__ import annotations

import json

from http import HTTPStatus
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/test_version_builder.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
"""Tests for the version builder."""

from __future__ import annotations

import re

import pytest
from typing import TYPE_CHECKING

from ansible_dev_tools.version_builder import PKGS, version_builder


if TYPE_CHECKING:
import pytest


def test_version_builder_success() -> None:
"""Test the version builder."""
versions = version_builder()
Expand Down

0 comments on commit 4faaa6b

Please sign in to comment.