Skip to content

Commit 7bff09d

Browse files
committed
Adds support for Ansible 11 and Python 3.13
1 parent 022e0f8 commit 7bff09d

19 files changed

+3201
-653
lines changed

.github/workflows/python-pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
11+
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']
1212

1313
steps:
1414
- uses: actions/checkout@v4

.github/workflows/python-tox.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
11+
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']
1212

1313
steps:
1414
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
exclude: '^(.bumpversion.cfg)$'
@@ -18,30 +18,31 @@ repos:
1818
hooks:
1919
- id: nocheckin
2020
exclude: .pre-commit-config.yaml
21-
- repo: https://github.com/PyCQA/flake8
22-
rev: 7.1.1
21+
- repo: https://github.com/astral-sh/ruff-pre-commit
22+
rev: v0.11.13
2323
hooks:
24-
- id: flake8
25-
additional_dependencies:
26-
- flake8-bugbear
27-
files: '^(src/.*|tests/.*)\.py$'
24+
- id: ruff
25+
args: [ "--fix" ]
2826
- repo: https://github.com/PyCQA/bandit
29-
rev: 1.7.9
27+
rev: 1.8.3
3028
hooks:
3129
- id: bandit
3230
args: ["-c", "pyproject.toml", "--quiet"]
3331
additional_dependencies: [ "bandit[toml]" ]
3432
- repo: https://github.com/pre-commit/mirrors-mypy
35-
rev: v1.11.1
33+
rev: v1.16.0
3634
hooks:
3735
- id: mypy
3836
additional_dependencies:
3937
- ansible
4038
- ansible-core
4139
- ansible-base
4240
- mitogen
41+
- port_for
42+
- pytest
43+
- types-paramiko
4344
exclude: '.*'
4445
always_run: true
4546
pass_filenames: false
46-
args: ["src"]
47+
args: ["-p", "suitable", "-p", "tests"]
4748

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Changelog
22
---------
33

4+
- Adds support for Ansible 11 and Python 3.13
5+
[Daverball]
6+
47
0.20.3 (2024-09-04)
58
~~~~~~~~~~~~~~~~~~~
69

pyproject.toml

Lines changed: 143 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ omit = [
1919
]
2020

2121
[tool.bandit]
22-
exclude_dirs = ["tests"]
22+
exclude_dirs = [
23+
"tests",
24+
"src/suitable/_module_types.py",
25+
"src/suitable/_modules.py",
26+
]
2327
skips = ["B101"]
2428

2529
[tool.mypy]
@@ -34,6 +38,123 @@ mypy_path = "$MYPY_CONFIG_FILE_DIR/src"
3438
module = ["suitable._module_types"]
3539
warn_return_any = false
3640

41+
[tool.ruff]
42+
exclude = [
43+
".bzr",
44+
".direnv",
45+
".eggs",
46+
".git",
47+
".git-rewrite",
48+
".hg",
49+
".ipynb_checkpoints",
50+
".mypy_cache",
51+
".nox",
52+
".pants.d",
53+
".pyenv",
54+
".pytest_cache",
55+
".pytype",
56+
".ruff_cache",
57+
".svn",
58+
".tox",
59+
".venv",
60+
".vscode",
61+
"__pypackages__",
62+
"_build",
63+
"buck-out",
64+
"build",
65+
"dist",
66+
"node_modules",
67+
"site-packages",
68+
"venv",
69+
]
70+
src = ["scripts", "src", "test"]
71+
include = [
72+
"pyproject.toml",
73+
"scripts/**/*.py",
74+
"src/**/*.py",
75+
"tests/**/*.py",
76+
]
77+
line-length = 80
78+
indent-width = 4
79+
target-version = "py38"
80+
81+
[tool.ruff.lint]
82+
select = [
83+
"A005",
84+
"ASYNC",
85+
"B0",
86+
"B904",
87+
"B909",
88+
"C4",
89+
"COM818",
90+
"E",
91+
"F",
92+
"FLY002",
93+
"FURB",
94+
"G010",
95+
"G2",
96+
"I002",
97+
"ISC",
98+
"LOG",
99+
"N",
100+
"PERF",
101+
"PGH004",
102+
"PGH005",
103+
"PIE",
104+
"PYI",
105+
"Q",
106+
"RUF",
107+
"SIM",
108+
"SLOT",
109+
"T",
110+
"UP",
111+
"W",
112+
]
113+
ignore = [
114+
"FURB103",
115+
"SIM105",
116+
"SIM118",
117+
]
118+
unfixable = []
119+
preview = true
120+
121+
[tool.ruff.lint.extend-per-file-ignores]
122+
"scripts/**/*.py" = [
123+
"T",
124+
]
125+
"tests/**/*.py" = [
126+
"RUF012",
127+
"SIM108",
128+
]
129+
"src/suitable/_module*s.py" = [
130+
"PYI041",
131+
"RUF100",
132+
]
133+
134+
[tool.ruff.lint.isort]
135+
required-imports = ["from __future__ import annotations"]
136+
137+
[tool.ruff.lint.pep8-naming]
138+
extend-ignore-names = []
139+
classmethod-decorators = []
140+
141+
[tool.ruff.lint.flake8-quotes]
142+
avoid-escape = true
143+
docstring-quotes = "double"
144+
inline-quotes = "single"
145+
multiline-quotes = "double"
146+
147+
[tool.ruff.lint.pyupgrade]
148+
keep-runtime-typing = true
149+
150+
[tool.ruff.format]
151+
quote-style = "single"
152+
indent-style = "space"
153+
skip-magic-trailing-comma = false
154+
line-ending = "lf"
155+
docstring-code-format = true
156+
docstring-code-line-length = "dynamic"
157+
37158
[tool.bumpversion]
38159
current_version = "0.20.3"
39160
commit = true
@@ -70,7 +191,8 @@ envlist =
70191
py{39,310,311}-ansible8
71192
py{310,311,312}-ansible9
72193
py{310,311,312}-ansible10
73-
flake8
194+
py{311,312,313}-ansible11
195+
ruff
74196
bandit
75197
mypy
76198
report
@@ -79,14 +201,15 @@ envlist =
79201
python =
80202
3.8: py38
81203
3.9: py39
82-
3.10: py310,flake8,bandit,mypy
83-
3.11: py311
204+
3.10: py310
205+
3.11: py311,ruff,bandit,mypy
84206
3.12: py312
207+
3.13: py313
85208
86209
[testenv]
87210
usedevelop = true
88211
setenv =
89-
py{38,39,310,311,312}: COVERAGE_FILE = .coverage.{envname}
212+
py{38,39,310,311,312,313}: COVERAGE_FILE = .coverage.{envname}
90213
deps =
91214
-e{toxinidir}[tests]
92215
ansible6: ansible==6.*
@@ -99,38 +222,41 @@ deps =
99222
ansible9: ansible-core==2.16.*
100223
ansible10: ansible==10.*
101224
ansible10: ansible-core==2.17.*
225+
ansible11: ansible==11.*
226+
ansible11: ansible-core==2.18.*
102227
103228
commands = pytest --cov --cov-report= {posargs}
104229
105230
passenv = *
106231
107-
[testenv:flake8]
108-
basepython = python3.10
232+
[testenv:ruff]
233+
basepython = python3.11
109234
skip_install = true
110235
deps =
111-
flake8
112-
flake8-bugbear
113-
commands = flake8 src/ tests/
236+
ruff
237+
commands = ruff check
114238
115239
[testenv:bandit]
116-
basepython = python3.10
240+
basepython = python3.11
117241
skip_install = true
118242
deps =
119243
bandit[toml]
120244
commands = bandit -q -c pyproject.toml -r src
121245
122246
[testenv:mypy]
123-
basepython = python3.10
247+
basepython = python3.11
124248
deps =
125249
-e{toxinidir}
126250
mypy
127251
mitogen
252+
types-paramiko
128253
commands =
129-
mypy -p suitable --python-version 3.8
130-
mypy -p suitable --python-version 3.9
131-
mypy -p suitable --python-version 3.10
132-
mypy -p suitable --python-version 3.11
133-
mypy -p suitable --python-version 3.12
254+
mypy -p suitable -p tests --python-version 3.8
255+
mypy -p suitable -p tests --python-version 3.9
256+
mypy -p suitable -p tests --python-version 3.10
257+
mypy -p suitable -p tests --python-version 3.11
258+
mypy -p suitable -p tests --python-version 3.12
259+
mypy -p suitable -p tests --python-version 3.13
134260
135261
[testenv:report]
136262
deps =

scripts/generate_module_hints.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
import re
1212

13-
from ansible import constants as C # type:ignore
13+
from ansible import constants as C # type:ignore # noqa: N812
1414
from ansible.plugins.loader import fragment_loader # type:ignore
1515
from ansible.plugins.loader import init_plugin_loader
1616
from ansible.plugins.loader import module_loader
@@ -87,7 +87,7 @@ def write_function_parameter_list(
8787
and (default := meta['default']) is not None
8888
):
8989
if type_name == 'bool':
90-
default = True if default in ('yes', True) else False
90+
default = default in ('yes', True)
9191

9292
default_type = type(default).__name__
9393
if default_type == 'AnsibleUnicode':
@@ -435,7 +435,7 @@ def write_return_type(returns: dict[str, Any] | None) -> None:
435435
condition = prepare_docstring_line(
436436
meta.get('returned', 'unspecified')
437437
)
438-
if condition.startswith('When') or condition.startswith('when'):
438+
if condition.startswith(('When', 'when')):
439439
condition = condition[5:]
440440
types_py.write('\n')
441441
for line in split_docstring_lines(f'Returned when: {condition}'):
@@ -455,7 +455,7 @@ def write_return_type(returns: dict[str, Any] | None) -> None:
455455
else:
456456
types_py.write(' """\n')
457457
types_py.write(
458-
f' return self.acquire(server, \'{name}\')\n'
458+
f" return self.acquire(server, '{name}')\n"
459459
)
460460

461461

@@ -507,7 +507,7 @@ def write_return_type(returns: dict[str, Any] | None) -> None:
507507
conflicts.append(collection)
508508

509509

510-
modules_header_py.write('''\
510+
modules_header_py.write("""\
511511
# This is an auto-generated file. Please don't manually edit.
512512
# Instead call `scripts/generate_module_hints.py`
513513
@@ -519,8 +519,8 @@ def write_return_type(returns: dict[str, Any] | None) -> None:
519519
from _typeshed import StrPath
520520
from collections.abc import Mapping, Sequence
521521
from suitable._module_types import (
522-
''')
523-
modules_py.write('''\
522+
""")
523+
modules_py.write("""\
524524
)
525525
from suitable.types import Incomplete
526526
@@ -531,8 +531,8 @@ def write_return_type(returns: dict[str, Any] | None) -> None:
531531
532532
533533
class AnsibleModules:
534-
''')
535-
types_py.write('''\
534+
""")
535+
types_py.write("""\
536536
# This is an auto-generated file. Please don't manually edit.
537537
# Instead call `scripts/generate_module_hints.py`
538538
@@ -547,7 +547,7 @@ class AnsibleModules:
547547
else:
548548
def type_check_only(f):
549549
return f
550-
''')
550+
""")
551551
current_collection = ''
552552
version_hint_above: tuple[int, ...]
553553
for module_name, (collection, docs, returns) in sorted(

0 commit comments

Comments
 (0)