Skip to content

Commit

Permalink
chore: auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent c65fe64 commit 5415c66
Show file tree
Hide file tree
Showing 125 changed files with 146 additions and 27 deletions.
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PyTest Fixtures."""

import importlib
import os
import platform
Expand Down
1 change: 0 additions & 1 deletion examples/.collection/plugins/modules/alpha.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""An ansible test module."""


DOCUMENTATION = """
module: mod_1
author:
Expand Down
1 change: 0 additions & 1 deletion examples/.collection/plugins/modules/deep/beta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""An ansible test module."""


DOCUMENTATION = """
module: mod_2
author:
Expand Down
1 change: 1 addition & 0 deletions examples/rules/task_has_tag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Example implementation of a rule requiring tasks to have tags set."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/fake_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This is used to test ability to detect and use custom modules.
"""

from ansible.module_utils.basic import AnsibleModule

EXAMPLES = r"""
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/_internal/rules.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Internally used rule classes."""

from __future__ import annotations

import inspect
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/_mockings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for mocking ansible modules and roles."""

from __future__ import annotations

import contextlib
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Application."""

from __future__ import annotations

import copy
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI parser setup and helpers."""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/color.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Console coloring and terminal support."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Store configuration options as a singleton."""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants used by AnsibleLint."""

from enum import Enum
from pathlib import Path
from typing import Literal
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Exceptions and error representations."""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/file_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions related to file operations."""

from __future__ import annotations

import copy
Expand Down
8 changes: 5 additions & 3 deletions src/ansiblelint/formatters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Output formatters."""

from __future__ import annotations

import hashlib
Expand Down Expand Up @@ -28,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:
Expand Down Expand Up @@ -288,9 +290,9 @@ def _to_sarif_result(self, match: MatchError) -> dict[str, Any]:
"ruleId": match.tag,
"level": self.get_sarif_result_severity_level(match),
"message": {
"text": str(match.details)
if str(match.details)
else str(match.message),
"text": (
str(match.details) if str(match.details) else str(match.message)
),
},
"locations": [
{
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/generate_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils to generate rules documentation."""

import logging
from collections.abc import Iterable

Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/loaders.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for loading various files."""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utils related to logging."""

import logging
import time
from collections.abc import Iterator
Expand Down
5 changes: 3 additions & 2 deletions src/ansiblelint/rules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""All internal ansible-lint rules."""

from __future__ import annotations

import copy
Expand Down Expand Up @@ -92,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
Expand Down Expand Up @@ -557,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:
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Rule definition to validate task options."""

from __future__ import annotations

import contextlib
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/avoid_implicit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of avoid-implicit rule."""

# https://github.com/ansible/ansible-lint/issues/2501
from __future__ import annotations

Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/command_instead_of_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of command-instead-of-module rule."""

# Copyright (c) 2013-2014 Will Thames <will@thames.id.au>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/command_instead_of_shell.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of command-instead-of-shell rule."""

# Copyright (c) 2016 Will Thames <will@thames.id.au>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/complexity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of limiting number of tasks."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Makes pytest fixtures available."""

# pylint: disable=wildcard-import,unused-wildcard-import
from ansiblelint.testing.fixtures import * # noqa: F403
1 change: 1 addition & 0 deletions src/ansiblelint/rules/deprecated_local_action.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation for deprecated-local-action rule."""

# Copyright (c) 2016, Tsukinowa Inc. <info@tsukinowa.jp>
# Copyright (c) 2018, Ansible Project
from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/deprecated_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of deprecated-module rule."""

# Copyright (c) 2018, Ansible Project

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/empty_string_compare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of empty-string-compare rule."""

# Copyright (c) 2016, Will Thames and contributors
# Copyright (c) 2018, Ansible Project

Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/fqcn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Rule definition for usage of fully qualified collection names for builtins."""

from __future__ import annotations

import logging
Expand Down
5 changes: 3 additions & 2 deletions src/ansiblelint/rules/galaxy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of GalaxyRule."""

from __future__ import annotations

import sys
Expand Down Expand Up @@ -63,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 (
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/ignore_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""IgnoreErrorsRule used with ansible-lint."""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/inline_env_var.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of inside-env-var rule."""

# Copyright (c) 2016 Will Thames <will@thames.id.au>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/jinja.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Rule for checking content of jinja template strings."""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/key_order.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""All tasks should be have name come first."""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/latest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of latest rule."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/literal_compare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of the literal-compare rule."""

# Copyright (c) 2016, Will Thames and contributors
# Copyright (c) 2018-2021, Ansible Project

Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/loop_var_prefix.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Optional Ansible-lint rule to enforce use of prefix on role loop vars."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/meta_incorrect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of meta-incorrect rule."""

# Copyright (c) 2018, Ansible Project
from __future__ import annotations

Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/meta_no_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of meta-no-tags rule."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/meta_runtime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of meta-runtime rule."""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/meta_video_links.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of meta-video-links rule."""

# Copyright (c) 2018, Ansible Project
from __future__ import annotations

Expand Down
7 changes: 4 additions & 3 deletions src/ansiblelint/rules/name.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of NameRule."""

from __future__ import annotations

import re
Expand Down Expand Up @@ -178,9 +179,9 @@ def transform(
if task_name:
if "|" in task_name: # if using prefix
[file_name, update_task_name] = task_name.split("|")
target_task[
"name"
] = f"{file_name.strip()} | {update_task_name.strip()[:1].upper()}{update_task_name.strip()[1:]}"
target_task["name"] = (
f"{file_name.strip()} | {update_task_name.strip()[:1].upper()}{update_task_name.strip()[1:]}"
)
else:
target_task["name"] = f"{task_name[:1].upper()}{task_name[1:]}"
match.fixed = True
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/no_changed_when.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of the no-changed-when rule."""

# Copyright (c) 2016 Will Thames <will@thames.id.au>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/no_free_form.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of NoFreeFormRule."""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/no_jinja_when.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of no-jinja-when rule."""

from __future__ import annotations

import re
Expand Down
3 changes: 2 additions & 1 deletion src/ansiblelint/rules/no_prompting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of no-prompting rule."""

from __future__ import annotations

import sys
Expand Down Expand Up @@ -33,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 [
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/no_relative_paths.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of no-relative-paths rule."""

# Copyright (c) 2016, Tsukinowa Inc. <info@tsukinowa.jp>
# Copyright (c) 2018, Ansible Project

Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/no_same_owner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Optional rule for avoiding keeping owner/group when transferring files."""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/no_tabs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of no-tabs rule."""

# Copyright (c) 2016, Will Thames and contributors
# Copyright (c) 2018, Ansible Project
from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/only_builtins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Rule definition for usage of builtin actions only."""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/package_latest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementations of the package-latest rule."""

# Copyright (c) 2016 Will Thames <will@thames.id.au>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/partial_become.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of partial-become rule."""

# Copyright (c) 2016 Will Thames <will@thames.id.au>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/playbook_extension.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of playbook-extension rule."""

# Copyright (c) 2016, Tsukinowa Inc. <info@tsukinowa.jp>
# Copyright (c) 2018, Ansible Project
from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/risky_octal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of risky-octal rule."""

# Copyright (c) 2013-2014 Will Thames <will@thames.id.au>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
Loading

0 comments on commit 5415c66

Please sign in to comment.