Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 14 additions & 30 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ authors = [{"email" = "[email protected]", "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',
Expand All @@ -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" = "[email protected]", "name" = "Ansible by Red Hat"}]
name = "ansible-navigator"
readme = "README.md"
Expand All @@ -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

Expand All @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/tm_tokenize/fchainmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 4 additions & 4 deletions src/ansible_navigator/utils/compatibility.py
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deprecation is only in Python 3.12+ (https://docs.python.org/3/library/importlib.html#importlib.abc.Traversable), while out pre-commit is running 3.11, so the deprecation won't hit here.

from importlib.abc import Traversable


__all__ = ["Traversable", "TypeAlias", "importlib_metadata"]
24 changes: 14 additions & 10 deletions src/ansible_navigator/utils/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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
2 changes: 1 addition & 1 deletion tests/integration/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading