diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb3ca6ee0..dcd7ef4f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ exclude: > )$ repos: - repo: https://github.com/renovatebot/pre-commit-hooks - rev: 41.99.7 + rev: 41.109.0 hooks: - id: renovate-config-validator alias: renovate @@ -44,39 +44,11 @@ repos: additional_dependencies: - prettier - prettier-plugin-toml - - - repo: https://github.com/pappasam/toml-sort - rev: v0.24.3 - hooks: - - id: toml-sort-fix - - - repo: https://github.com/tox-dev/tox-ini-fmt - rev: 1.6.0 - hooks: - - id: tox-ini-fmt - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.12.12" - hooks: - - id: ruff - entry: sh -c 'ruff check --fix --force-exclude && ruff format --force-exclude' - types_or: [python, pyi] - - repo: https://github.com/streetsidesoftware/cspell-cli rev: v9.2.0 hooks: - id: cspell name: Spell check with cspell - - - repo: https://github.com/Lucas-C/pre-commit-hooks.git - rev: v1.5.5 - hooks: - - id: remove-tabs - exclude: > - (?x)^( - .config/pylint-baseline.txt - )$ - - repo: https://github.com/pre-commit/pre-commit-hooks.git rev: v6.0.0 hooks: @@ -157,6 +129,11 @@ repos: additional_dependencies: - flake8-docstrings # uses pydocstyle + - repo: https://github.com/pappasam/toml-sort + rev: v0.24.3 + hooks: + - id: toml-sort-fix + alias: toml - repo: https://github.com/jsh9/pydoclint rev: 0.7.3 hooks: @@ -168,8 +145,15 @@ repos: hooks: - id: pyupgrade args: ["--py310-plus"] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.13.0 + hooks: + - id: ruff-format + alias: ruff + - id: ruff-check + alias: ruff - repo: https://github.com/pre-commit/mirrors-mypy.git - rev: v1.17.1 + rev: v1.18.1 hooks: - id: mypy additional_dependencies: diff --git a/pyproject.toml b/pyproject.toml index d9e198ae9..c7d3108ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ authors = [{"email" = "bthornto@redhat.com", "name" = "Bradley A. Thornton"}] classifiers = [ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', 'Operating System :: OS Independent', 'Topic :: Software Development :: Testing', 'Topic :: Software Development :: Quality Assurance', @@ -30,7 +29,7 @@ classifiers = [ description = "A text-based user interface (TUI) for the Red Hat Ansible Automation Platform" dynamic = ["version", "dependencies", "optional-dependencies"] keywords = ["ansible"] -license = {text = "Apache"} +license = "Apache-2.0" maintainers = [{"email" = "info@ansible.com", "name" = "Ansible by Red Hat"}] name = "ansible-navigator" readme = "README.md" @@ -51,7 +50,7 @@ repository = "https://github.com/ansible/ansible-navigator" source = ["src", ".tox/*/site-packages"] [tool.coverage.report] -exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"] +exclude_also = ["pragma: no cover", "if TYPE_CHECKING:"] show_missing = true skip_covered = true @@ -69,6 +68,7 @@ disallow_any_generics = true # disallow_untyped_calls = true disallow_untyped_defs = true error_summary = true +exclude_gitignore = true incremental = false python_version = "3.10" @@ -359,7 +359,7 @@ filterwarnings = [ "ignore::pytest.PytestUnraisableExceptionWarning", "ignore::DeprecationWarning:ansible_runner" ] -junit_family = "legacy" # see https://docs.codecov.com/docs/test-analytics +junit_family = "xunit2" # see https://docs.codecov.com/docs/test-analytics [tool.pytest_env] PYTEST_CHECK_TEST_DUPLICATE = 0 @@ -442,7 +442,7 @@ optional-dependencies.test = {file = [".config/requirements-test.in"]} [tool.setuptools_scm] local_scheme = "no-local-version" -write_to = "src/ansible_navigator/_version.py" +version_file = "src/ansible_navigator/_version.py" [tool.tomlsort] in_place = true diff --git a/src/ansible_navigator/tm_tokenize/fchainmap.py b/src/ansible_navigator/tm_tokenize/fchainmap.py index 26da03f83..0ce2923aa 100644 --- a/src/ansible_navigator/tm_tokenize/fchainmap.py +++ b/src/ansible_navigator/tm_tokenize/fchainmap.py @@ -8,7 +8,7 @@ TValue_co = TypeVar("TValue_co", covariant=True) -class Indexable(Generic[TKey_contra, TValue_co], Protocol): +class Indexable(Generic[TKey_contra, TValue_co], Protocol): # noqa: PYI059 def __getitem__(self, key: TKey_contra) -> TValue_co: """Get the value associated with the given key. diff --git a/src/ansible_navigator/utils/compatibility.py b/src/ansible_navigator/utils/compatibility.py index 7688f89ad..d25dbeba8 100644 --- a/src/ansible_navigator/utils/compatibility.py +++ b/src/ansible_navigator/utils/compatibility.py @@ -1,17 +1,17 @@ """Conditional imports related to python versions.""" import importlib.metadata as importlib_metadata -import sys # https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases from typing import TypeAlias -if sys.version_info < (3, 11): - from importlib.abc import Traversable -else: +try: from importlib.resources.abc import Traversable +except ImportError: + # pylint: disable-next=deprecated-class + from importlib.abc import Traversable __all__ = ["Traversable", "TypeAlias", "importlib_metadata"] diff --git a/src/ansible_navigator/utils/json_schema.py b/src/ansible_navigator/utils/json_schema.py index 526a7b132..4ba71abd9 100644 --- a/src/ansible_navigator/utils/json_schema.py +++ b/src/ansible_navigator/utils/json_schema.py @@ -16,10 +16,10 @@ if TYPE_CHECKING: - from collections import deque + from collections.abc import Sequence -def to_path(schema_path: deque[Any]) -> str: +def to_path(schema_path: Sequence[Any]) -> str: """Flatten a path to a dot delimited string. Args: @@ -31,7 +31,7 @@ def to_path(schema_path: deque[Any]) -> str: return ".".join(str(index) for index in schema_path) -def json_path(absolute_path: deque[Any]) -> str: +def json_path(absolute_path: Sequence[Any]) -> str: """Flatten a data path to a dot delimited string. Args: @@ -97,7 +97,7 @@ def validate(schema: str | dict[str, Any], data: dict[str, Any]) -> list[JsonSch if isinstance(schema, str): schema = json.loads(schema) - if isinstance(schema, bool): + if isinstance(schema, (bool, str)): msg = "Unexpected schema data." raise TypeError(msg) validator = validator_for(schema) @@ -124,15 +124,19 @@ def validate(schema: str | dict[str, Any], data: dict[str, Any]) -> list[JsonSch for validation_error in validation_errors: if isinstance(validation_error, ValidationError): + if isinstance(validation_error.absolute_path, bool): + path = str(validation_error.absolute_path) + else: + path = to_path(validation_error.absolute_path) error = JsonSchemaError( message=validation_error.message, - data_path=to_path(validation_error.absolute_path), - json_path=json_path(validation_error.absolute_path), + data_path=path, + json_path=path, schema_path=to_path(validation_error.relative_schema_path), - relative_schema=validation_error.schema, - expected=validation_error.validator_value, - validator=validation_error.validator, - found=validation_error.instance, + relative_schema=str(validation_error.schema), + expected=str(validation_error.validator_value), + validator=str(validation_error.validator), + found=str(validation_error.instance), ) errors.append(error) return errors diff --git a/tests/integration/_common.py b/tests/integration/_common.py index f98ccebf2..4e4729d17 100644 --- a/tests/integration/_common.py +++ b/tests/integration/_common.py @@ -248,7 +248,7 @@ def copytree( try: if symlinks and source_path.is_symlink(): source_link = source_path.readlink() - os.symlink(source_link, destination_path) + source_link.symlink_to(destination_path) elif source_path.is_dir(): copytree( source_path,