Skip to content

Commit 1b11890

Browse files
authored
Update ruff to 0.8.0 (#4427)
1 parent c910fee commit 1b11890

18 files changed

+27
-27
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ repos:
130130
types: [file, yaml]
131131
entry: yamllint --strict
132132
- repo: https://github.com/pappasam/toml-sort
133-
rev: v0.23.1
133+
rev: v0.24.2
134134
hooks:
135135
- id: toml-sort-fix
136136
- repo: https://github.com/astral-sh/ruff-pre-commit
137-
rev: v0.7.3
137+
rev: v0.8.0
138138
hooks:
139139
- id: ruff
140140
args:

src/ansiblelint/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def initialize_logger(level: int = 0) -> None:
119119
_logger.debug("Logging initialized to level %s", logging_level)
120120

121121

122-
def initialize_options(arguments: list[str] | None = None) -> None | BaseFileLock:
122+
def initialize_options(arguments: list[str] | None = None) -> BaseFileLock | None:
123123
"""Load config options and store them inside options module."""
124124
cache_dir_lock = None
125125
new_options = cli.get_config(arguments or [])
@@ -377,7 +377,7 @@ def main(argv: list[str] | None = None) -> int:
377377
_logger.debug("Ignored: %s", match)
378378

379379
if app.yamllint_config.incompatible:
380-
logging.log(
380+
_logger.log(
381381
level=logging.ERROR if options.write_list else logging.WARNING,
382382
msg=app.yamllint_config.incompatible,
383383
)

src/ansiblelint/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self, options: Options):
6262
str(self.runtime.version),
6363
): # pragma: no cover
6464
msg = f"ansible-lint requires {package}{','.join(str(x) for x in self.reqs[package])} and current version is {self.runtime.version}"
65-
logging.error(msg)
65+
_logger.error(msg)
6666
sys.exit(RC.INVALID_CONFIG)
6767

6868
# pylint: disable=import-outside-toplevel

src/ansiblelint/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __call__(
135135
values: str | Sequence[Any] | None,
136136
option_string: str | None = None,
137137
) -> None:
138-
logging.debug(option_string)
138+
_logger.debug(option_string)
139139
if isinstance(values, str | Path):
140140
values = [values]
141141
if values:

src/ansiblelint/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def guess_install_method() -> str:
221221
if (distribution(package_name).read_text("INSTALLER") or "").strip() != "pip":
222222
return ""
223223
except PackageNotFoundError as exc:
224-
logging.debug(exc)
224+
_logger.debug(exc)
225225
return ""
226226

227227
pip = ""
@@ -251,16 +251,16 @@ def guess_install_method() -> str:
251251

252252
dist = get_default_environment().get_distribution(package_name)
253253
if dist:
254-
logging.debug("Found %s dist", dist)
254+
_logger.debug("Found %s dist", dist)
255255
for _ in uninstallation_paths(dist):
256256
use_pip = True
257257
else:
258-
logging.debug("Skipping %s as it is not installed.", package_name)
258+
_logger.debug("Skipping %s as it is not installed.", package_name)
259259
use_pip = False
260260
except (AttributeError, ModuleNotFoundError) as exc:
261261
# On Fedora 36, we got a AttributeError exception from pip that we want to avoid
262262
# On NixOS, we got a ModuleNotFoundError exception from pip that we want to avoid
263-
logging.debug(exc)
263+
_logger.debug(exc)
264264
use_pip = False
265265

266266
# We only want to recommend pip for upgrade if it looks safe to do so.

src/ansiblelint/file_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def data(self) -> Any:
440440
self,
441441
)
442442
else:
443-
logging.debug(
443+
_logger.debug(
444444
"data set to None for %s due to being '%s' (%s) kind.",
445445
self.path,
446446
self.kind,

src/ansiblelint/rules/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def _parse_failed_msg(
281281

282282
# testing code to be loaded only with pytest or when executed the rule file
283283
if "pytest" in sys.modules:
284-
import pytest # noqa: TCH002
284+
import pytest # noqa: TC002
285285

286286
from ansiblelint.runner import Runner # pylint: disable=ungrouped-imports
287287

src/ansiblelint/rules/empty_string_compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ComparisonToEmptyStringRule(AnsibleLintRule):
2929
tags = ["idiom", "opt-in"]
3030
version_added = "v4.0.0"
3131

32-
empty_string_compare = re.compile("[=!]= ?(\"{2}|'{2})")
32+
empty_string_compare = re.compile(r"[=!]= ?(\"{2}|'{2})")
3333

3434
def matchtask(
3535
self,

src/ansiblelint/rules/literal_compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ComparisonToLiteralBoolRule(AnsibleLintRule):
2929
tags = ["idiom"]
3030
version_added = "v4.0.0"
3131

32-
literal_bool_compare = re.compile("[=!]= ?(True|true|False|false)")
32+
literal_bool_compare = re.compile(r"[=!]= ?(True|true|False|false)")
3333

3434
def matchtask(
3535
self,

src/ansiblelint/rules/loop_var_prefix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class RoleLoopVarPrefix(AnsibleLintRule):
2929
"""
3030

3131
tags = ["idiom"]
32-
prefix = re.compile("")
32+
prefix = re.compile(r"")
3333
severity = "MEDIUM"
3434
_ids = {
3535
"loop-var-prefix[wrong]": "Loop variable name does not match regex.",

0 commit comments

Comments
 (0)