From 7ebc5aaf792441324aa302705eda839b26f3fe0f Mon Sep 17 00:00:00 2001 From: Ajinkya Udgirkar Date: Tue, 25 Apr 2023 16:03:39 +0530 Subject: [PATCH] Remove C from ruff ignores --- pyproject.toml | 1 - src/ansiblelint/__main__.py | 2 +- src/ansiblelint/app.py | 6 +++--- src/ansiblelint/file_utils.py | 2 +- src/ansiblelint/rules/args.py | 2 +- src/ansiblelint/rules/jinja.py | 2 +- src/ansiblelint/rules/role_name.py | 2 +- src/ansiblelint/rules/syntax_check.py | 4 +++- src/ansiblelint/schemas/__main__.py | 2 +- src/ansiblelint/skip_utils.py | 2 +- src/ansiblelint/utils.py | 2 +- src/ansiblelint/yaml_utils.py | 2 +- test/test_config.py | 2 +- 13 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3ad38f069d..28074129ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -227,7 +227,6 @@ ignore = [ "ARG", "A", "B", - "C", "SIM", "BLE", "D", diff --git a/src/ansiblelint/__main__.py b/src/ansiblelint/__main__.py index 3eff785fcb..273b8d2123 100755 --- a/src/ansiblelint/__main__.py +++ b/src/ansiblelint/__main__.py @@ -376,7 +376,7 @@ def _run_cli_entrypoint() -> None: raise SystemExit(exc) from exc -def path_inject() -> None: +def path_inject() -> None: # noqa: C901 """Add python interpreter path to top of PATH to fix outside venv calling.""" # This make it possible to call ansible-lint that was installed inside a # virtualenv without having to pre-activate it. Otherwise subprocess will diff --git a/src/ansiblelint/app.py b/src/ansiblelint/app.py index 04a2cdc981..d946dcc68f 100644 --- a/src/ansiblelint/app.py +++ b/src/ansiblelint/app.py @@ -46,7 +46,7 @@ def __init__(self, options: Options): # Without require_module, our _set_collections_basedir may fail self.runtime = Runtime(isolated=True, require_module=True) - def render_matches(self, matches: list[MatchError]) -> None: + def render_matches(self, matches: list[MatchError]) -> None: # noqa: C901 """Display given matches (if they are not fixed).""" matches = [match for match in matches if not match.fixed] @@ -185,7 +185,7 @@ def report_outcome(self, result: LintResult, mark_as_success: bool = False) -> i ignore_file.write( "# This file contains ignores rule violations for ansible-lint\n", ) - ignore_file.writelines(sorted(list(lines))) + ignore_file.writelines(sorted(lines)) elif matched_rules and not self.options.quiet: console_stderr.print( "Read [link=https://ansible-lint.readthedocs.io/configuring/#ignoring-rules-for-entire-files]documentation[/link] for instructions on how to ignore specific rule violations.", @@ -233,7 +233,7 @@ def report_outcome(self, result: LintResult, mark_as_success: bool = False) -> i return RC.SUCCESS return RC.VIOLATIONS_FOUND - def report_summary( # pylint: disable=too-many-branches,too-many-locals + def report_summary( # pylint: disable=too-many-branches,too-many-locals # noqa: C901 self, summary: SummarizedResults, changed_files_count: int, diff --git a/src/ansiblelint/file_utils.py b/src/ansiblelint/file_utils.py index 19e050c088..41999f251c 100644 --- a/src/ansiblelint/file_utils.py +++ b/src/ansiblelint/file_utils.py @@ -473,7 +473,7 @@ def strip_dotslash_prefix(fname: str) -> str: return fname[2:] if fname.startswith("./") else fname -def find_project_root( +def find_project_root( # noqa: C901 srcs: Sequence[str], config_file: str | None = None, ) -> tuple[Path, str]: diff --git a/src/ansiblelint/rules/args.py b/src/ansiblelint/rules/args.py index 1145c98a72..f9aade5f4e 100644 --- a/src/ansiblelint/rules/args.py +++ b/src/ansiblelint/rules/args.py @@ -91,7 +91,7 @@ class ArgsRule(AnsibleLintRule): version_added = "v6.10.0" module_aliases: dict[str, str] = {"block/always/rescue": "block/always/rescue"} - def matchtask( + def matchtask( # noqa: C901 self, task: dict[str, Any], file: Lintable | None = None, diff --git a/src/ansiblelint/rules/jinja.py b/src/ansiblelint/rules/jinja.py index 83c2951d52..bfa6310709 100644 --- a/src/ansiblelint/rules/jinja.py +++ b/src/ansiblelint/rules/jinja.py @@ -388,7 +388,7 @@ def fixture_lint_error_lines() -> list[int]: collection.register(JinjaRule()) lintable = Lintable("examples/playbooks/jinja-spacing.yml") results = Runner(lintable, rules=collection).run() - return list(map(lambda item: item.lineno, results)) + return [item.lineno for item in results] def test_jinja_spacing_playbook( error_expected_lines: list[int], diff --git a/src/ansiblelint/rules/role_name.py b/src/ansiblelint/rules/role_name.py index 3905952263..925c6200d3 100644 --- a/src/ansiblelint/rules/role_name.py +++ b/src/ansiblelint/rules/role_name.py @@ -83,7 +83,7 @@ def matchtask( def matchdir(self, lintable: Lintable) -> list[MatchError]: return self.matchyaml(lintable) - def matchyaml(self, file: Lintable) -> list[MatchError]: + def matchyaml(self, file: Lintable) -> list[MatchError]: # noqa: C901 result: list[MatchError] = [] if file.kind not in ("meta", "role", "playbook"): diff --git a/src/ansiblelint/rules/syntax_check.py b/src/ansiblelint/rules/syntax_check.py index 57545284e3..f7520b0e4b 100644 --- a/src/ansiblelint/rules/syntax_check.py +++ b/src/ansiblelint/rules/syntax_check.py @@ -71,7 +71,9 @@ class AnsibleSyntaxCheckRule(AnsibleLintRule): @staticmethod # pylint: disable=too-many-locals,too-many-branches - def _get_ansible_syntax_check_matches(lintable: Lintable) -> list[MatchError]: + def _get_ansible_syntax_check_matches( # noqa: C901 + lintable: Lintable, + ) -> list[MatchError]: """Run ansible syntax check and return a list of MatchError(s).""" default_rule: BaseRule = AnsibleSyntaxCheckRule() fh = None diff --git a/src/ansiblelint/schemas/__main__.py b/src/ansiblelint/schemas/__main__.py index d23bc0f6a3..18e24680da 100644 --- a/src/ansiblelint/schemas/__main__.py +++ b/src/ansiblelint/schemas/__main__.py @@ -42,7 +42,7 @@ def get_schema(kind: str) -> Any: # pylint: disable=too-many-branches -def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int: +def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int: # noqa: C901 """Refresh JSON schemas by downloading latest versions. Returns number of changed schemas. diff --git a/src/ansiblelint/skip_utils.py b/src/ansiblelint/skip_utils.py index 00c630d70b..9fd8034722 100644 --- a/src/ansiblelint/skip_utils.py +++ b/src/ansiblelint/skip_utils.py @@ -245,7 +245,7 @@ def _get_rule_skips_from_yaml( # noqa: max-complexity: 12 if isinstance(yaml_input, str): return [] - def traverse_yaml(obj: Any) -> None: + def traverse_yaml(obj: Any) -> None: # noqa: C901 for _, entry in obj.ca.items.items(): for v in entry: if isinstance(v, CommentToken): diff --git a/src/ansiblelint/utils.py b/src/ansiblelint/utils.py index 8348998560..fd3ab47b66 100644 --- a/src/ansiblelint/utils.py +++ b/src/ansiblelint/utils.py @@ -763,7 +763,7 @@ def __repr__(self) -> str: return f"Task('{self.name}' [{self.position}])" -def task_in_list( +def task_in_list( # noqa: C901 data: AnsibleBaseYAMLObject, filename: str, kind: str, diff --git a/src/ansiblelint/yaml_utils.py b/src/ansiblelint/yaml_utils.py index 80e3e54c26..bd6155d344 100644 --- a/src/ansiblelint/yaml_utils.py +++ b/src/ansiblelint/yaml_utils.py @@ -831,7 +831,7 @@ def __init__( # self.Representer.add_representer( @staticmethod - def _defaults_from_yamllint_config() -> dict[str, bool | int | str]: + def _defaults_from_yamllint_config() -> dict[str, bool | int | str]: # noqa: C901 """Extract FormattedYAML-relevant settings from yamllint config if possible.""" config = { "explicit_start": True, diff --git a/test/test_config.py b/test/test_config.py index 67a6cdd5cb..51a09b012b 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -5,7 +5,7 @@ def test_profiles(default_rules_collection: RulesCollection) -> None: """Test the rules included in profiles are valid.""" - profile_banned_tags = set(["opt-in", "experimental"]) + profile_banned_tags = {"opt-in", "experimental"} for name, data in PROFILES.items(): for profile_rule_id in data["rules"]: for rule in default_rules_collection.rules: