From a3fc7e4def4c3576a221fd1e0e58c0ee43f73af5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:53:05 +0530 Subject: [PATCH] chore: pre-commit autoupdate (#4010) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Cristiano Nicolai <570894+cristianonicolai@users.noreply.github.com> Co-authored-by: Ajinkya Udgirkar --- .pre-commit-config.yaml | 4 ++-- src/ansiblelint/formatters/__init__.py | 1 + src/ansiblelint/rules/__init__.py | 4 ++-- src/ansiblelint/rules/galaxy.py | 4 ++-- src/ansiblelint/rules/no_prompting.py | 2 +- src/ansiblelint/rules/run_once.py | 2 +- src/ansiblelint/skip_utils.py | 2 +- src/ansiblelint/utils.py | 4 ++-- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f74ddbab6..b2bed91213 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -76,7 +76,7 @@ repos: args: [--relative, --no-progress, --no-summary] name: Spell check with cspell - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.27.3 + rev: 0.27.4 hooks: - id: check-github-workflows - repo: https://github.com/pre-commit/pre-commit-hooks.git @@ -136,7 +136,7 @@ repos: types: [file, yaml] entry: yamllint --strict - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.13" + rev: "v0.2.0" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/src/ansiblelint/formatters/__init__.py b/src/ansiblelint/formatters/__init__.py index e40d03c7d4..3a70a8c932 100644 --- a/src/ansiblelint/formatters/__init__.py +++ b/src/ansiblelint/formatters/__init__.py @@ -29,6 +29,7 @@ class BaseFormatter(Generic[T]): ---- base_dir (str|Path): reference directory against which display relative path. display_relative_path (bool): whether to show path as relative or absolute + """ def __init__(self, base_dir: str | Path, display_relative_path: bool) -> None: diff --git a/src/ansiblelint/rules/__init__.py b/src/ansiblelint/rules/__init__.py index 9dde56cd63..33db26e208 100644 --- a/src/ansiblelint/rules/__init__.py +++ b/src/ansiblelint/rules/__init__.py @@ -93,7 +93,7 @@ def create_matcherror( match_type: str | None = None while not match_type and frame is not None: func_name = frame.f_code.co_name - match_type = match_types.get(func_name, None) + match_type = match_types.get(func_name) if match_type: # add the match_type to the match match.match_type = match_type @@ -558,7 +558,7 @@ def list_tags(self) -> str: tags[tag] = list(rule.ids()) result = "# List of tags and rules they cover\n" for tag in sorted(tags): - desc = tag_desc.get(tag, None) + desc = tag_desc.get(tag) if desc: result += f"{tag}: # {desc}\n" else: diff --git a/src/ansiblelint/rules/galaxy.py b/src/ansiblelint/rules/galaxy.py index 28f35437ae..a313843e82 100644 --- a/src/ansiblelint/rules/galaxy.py +++ b/src/ansiblelint/rules/galaxy.py @@ -64,8 +64,8 @@ def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]: for path in changelog_paths: if path.is_file(): changelog_found = 1 - galaxy_tag_list = data.get("tags", None) - collection_deps = data.get("dependencies", None) + galaxy_tag_list = data.get("tags") + collection_deps = data.get("dependencies") if collection_deps: for dep, ver in collection_deps.items(): if ( diff --git a/src/ansiblelint/rules/no_prompting.py b/src/ansiblelint/rules/no_prompting.py index 476dd142f9..c5d11d838c 100644 --- a/src/ansiblelint/rules/no_prompting.py +++ b/src/ansiblelint/rules/no_prompting.py @@ -34,7 +34,7 @@ def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]: if file.kind != "playbook": # pragma: no cover return [] - vars_prompt = data.get("vars_prompt", None) + vars_prompt = data.get("vars_prompt") if not vars_prompt: return [] return [ diff --git a/src/ansiblelint/rules/run_once.py b/src/ansiblelint/rules/run_once.py index 70315fe926..d656711858 100644 --- a/src/ansiblelint/rules/run_once.py +++ b/src/ansiblelint/rules/run_once.py @@ -35,7 +35,7 @@ def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]: if not file or file.kind != "playbook" or not data: return [] - strategy = data.get("strategy", None) + strategy = data.get("strategy") run_once = data.get("run_once", False) if (not strategy and not run_once) or strategy != "free": return [] diff --git a/src/ansiblelint/skip_utils.py b/src/ansiblelint/skip_utils.py index 1c43ebce86..afce58b5ea 100644 --- a/src/ansiblelint/skip_utils.py +++ b/src/ansiblelint/skip_utils.py @@ -240,7 +240,7 @@ def get_nested_tasks(task: Any) -> Generator[Any, None, None]: if not task or not is_nested_task(task): return for k in NESTED_TASK_KEYS: - if k in task and task[k]: + if task.get(k): if hasattr(task[k], "get"): continue for subtask in task[k]: diff --git a/src/ansiblelint/utils.py b/src/ansiblelint/utils.py index 078bc5cc92..77d2517839 100644 --- a/src/ansiblelint/utils.py +++ b/src/ansiblelint/utils.py @@ -28,7 +28,7 @@ import logging import os import re -from collections.abc import Generator, ItemsView, Iterator, Mapping, Sequence +from collections.abc import ItemsView, Iterator, Mapping, Sequence from dataclasses import _MISSING_TYPE, dataclass, field from functools import cache, lru_cache from pathlib import Path @@ -774,7 +774,7 @@ def __getitem__(self, index: str) -> Any: """Allow access as task[...].""" return self.normalized_task[index] - def __iter__(self) -> Generator[str, None, None]: + def __iter__(self) -> Iterator[str]: """Provide support for 'key in task'.""" yield from (f for f in self.normalized_task)