Skip to content

Commit 3c6d3b8

Browse files
committed
chore: update linters
Needed-By: #2037
1 parent 7288de0 commit 3c6d3b8

File tree

6 files changed

+39
-51
lines changed

6 files changed

+39
-51
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude: >
1515
)$
1616
repos:
1717
- repo: https://github.com/renovatebot/pre-commit-hooks
18-
rev: 41.99.7
18+
rev: 41.109.0
1919
hooks:
2020
- id: renovate-config-validator
2121
alias: renovate
@@ -44,39 +44,11 @@ repos:
4444
additional_dependencies:
4545
- prettier
4646
- prettier-plugin-toml
47-
48-
- repo: https://github.com/pappasam/toml-sort
49-
rev: v0.24.3
50-
hooks:
51-
- id: toml-sort-fix
52-
53-
- repo: https://github.com/tox-dev/tox-ini-fmt
54-
rev: 1.6.0
55-
hooks:
56-
- id: tox-ini-fmt
57-
58-
- repo: https://github.com/astral-sh/ruff-pre-commit
59-
rev: "v0.12.12"
60-
hooks:
61-
- id: ruff
62-
entry: sh -c 'ruff check --fix --force-exclude && ruff format --force-exclude'
63-
types_or: [python, pyi]
64-
6547
- repo: https://github.com/streetsidesoftware/cspell-cli
6648
rev: v9.2.0
6749
hooks:
6850
- id: cspell
6951
name: Spell check with cspell
70-
71-
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
72-
rev: v1.5.5
73-
hooks:
74-
- id: remove-tabs
75-
exclude: >
76-
(?x)^(
77-
.config/pylint-baseline.txt
78-
)$
79-
8052
- repo: https://github.com/pre-commit/pre-commit-hooks.git
8153
rev: v6.0.0
8254
hooks:
@@ -157,6 +129,11 @@ repos:
157129
additional_dependencies:
158130
- flake8-docstrings # uses pydocstyle
159131

132+
- repo: https://github.com/pappasam/toml-sort
133+
rev: v0.24.3
134+
hooks:
135+
- id: toml-sort-fix
136+
alias: toml
160137
- repo: https://github.com/jsh9/pydoclint
161138
rev: 0.7.3
162139
hooks:
@@ -168,8 +145,15 @@ repos:
168145
hooks:
169146
- id: pyupgrade
170147
args: ["--py310-plus"]
148+
- repo: https://github.com/astral-sh/ruff-pre-commit
149+
rev: v0.13.0
150+
hooks:
151+
- id: ruff-format
152+
alias: ruff
153+
- id: ruff-check
154+
alias: ruff
171155
- repo: https://github.com/pre-commit/mirrors-mypy.git
172-
rev: v1.17.1
156+
rev: v1.18.1
173157
hooks:
174158
- id: mypy
175159
additional_dependencies:

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ authors = [{"email" = "[email protected]", "name" = "Bradley A. Thornton"}]
1212
classifiers = [
1313
'Development Status :: 5 - Production/Stable',
1414
'Intended Audience :: Developers',
15-
'License :: OSI Approved :: Apache Software License',
1615
'Operating System :: OS Independent',
1716
'Topic :: Software Development :: Testing',
1817
'Topic :: Software Development :: Quality Assurance',
@@ -30,7 +29,7 @@ classifiers = [
3029
description = "A text-based user interface (TUI) for the Red Hat Ansible Automation Platform"
3130
dynamic = ["version", "dependencies", "optional-dependencies"]
3231
keywords = ["ansible"]
33-
license = {text = "Apache"}
32+
license = "Apache-2.0"
3433
maintainers = [{"email" = "[email protected]", "name" = "Ansible by Red Hat"}]
3534
name = "ansible-navigator"
3635
readme = "README.md"
@@ -51,7 +50,7 @@ repository = "https://github.com/ansible/ansible-navigator"
5150
source = ["src", ".tox/*/site-packages"]
5251

5352
[tool.coverage.report]
54-
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]
53+
exclude_also = ["pragma: no cover", "if TYPE_CHECKING:"]
5554
show_missing = true
5655
skip_covered = true
5756

@@ -69,6 +68,7 @@ disallow_any_generics = true
6968
# disallow_untyped_calls = true
7069
disallow_untyped_defs = true
7170
error_summary = true
71+
exclude_gitignore = true
7272
incremental = false
7373
python_version = "3.10"
7474

@@ -359,7 +359,7 @@ filterwarnings = [
359359
"ignore::pytest.PytestUnraisableExceptionWarning",
360360
"ignore::DeprecationWarning:ansible_runner"
361361
]
362-
junit_family = "legacy" # see https://docs.codecov.com/docs/test-analytics
362+
junit_family = "xunit2" # see https://docs.codecov.com/docs/test-analytics
363363

364364
[tool.pytest_env]
365365
PYTEST_CHECK_TEST_DUPLICATE = 0
@@ -442,7 +442,7 @@ optional-dependencies.test = {file = [".config/requirements-test.in"]}
442442

443443
[tool.setuptools_scm]
444444
local_scheme = "no-local-version"
445-
write_to = "src/ansible_navigator/_version.py"
445+
version_file = "src/ansible_navigator/_version.py"
446446

447447
[tool.tomlsort]
448448
in_place = true

src/ansible_navigator/tm_tokenize/fchainmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
TValue_co = TypeVar("TValue_co", covariant=True)
99

1010

11-
class Indexable(Generic[TKey_contra, TValue_co], Protocol):
11+
class Indexable(Generic[TKey_contra, TValue_co], Protocol): # noqa: PYI059
1212
def __getitem__(self, key: TKey_contra) -> TValue_co:
1313
"""Get the value associated with the given key.
1414
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
"""Conditional imports related to python versions."""
22

33
import importlib.metadata as importlib_metadata
4-
import sys
54

65

76
# https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
87
from typing import TypeAlias
98

109

11-
if sys.version_info < (3, 11):
12-
from importlib.abc import Traversable
13-
else:
10+
try:
1411
from importlib.resources.abc import Traversable
12+
except ImportError:
13+
# pylint: disable-next=deprecated-class
14+
from importlib.abc import Traversable
1515

1616

1717
__all__ = ["Traversable", "TypeAlias", "importlib_metadata"]

src/ansible_navigator/utils/json_schema.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717

1818
if TYPE_CHECKING:
19-
from collections import deque
19+
from collections.abc import Sequence
2020

2121

22-
def to_path(schema_path: deque[Any]) -> str:
22+
def to_path(schema_path: Sequence[Any]) -> str:
2323
"""Flatten a path to a dot delimited string.
2424
2525
Args:
@@ -31,7 +31,7 @@ def to_path(schema_path: deque[Any]) -> str:
3131
return ".".join(str(index) for index in schema_path)
3232

3333

34-
def json_path(absolute_path: deque[Any]) -> str:
34+
def json_path(absolute_path: Sequence[Any]) -> str:
3535
"""Flatten a data path to a dot delimited string.
3636
3737
Args:
@@ -97,7 +97,7 @@ def validate(schema: str | dict[str, Any], data: dict[str, Any]) -> list[JsonSch
9797

9898
if isinstance(schema, str):
9999
schema = json.loads(schema)
100-
if isinstance(schema, bool):
100+
if isinstance(schema, (bool, str)):
101101
msg = "Unexpected schema data."
102102
raise TypeError(msg)
103103
validator = validator_for(schema)
@@ -124,15 +124,19 @@ def validate(schema: str | dict[str, Any], data: dict[str, Any]) -> list[JsonSch
124124

125125
for validation_error in validation_errors:
126126
if isinstance(validation_error, ValidationError):
127+
if isinstance(validation_error.absolute_path, bool):
128+
path = str(validation_error.absolute_path)
129+
else:
130+
path = to_path(validation_error.absolute_path)
127131
error = JsonSchemaError(
128132
message=validation_error.message,
129-
data_path=to_path(validation_error.absolute_path),
130-
json_path=json_path(validation_error.absolute_path),
133+
data_path=path,
134+
json_path=path,
131135
schema_path=to_path(validation_error.relative_schema_path),
132-
relative_schema=validation_error.schema,
133-
expected=validation_error.validator_value,
134-
validator=validation_error.validator,
135-
found=validation_error.instance,
136+
relative_schema=str(validation_error.schema),
137+
expected=str(validation_error.validator_value),
138+
validator=str(validation_error.validator),
139+
found=str(validation_error.instance),
136140
)
137141
errors.append(error)
138142
return errors

tests/integration/_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def copytree(
248248
try:
249249
if symlinks and source_path.is_symlink():
250250
source_link = source_path.readlink()
251-
os.symlink(source_link, destination_path)
251+
source_link.symlink_to(destination_path)
252252
elif source_path.is_dir():
253253
copytree(
254254
source_path,

0 commit comments

Comments
 (0)