Skip to content

Commit 4b36ffa

Browse files
Apply Python 3.10 code changes (#4012)
1 parent 1543d4c commit 4b36ffa

File tree

133 files changed

+188
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+188
-85
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ repos:
141141
- id: ruff
142142
args: [--fix, --exit-non-zero-on-fix]
143143
- repo: https://github.com/psf/black
144-
rev: 23.12.1
144+
rev: 24.1.1
145145
hooks:
146146
- id: black
147147
language_version: python3

conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""PyTest Fixtures."""
2+
23
import importlib
34
import os
45
import platform

examples/.collection/plugins/modules/alpha.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""An ansible test module."""
22

3-
43
DOCUMENTATION = """
54
module: mod_1
65
author:

examples/.collection/plugins/modules/deep/beta.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""An ansible test module."""
22

3-
43
DOCUMENTATION = """
54
module: mod_2
65
author:

examples/rules/task_has_tag.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Example implementation of a rule requiring tasks to have tags set."""
2+
23
from __future__ import annotations
34

45
from typing import TYPE_CHECKING

plugins/modules/fake_module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
This is used to test ability to detect and use custom modules.
44
"""
5+
56
from ansible.module_utils.basic import AnsibleModule
67

78
EXAMPLES = r"""

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ repository = "https://github.com/ansible/ansible-lint"
4848
changelog = "https://github.com/ansible/ansible-lint/releases"
4949

5050
[tool.black]
51-
target-version = ["py39"]
51+
target-version = ["py310"]
5252

5353
[tool.codespell]
5454
skip = ".tox,.mypy_cache,build,.git,.eggs,pip-wheel-metadata"
@@ -251,7 +251,7 @@ ignore = [
251251
"PD011" # We are not using pandas, any .values attributes are unrelated
252252
]
253253
select = ["ALL"]
254-
target-version = "py39"
254+
target-version = "py310"
255255
# Same as Black.
256256
line-length = 88
257257

src/ansiblelint/__main__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import site
3131
import sys
3232
from pathlib import Path
33-
from typing import TYPE_CHECKING, Any, Callable, TextIO
33+
from typing import TYPE_CHECKING, Any, TextIO
3434

3535
from ansible_compat.prerun import get_cache_dir
3636
from filelock import FileLock, Timeout
@@ -72,6 +72,8 @@
7272
if TYPE_CHECKING:
7373
# RulesCollection must be imported lazily or ansible gets imported too early.
7474

75+
from collections.abc import Callable
76+
7577
from ansiblelint.rules import RulesCollection
7678
from ansiblelint.runner import LintResult
7779

@@ -205,12 +207,6 @@ def _do_transform(result: LintResult, opts: Options) -> None:
205207

206208
def support_banner() -> None:
207209
"""Display support banner when running on unsupported platform."""
208-
if sys.version_info < (3, 10, 0): # pragma: no cover
209-
prefix = "::warning::" if "GITHUB_ACTION" in os.environ else "WARNING: "
210-
console_stderr.print(
211-
f"{prefix}ansible-lint is no longer tested under Python {sys.version_info.major}.{sys.version_info.minor} and will soon require 3.10. Do not report bugs for this version.",
212-
style="bold red",
213-
)
214210

215211

216212
def fix(runtime_options: Options, result: LintResult, rules: RulesCollection) -> None:

src/ansiblelint/_internal/rules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Internally used rule classes."""
2+
23
from __future__ import annotations
34

45
import inspect

src/ansiblelint/_mockings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Utilities for mocking ansible modules and roles."""
2+
23
from __future__ import annotations
34

45
import contextlib

0 commit comments

Comments
 (0)