Skip to content

Commit ac7bc03

Browse files
committed
1 parent a2a9176 commit ac7bc03

File tree

11 files changed

+42
-98
lines changed

11 files changed

+42
-98
lines changed

.config/requirements.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html
2-
ansible-core>=2.14
2+
ansible-core>=2.16
33
packaging
44
PyYAML
55
subprocess-tee>=0.4.1
66
jsonschema>=4.6.0
7-
typing-extensions>=4.5.0;python_version<'3.10'

.github/workflows/tox.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ jobs:
2525
docs
2626
lint
2727
pkg
28-
py39-ansible214
29-
py39-ansible215
30-
py310-ansible215
3128
py310-ansible217
32-
py311-ansible215
3329
py312-ansible216
3430
py312-ansible217
3531
py312-devel

.readthedocs.yml

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,25 @@
1-
# Read the Docs configuration file
2-
# See https://docs.readthedocs.io/en/stable/config-file/v2.html
3-
# for details
4-
51
---
6-
# Required
72
version: 2
83

9-
# Build documentation in the docs/ directory with Sphinx
10-
sphinx:
11-
# keep dirhtml for nice URLs without .html extension
12-
builder: dirhtml
13-
configuration: docs/conf.py
4+
mkdocs:
145
fail_on_warning: true
15-
16-
# Build documentation with MkDocs
17-
#mkdocs:
18-
# configuration: mkdocs.yml
19-
# fail_on_warning: true
20-
21-
# Optionally build your docs in additional formats
22-
# such as PDF and ePub
23-
formats: []
24-
25-
submodules:
26-
include: all # []
27-
exclude: []
28-
recursive: true
6+
configuration: mkdocs.yml
297

308
build:
31-
image: latest
32-
33-
# Optionally set the version of Python and requirements required
34-
# to build docs
9+
os: ubuntu-24.04
10+
tools:
11+
python: "3.11"
12+
commands:
13+
- pip install --user tox
14+
- python3 -m tox -e docs
3515
python:
36-
version: "3.9"
3716
install:
38-
# On https://readthedocs.org/dashboard/ansible-lint/environmentvariables/ we
39-
# do have PIP_CONSTRAINTS=.config/constraints.txt which ensures we install only
40-
# pinned requirements that that we know to be working.
17+
- method: pip
18+
path: tox
4119
- method: pip
4220
path: .
4321
extra_requirements:
4422
- docs
45-
system_packages: false
23+
submodules:
24+
include: all
25+
recursive: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![codecov.io](https://codecov.io/github/ansible/ansible-compat/coverage.svg?branch=main)](https://codecov.io/github/ansible/ansible-compat?branch=main)
77

88
A python package contains functions that facilitate working with various
9-
versions of Ansible 2.14 and newer.
9+
versions of Ansible.
1010

1111
## Documentation
1212

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ classifiers = [
1616
"License :: OSI Approved :: MIT License",
1717
"Operating System :: OS Independent",
1818
"Programming Language :: Python :: 3",
19-
"Programming Language :: Python :: 3.9",
2019
"Programming Language :: Python :: 3.10",
2120
"Programming Language :: Python :: 3.11",
2221
"Programming Language :: Python :: 3.12",
@@ -36,7 +35,7 @@ maintainers = [{"email" = "ssbarnea@redhat.com", "name" = "Sorin Sbarnea"}]
3635
name = "ansible-compat"
3736
readme = "README.md"
3837
# https://peps.python.org/pep-0621/#readme
39-
requires-python = ">=3.9"
38+
requires-python = ">=3.10"
4039

4140
[project.urls]
4241
changelog = "https://github.com/ansible/ansible-compat/releases"
@@ -72,7 +71,7 @@ error_summary = true
7271
# warn_return_any = True
7372
# warn_unused_configs = True
7473
exclude = "test/local-content"
75-
python_version = "3.9"
74+
python_version = "3.10"
7675

7776
[[tool.mypy.overrides]]
7877
ignore_missing_imports = true
@@ -364,7 +363,7 @@ testpaths = ["test"]
364363
[tool.ruff]
365364
extend-include = ["src/ansible_compat/_version.py"]
366365
preview = true
367-
target-version = "py39"
366+
target-version = "py310"
368367

369368
[tool.ruff.format]
370369
docstring-code-format = true

src/ansible_compat/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
]
1515

1616
# Minimal version of Ansible we support for runtime
17-
ANSIBLE_MIN_VERSION = "2.14"
17+
ANSIBLE_MIN_VERSION = "2.16"
1818

1919
# Based on https://docs.ansible.com/ansible/latest/reference_appendices/config.html
2020
ANSIBLE_DEFAULT_ROLES_PATH = (

src/ansible_compat/runtime.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from collections import OrderedDict
1818
from dataclasses import dataclass, field
1919
from pathlib import Path
20-
from typing import TYPE_CHECKING, Any, Callable, no_type_check
20+
from typing import TYPE_CHECKING, Any, no_type_check
2121

2222
import subprocess_tee
2323
from packaging.version import Version
@@ -46,6 +46,7 @@
4646
# https://github.com/PyCQA/pylint/issues/3240
4747
# pylint: disable=unsubscriptable-object
4848
CompletedProcess = subprocess.CompletedProcess[Any]
49+
from collections.abc import Callable
4950
else:
5051
CompletedProcess = subprocess.CompletedProcess
5152

@@ -337,7 +338,7 @@ def _ensure_module_available(self) -> None:
337338
msg = f"Ansible CLI ({self.version}) and python module ({ansible_module_version}) versions do not match. This indicates a broken execution environment."
338339
raise RuntimeError(msg)
339340

340-
# For ansible 2.15+ we need to initialize the plugin loader
341+
# We need to initialize the plugin loader
341342
# https://github.com/ansible/ansible-lint/issues/2945
342343
if not Runtime.initialized:
343344
col_path = [f"{self.cache_dir}/collections"]
@@ -346,24 +347,15 @@ def _ensure_module_available(self) -> None:
346347
_AnsibleCollectionFinder, # noqa: PLC2701
347348
)
348349

349-
if self.version >= Version("2.15.0.dev0"):
350-
# pylint: disable=import-outside-toplevel,no-name-in-module
351-
from ansible.plugins.loader import init_plugin_loader
352-
353-
_AnsibleCollectionFinder( # noqa: SLF001
354-
paths=col_path,
355-
)._remove() # pylint: disable=protected-access
356-
init_plugin_loader(col_path)
357-
else:
358-
# noinspection PyProtectedMember
359-
# pylint: disable=protected-access
360-
col_path += self.config.collections_paths
361-
col_path += os.path.dirname( # noqa: PTH120
362-
os.environ.get(ansible_collections_path(), "."),
363-
).split(":")
364-
_AnsibleCollectionFinder( # noqa: SLF001
365-
paths=col_path,
366-
)._install() # pylint: disable=protected-access
350+
# noinspection PyProtectedMember
351+
# pylint: disable=protected-access
352+
col_path += self.config.collections_paths
353+
col_path += os.path.dirname( # noqa: PTH120
354+
os.environ.get(ansible_collections_path(), "."),
355+
).split(":")
356+
_AnsibleCollectionFinder( # noqa: SLF001
357+
paths=col_path,
358+
)._install() # pylint: disable=protected-access
367359
Runtime.initialized = True
368360

369361
def clean(self) -> None:
@@ -559,7 +551,7 @@ def install_requirements( # noqa: C901
559551
if not Path(requirement).exists():
560552
return
561553
reqs_yaml = yaml_from_file(Path(requirement))
562-
if not isinstance(reqs_yaml, (dict, list)):
554+
if not isinstance(reqs_yaml, dict | list):
563555
msg = f"{requirement} file is not a valid Ansible requirements file."
564556
raise InvalidPrerequisiteError(msg)
565557

src/ansible_compat/types.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,11 @@
33
from __future__ import annotations
44

55
from collections.abc import Mapping, Sequence
6-
from typing import Union
6+
from typing import TypeAlias
77

8-
try: # py39 does not have TypeAlias
9-
from typing_extensions import TypeAlias
10-
except ImportError:
11-
from typing import TypeAlias # type: ignore[no-redef,attr-defined]
12-
13-
JSON: TypeAlias = Union[dict[str, "JSON"], list["JSON"], str, int, float, bool, None]
14-
JSON_ro: TypeAlias = Union[
15-
Mapping[str, "JSON_ro"],
16-
Sequence["JSON_ro"],
17-
str,
18-
int,
19-
float,
20-
bool,
21-
None,
22-
]
8+
JSON: TypeAlias = dict[str, "JSON"] | list["JSON"] | str | int | float | bool | None
9+
JSON_ro: TypeAlias = (
10+
Mapping[str, "JSON_ro"] | Sequence["JSON_ro"] | str | int | float | bool | None
11+
)
2312

2413
__all__ = ["JSON", "JSON_ro"]

test/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import pathlib
66
import subprocess
77
import sys
8-
from collections.abc import Generator
8+
from collections.abc import Callable, Generator
99
from pathlib import Path
10-
from typing import Callable
1110

1211
import pytest
1312

test/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_config() -> None:
2424
assert isinstance(config.CONNECTION_FACTS_MODULES, dict)
2525
assert config.ANSIBLE_COW_PATH is None
2626
assert isinstance(config.NETWORK_GROUP_MODULES, list)
27-
assert isinstance(config.DEFAULT_FORKS, (int, type(None)))
27+
assert isinstance(config.DEFAULT_FORKS, int | type(None))
2828

2929
# check lowercase and older name aliasing
3030
assert isinstance(config.collections_paths, list)

tox.ini

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@ envlist =
66
docs
77
py
88
py-devel
9-
py39-ansible214
10-
py39-ansible215
11-
py310-ansible214
12-
py310-ansible215
139
py310-ansible216
1410
py310-ansible217
15-
py311-ansible214
16-
py311-ansible215
1711
py311-ansible216
1812
py311-ansible217
1913
py312-ansible216
@@ -31,14 +25,10 @@ requires =
3125
description =
3226
Run the tests
3327
devel: ansible devel branch
34-
ansible214: ansible-core 2.14
35-
ansible215: ansible-core 2.15
3628
ansible216: ansible-core 2.16
3729
ansible217: ansible-core 2.17
3830

3931
deps =
40-
ansible214: ansible-core>=2.14,<2.15
41-
ansible215: ansible-core>=2.15,<2.16
4232
ansible216: ansible-core>=2.16,<2.17
4333
ansible217: ansible-core>=2.17,<2.18
4434

@@ -60,7 +50,7 @@ commands =
6050
# pytest users to run coverage when they just want to run a single test with `pytest -k test`
6151
coverage run -m pytest {posargs:}
6252
# needed for upload to codecov.io
63-
{py,py39,py310,py311,py312,py313}: sh -c "coverage combine -q --data-file={envdir}/.coverage {envdir}/.coverage.* && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --ignore-errors --fail-under=0 && COVERAGE_FILE={envdir}/.coverage coverage lcov --fail-under=0 --ignore-errors -q && COVERAGE_FILE={envdir}/.coverage coverage report --fail-under=0 --ignore-errors"
53+
{py,py310,py311,py312,py313}: sh -c "coverage combine -q --data-file={envdir}/.coverage {envdir}/.coverage.* && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --ignore-errors --fail-under=0 && COVERAGE_FILE={envdir}/.coverage coverage lcov --fail-under=0 --ignore-errors -q && COVERAGE_FILE={envdir}/.coverage coverage report --fail-under=0 --ignore-errors"
6454
# lcov needed for vscode integration due to https://github.com/ryanluker/vscode-coverage-gutters/issues/403
6555

6656
passenv =
@@ -153,10 +143,10 @@ commands =
153143
pip uninstall -y ansible-compat
154144

155145
[testenv:py]
156-
description = Run the tests with {basepython} ansible-core 2.14+
146+
description = Run the tests with {basepython} ansible-core 2.16+
157147
deps =
158148
{[testenv]deps}
159-
ansible-core>=2.14
149+
ansible-core>=2.16
160150

161151
[testenv:rpm]
162152
description = Use packit to build RPM (requires RPM based Linux distro)

0 commit comments

Comments
 (0)