Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove C from ruff ignores #3343

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ ignore = [
"ARG",
"A",
"B",
"C",
"SIM",
"BLE",
"D",
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/ansiblelint/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/role_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
4 changes: 3 additions & 1 deletion src/ansiblelint/rules/syntax_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/schemas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/skip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down