From 5415c66eb5001036df3939a0f5385f9e0c67ff4a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:56:46 +0000 Subject: [PATCH] chore: auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- conftest.py | 1 + examples/.collection/plugins/modules/alpha.py | 1 - examples/.collection/plugins/modules/deep/beta.py | 1 - examples/rules/task_has_tag.py | 1 + plugins/modules/fake_module.py | 1 + src/ansiblelint/_internal/rules.py | 1 + src/ansiblelint/_mockings.py | 1 + src/ansiblelint/app.py | 1 + src/ansiblelint/cli.py | 1 + src/ansiblelint/color.py | 1 + src/ansiblelint/config.py | 1 + src/ansiblelint/constants.py | 1 + src/ansiblelint/errors.py | 1 + src/ansiblelint/file_utils.py | 1 + src/ansiblelint/formatters/__init__.py | 8 +++++--- src/ansiblelint/generate_docs.py | 1 + src/ansiblelint/loaders.py | 1 + src/ansiblelint/logger.py | 1 + src/ansiblelint/rules/__init__.py | 5 +++-- src/ansiblelint/rules/args.py | 1 + src/ansiblelint/rules/avoid_implicit.py | 1 + src/ansiblelint/rules/command_instead_of_module.py | 1 + src/ansiblelint/rules/command_instead_of_shell.py | 1 + src/ansiblelint/rules/complexity.py | 1 + src/ansiblelint/rules/conftest.py | 1 + src/ansiblelint/rules/deprecated_local_action.py | 1 + src/ansiblelint/rules/deprecated_module.py | 1 + src/ansiblelint/rules/empty_string_compare.py | 1 + src/ansiblelint/rules/fqcn.py | 1 + src/ansiblelint/rules/galaxy.py | 5 +++-- src/ansiblelint/rules/ignore_errors.py | 1 + src/ansiblelint/rules/inline_env_var.py | 1 + src/ansiblelint/rules/jinja.py | 1 + src/ansiblelint/rules/key_order.py | 1 + src/ansiblelint/rules/latest.py | 1 + src/ansiblelint/rules/literal_compare.py | 1 + src/ansiblelint/rules/loop_var_prefix.py | 1 + src/ansiblelint/rules/meta_incorrect.py | 1 + src/ansiblelint/rules/meta_no_tags.py | 1 + src/ansiblelint/rules/meta_runtime.py | 1 + src/ansiblelint/rules/meta_video_links.py | 1 + src/ansiblelint/rules/name.py | 7 ++++--- src/ansiblelint/rules/no_changed_when.py | 1 + src/ansiblelint/rules/no_free_form.py | 1 + src/ansiblelint/rules/no_jinja_when.py | 1 + src/ansiblelint/rules/no_prompting.py | 3 ++- src/ansiblelint/rules/no_relative_paths.py | 1 + src/ansiblelint/rules/no_same_owner.py | 1 + src/ansiblelint/rules/no_tabs.py | 1 + src/ansiblelint/rules/only_builtins.py | 1 + src/ansiblelint/rules/package_latest.py | 1 + src/ansiblelint/rules/partial_become.py | 1 + src/ansiblelint/rules/playbook_extension.py | 1 + src/ansiblelint/rules/risky_octal.py | 1 + src/ansiblelint/rules/risky_shell_pipe.py | 1 + src/ansiblelint/rules/role_name.py | 1 + src/ansiblelint/rules/run_once.py | 3 ++- src/ansiblelint/rules/sanity.py | 1 + src/ansiblelint/rules/schema.py | 1 + src/ansiblelint/rules/syntax_check.py | 1 + src/ansiblelint/rules/var_naming.py | 1 + src/ansiblelint/rules/yaml_rule.py | 1 + src/ansiblelint/runner.py | 7 ++++--- src/ansiblelint/schemas/__main__.py | 1 + src/ansiblelint/schemas/main.py | 1 + src/ansiblelint/skip_utils.py | 2 +- src/ansiblelint/stats.py | 1 + src/ansiblelint/testing/__init__.py | 1 + src/ansiblelint/testing/fixtures.py | 1 + src/ansiblelint/text.py | 1 + src/ansiblelint/transformer.py | 5 ++--- src/ansiblelint/version.py | 1 + src/ansiblelint/yaml_utils.py | 7 ++++--- test/conftest.py | 1 + test/rules/fixtures/ematcher.py | 1 + test/rules/fixtures/raw_task.py | 1 + test/rules/fixtures/unset_variable_matcher.py | 1 + test/rules/test_deprecated_module.py | 1 + test/rules/test_inline_env_var.py | 1 + test/rules/test_no_changed_when.py | 1 + test/rules/test_package_latest.py | 1 + test/rules/test_role_names.py | 1 + test/rules/test_syntax_check.py | 1 + test/schemas/src/rebuild.py | 7 ++++--- test/test_ansiblelintrule.py | 1 + test/test_ansiblesyntax.py | 1 + test/test_app.py | 1 + test/test_cli.py | 1 + test/test_cli_role_paths.py | 1 + test/test_config.py | 1 + test/test_constants.py | 1 + test/test_dependencies_in_meta.py | 1 + test/test_examples.py | 1 + test/test_file_path_evaluation.py | 1 + test/test_file_utils.py | 1 + test/test_formatter.py | 1 + test/test_formatter_base.py | 1 + test/test_formatter_json.py | 1 + test/test_formatter_sarif.py | 1 + test/test_import_include_role.py | 1 + test/test_import_playbook.py | 1 + test/test_import_tasks.py | 1 + test/test_include_miss_file_with_role.py | 1 + test/test_internal_rules.py | 1 + test/test_lint_rule.py | 1 + test/test_load_failure.py | 1 + test/test_loaders.py | 1 + test/test_local_content.py | 1 + test/test_main.py | 1 + test/test_profiles.py | 1 + test/test_rule_properties.py | 1 + test/test_rules_collection.py | 1 + test/test_runner.py | 1 + test/test_schemas.py | 1 + test/test_skip_import_playbook.py | 1 + test/test_skip_inside_yaml.py | 1 + test/test_skip_playbook_items.py | 1 + test/test_skiputils.py | 1 + test/test_strict.py | 1 + test/test_text.py | 1 + test/test_transform_mixin.py | 1 + test/test_transformer.py | 1 + test/test_verbosity.py | 1 + test/test_with_skip_tagid.py | 1 + test/test_yaml_utils.py | 1 + 125 files changed, 146 insertions(+), 27 deletions(-) diff --git a/conftest.py b/conftest.py index e5e3a9edfb8..e7eee8faf7c 100644 --- a/conftest.py +++ b/conftest.py @@ -1,4 +1,5 @@ """PyTest Fixtures.""" + import importlib import os import platform diff --git a/examples/.collection/plugins/modules/alpha.py b/examples/.collection/plugins/modules/alpha.py index c806cadbca9..a508a05ab60 100644 --- a/examples/.collection/plugins/modules/alpha.py +++ b/examples/.collection/plugins/modules/alpha.py @@ -1,6 +1,5 @@ """An ansible test module.""" - DOCUMENTATION = """ module: mod_1 author: diff --git a/examples/.collection/plugins/modules/deep/beta.py b/examples/.collection/plugins/modules/deep/beta.py index ffd9ff8bbdc..3b60edc7d89 100644 --- a/examples/.collection/plugins/modules/deep/beta.py +++ b/examples/.collection/plugins/modules/deep/beta.py @@ -1,6 +1,5 @@ """An ansible test module.""" - DOCUMENTATION = """ module: mod_2 author: diff --git a/examples/rules/task_has_tag.py b/examples/rules/task_has_tag.py index a4b927cdc6b..a96d123a109 100644 --- a/examples/rules/task_has_tag.py +++ b/examples/rules/task_has_tag.py @@ -1,4 +1,5 @@ """Example implementation of a rule requiring tasks to have tags set.""" + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/plugins/modules/fake_module.py b/plugins/modules/fake_module.py index 1c4ab424fd1..1c42b8f4ef6 100644 --- a/plugins/modules/fake_module.py +++ b/plugins/modules/fake_module.py @@ -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""" diff --git a/src/ansiblelint/_internal/rules.py b/src/ansiblelint/_internal/rules.py index 193ce1aa397..b28dd0d4be1 100644 --- a/src/ansiblelint/_internal/rules.py +++ b/src/ansiblelint/_internal/rules.py @@ -1,4 +1,5 @@ """Internally used rule classes.""" + from __future__ import annotations import inspect diff --git a/src/ansiblelint/_mockings.py b/src/ansiblelint/_mockings.py index 4004e273e12..77bd67e8e65 100644 --- a/src/ansiblelint/_mockings.py +++ b/src/ansiblelint/_mockings.py @@ -1,4 +1,5 @@ """Utilities for mocking ansible modules and roles.""" + from __future__ import annotations import contextlib diff --git a/src/ansiblelint/app.py b/src/ansiblelint/app.py index 6042cf15bdc..a6c7d6a309f 100644 --- a/src/ansiblelint/app.py +++ b/src/ansiblelint/app.py @@ -1,4 +1,5 @@ """Application.""" + from __future__ import annotations import copy diff --git a/src/ansiblelint/cli.py b/src/ansiblelint/cli.py index c30c1f0d71e..a9542d1a226 100644 --- a/src/ansiblelint/cli.py +++ b/src/ansiblelint/cli.py @@ -1,4 +1,5 @@ """CLI parser setup and helpers.""" + from __future__ import annotations import argparse diff --git a/src/ansiblelint/color.py b/src/ansiblelint/color.py index 8f31e1c6e26..d72d98d0e38 100644 --- a/src/ansiblelint/color.py +++ b/src/ansiblelint/color.py @@ -1,4 +1,5 @@ """Console coloring and terminal support.""" + from __future__ import annotations from typing import Any diff --git a/src/ansiblelint/config.py b/src/ansiblelint/config.py index bc1c16d887f..e4763d000d7 100644 --- a/src/ansiblelint/config.py +++ b/src/ansiblelint/config.py @@ -1,4 +1,5 @@ """Store configuration options as a singleton.""" + from __future__ import annotations import json diff --git a/src/ansiblelint/constants.py b/src/ansiblelint/constants.py index b47c51cef4e..56cf71bf438 100644 --- a/src/ansiblelint/constants.py +++ b/src/ansiblelint/constants.py @@ -1,4 +1,5 @@ """Constants used by AnsibleLint.""" + from enum import Enum from pathlib import Path from typing import Literal diff --git a/src/ansiblelint/errors.py b/src/ansiblelint/errors.py index 7531018e8a7..416fa46412f 100644 --- a/src/ansiblelint/errors.py +++ b/src/ansiblelint/errors.py @@ -1,4 +1,5 @@ """Exceptions and error representations.""" + from __future__ import annotations import functools diff --git a/src/ansiblelint/file_utils.py b/src/ansiblelint/file_utils.py index cd03eb6d115..c3daf00a923 100644 --- a/src/ansiblelint/file_utils.py +++ b/src/ansiblelint/file_utils.py @@ -1,4 +1,5 @@ """Utility functions related to file operations.""" + from __future__ import annotations import copy diff --git a/src/ansiblelint/formatters/__init__.py b/src/ansiblelint/formatters/__init__.py index 9919ee8d6ad..3a70a8c932a 100644 --- a/src/ansiblelint/formatters/__init__.py +++ b/src/ansiblelint/formatters/__init__.py @@ -1,4 +1,5 @@ """Output formatters.""" + from __future__ import annotations import hashlib @@ -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: @@ -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": [ { diff --git a/src/ansiblelint/generate_docs.py b/src/ansiblelint/generate_docs.py index 8d422d93ba7..6e319fb846a 100644 --- a/src/ansiblelint/generate_docs.py +++ b/src/ansiblelint/generate_docs.py @@ -1,4 +1,5 @@ """Utils to generate rules documentation.""" + import logging from collections.abc import Iterable diff --git a/src/ansiblelint/loaders.py b/src/ansiblelint/loaders.py index 5942ff4b510..c369c892aae 100644 --- a/src/ansiblelint/loaders.py +++ b/src/ansiblelint/loaders.py @@ -1,4 +1,5 @@ """Utilities for loading various files.""" + from __future__ import annotations import logging diff --git a/src/ansiblelint/logger.py b/src/ansiblelint/logger.py index 9588c7a9e6a..cb3bb1954e8 100644 --- a/src/ansiblelint/logger.py +++ b/src/ansiblelint/logger.py @@ -1,4 +1,5 @@ """Utils related to logging.""" + import logging import time from collections.abc import Iterator diff --git a/src/ansiblelint/rules/__init__.py b/src/ansiblelint/rules/__init__.py index e056359069e..33db26e2087 100644 --- a/src/ansiblelint/rules/__init__.py +++ b/src/ansiblelint/rules/__init__.py @@ -1,4 +1,5 @@ """All internal ansible-lint rules.""" + from __future__ import annotations import copy @@ -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 @@ -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: diff --git a/src/ansiblelint/rules/args.py b/src/ansiblelint/rules/args.py index f127026cc7f..0c499215bbe 100644 --- a/src/ansiblelint/rules/args.py +++ b/src/ansiblelint/rules/args.py @@ -1,4 +1,5 @@ """Rule definition to validate task options.""" + from __future__ import annotations import contextlib diff --git a/src/ansiblelint/rules/avoid_implicit.py b/src/ansiblelint/rules/avoid_implicit.py index d2c683a331d..d752ec72580 100644 --- a/src/ansiblelint/rules/avoid_implicit.py +++ b/src/ansiblelint/rules/avoid_implicit.py @@ -1,4 +1,5 @@ """Implementation of avoid-implicit rule.""" + # https://github.com/ansible/ansible-lint/issues/2501 from __future__ import annotations diff --git a/src/ansiblelint/rules/command_instead_of_module.py b/src/ansiblelint/rules/command_instead_of_module.py index bf985456a65..9118db04beb 100644 --- a/src/ansiblelint/rules/command_instead_of_module.py +++ b/src/ansiblelint/rules/command_instead_of_module.py @@ -1,4 +1,5 @@ """Implementation of command-instead-of-module rule.""" + # Copyright (c) 2013-2014 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/ansiblelint/rules/command_instead_of_shell.py b/src/ansiblelint/rules/command_instead_of_shell.py index 0278f27d9c6..789adca352b 100644 --- a/src/ansiblelint/rules/command_instead_of_shell.py +++ b/src/ansiblelint/rules/command_instead_of_shell.py @@ -1,4 +1,5 @@ """Implementation of command-instead-of-shell rule.""" + # Copyright (c) 2016 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/ansiblelint/rules/complexity.py b/src/ansiblelint/rules/complexity.py index 29a8382ae64..ca5c132f6aa 100644 --- a/src/ansiblelint/rules/complexity.py +++ b/src/ansiblelint/rules/complexity.py @@ -1,4 +1,5 @@ """Implementation of limiting number of tasks.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/rules/conftest.py b/src/ansiblelint/rules/conftest.py index f4df7a5b270..5a22ffd5e05 100644 --- a/src/ansiblelint/rules/conftest.py +++ b/src/ansiblelint/rules/conftest.py @@ -1,3 +1,4 @@ """Makes pytest fixtures available.""" + # pylint: disable=wildcard-import,unused-wildcard-import from ansiblelint.testing.fixtures import * # noqa: F403 diff --git a/src/ansiblelint/rules/deprecated_local_action.py b/src/ansiblelint/rules/deprecated_local_action.py index 088ab79e8d2..4e09795c0a1 100644 --- a/src/ansiblelint/rules/deprecated_local_action.py +++ b/src/ansiblelint/rules/deprecated_local_action.py @@ -1,4 +1,5 @@ """Implementation for deprecated-local-action rule.""" + # Copyright (c) 2016, Tsukinowa Inc. # Copyright (c) 2018, Ansible Project from __future__ import annotations diff --git a/src/ansiblelint/rules/deprecated_module.py b/src/ansiblelint/rules/deprecated_module.py index 03c936199cb..72e328fc802 100644 --- a/src/ansiblelint/rules/deprecated_module.py +++ b/src/ansiblelint/rules/deprecated_module.py @@ -1,4 +1,5 @@ """Implementation of deprecated-module rule.""" + # Copyright (c) 2018, Ansible Project from __future__ import annotations diff --git a/src/ansiblelint/rules/empty_string_compare.py b/src/ansiblelint/rules/empty_string_compare.py index 74ae117c82a..6870ed2f42b 100644 --- a/src/ansiblelint/rules/empty_string_compare.py +++ b/src/ansiblelint/rules/empty_string_compare.py @@ -1,4 +1,5 @@ """Implementation of empty-string-compare rule.""" + # Copyright (c) 2016, Will Thames and contributors # Copyright (c) 2018, Ansible Project diff --git a/src/ansiblelint/rules/fqcn.py b/src/ansiblelint/rules/fqcn.py index 6bc44721b62..bcab1bcbf6e 100644 --- a/src/ansiblelint/rules/fqcn.py +++ b/src/ansiblelint/rules/fqcn.py @@ -1,4 +1,5 @@ """Rule definition for usage of fully qualified collection names for builtins.""" + from __future__ import annotations import logging diff --git a/src/ansiblelint/rules/galaxy.py b/src/ansiblelint/rules/galaxy.py index 5c1b28e4472..06329b2c241 100644 --- a/src/ansiblelint/rules/galaxy.py +++ b/src/ansiblelint/rules/galaxy.py @@ -1,4 +1,5 @@ """Implementation of GalaxyRule.""" + from __future__ import annotations import sys @@ -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 ( diff --git a/src/ansiblelint/rules/ignore_errors.py b/src/ansiblelint/rules/ignore_errors.py index 5b87cbe2c5f..29f04088d9f 100644 --- a/src/ansiblelint/rules/ignore_errors.py +++ b/src/ansiblelint/rules/ignore_errors.py @@ -1,4 +1,5 @@ """IgnoreErrorsRule used with ansible-lint.""" + from __future__ import annotations import sys diff --git a/src/ansiblelint/rules/inline_env_var.py b/src/ansiblelint/rules/inline_env_var.py index f578fb7203d..071bac3bdc8 100644 --- a/src/ansiblelint/rules/inline_env_var.py +++ b/src/ansiblelint/rules/inline_env_var.py @@ -1,4 +1,5 @@ """Implementation of inside-env-var rule.""" + # Copyright (c) 2016 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/ansiblelint/rules/jinja.py b/src/ansiblelint/rules/jinja.py index e81f2ac9d88..2f11607210c 100644 --- a/src/ansiblelint/rules/jinja.py +++ b/src/ansiblelint/rules/jinja.py @@ -1,4 +1,5 @@ """Rule for checking content of jinja template strings.""" + from __future__ import annotations import logging diff --git a/src/ansiblelint/rules/key_order.py b/src/ansiblelint/rules/key_order.py index 2cef09df375..2a58b8c0be2 100644 --- a/src/ansiblelint/rules/key_order.py +++ b/src/ansiblelint/rules/key_order.py @@ -1,4 +1,5 @@ """All tasks should be have name come first.""" + from __future__ import annotations import functools diff --git a/src/ansiblelint/rules/latest.py b/src/ansiblelint/rules/latest.py index 0838febff63..ef57b94351b 100644 --- a/src/ansiblelint/rules/latest.py +++ b/src/ansiblelint/rules/latest.py @@ -1,4 +1,5 @@ """Implementation of latest rule.""" + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/src/ansiblelint/rules/literal_compare.py b/src/ansiblelint/rules/literal_compare.py index 5c49c3b9b51..151398a8994 100644 --- a/src/ansiblelint/rules/literal_compare.py +++ b/src/ansiblelint/rules/literal_compare.py @@ -1,4 +1,5 @@ """Implementation of the literal-compare rule.""" + # Copyright (c) 2016, Will Thames and contributors # Copyright (c) 2018-2021, Ansible Project diff --git a/src/ansiblelint/rules/loop_var_prefix.py b/src/ansiblelint/rules/loop_var_prefix.py index 056636b2e8d..9f7a2caa077 100644 --- a/src/ansiblelint/rules/loop_var_prefix.py +++ b/src/ansiblelint/rules/loop_var_prefix.py @@ -1,4 +1,5 @@ """Optional Ansible-lint rule to enforce use of prefix on role loop vars.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/rules/meta_incorrect.py b/src/ansiblelint/rules/meta_incorrect.py index 0981f490880..ed8d8d9a8e9 100644 --- a/src/ansiblelint/rules/meta_incorrect.py +++ b/src/ansiblelint/rules/meta_incorrect.py @@ -1,4 +1,5 @@ """Implementation of meta-incorrect rule.""" + # Copyright (c) 2018, Ansible Project from __future__ import annotations diff --git a/src/ansiblelint/rules/meta_no_tags.py b/src/ansiblelint/rules/meta_no_tags.py index c27a30ed0a4..3e9b636f464 100644 --- a/src/ansiblelint/rules/meta_no_tags.py +++ b/src/ansiblelint/rules/meta_no_tags.py @@ -1,4 +1,5 @@ """Implementation of meta-no-tags rule.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/rules/meta_runtime.py b/src/ansiblelint/rules/meta_runtime.py index 1a6e62719ee..f761d0c81e0 100644 --- a/src/ansiblelint/rules/meta_runtime.py +++ b/src/ansiblelint/rules/meta_runtime.py @@ -1,4 +1,5 @@ """Implementation of meta-runtime rule.""" + from __future__ import annotations import sys diff --git a/src/ansiblelint/rules/meta_video_links.py b/src/ansiblelint/rules/meta_video_links.py index 806e73f429d..fa19cc68496 100644 --- a/src/ansiblelint/rules/meta_video_links.py +++ b/src/ansiblelint/rules/meta_video_links.py @@ -1,4 +1,5 @@ """Implementation of meta-video-links rule.""" + # Copyright (c) 2018, Ansible Project from __future__ import annotations diff --git a/src/ansiblelint/rules/name.py b/src/ansiblelint/rules/name.py index 81c1e743ff3..b63ad48137e 100644 --- a/src/ansiblelint/rules/name.py +++ b/src/ansiblelint/rules/name.py @@ -1,4 +1,5 @@ """Implementation of NameRule.""" + from __future__ import annotations import re @@ -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 diff --git a/src/ansiblelint/rules/no_changed_when.py b/src/ansiblelint/rules/no_changed_when.py index 110d414ad22..e71934d7eb8 100644 --- a/src/ansiblelint/rules/no_changed_when.py +++ b/src/ansiblelint/rules/no_changed_when.py @@ -1,4 +1,5 @@ """Implementation of the no-changed-when rule.""" + # Copyright (c) 2016 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/ansiblelint/rules/no_free_form.py b/src/ansiblelint/rules/no_free_form.py index 60cb1e9f998..8b3a3884af3 100644 --- a/src/ansiblelint/rules/no_free_form.py +++ b/src/ansiblelint/rules/no_free_form.py @@ -1,4 +1,5 @@ """Implementation of NoFreeFormRule.""" + from __future__ import annotations import functools diff --git a/src/ansiblelint/rules/no_jinja_when.py b/src/ansiblelint/rules/no_jinja_when.py index 59350c9bfcb..a5fc030b229 100644 --- a/src/ansiblelint/rules/no_jinja_when.py +++ b/src/ansiblelint/rules/no_jinja_when.py @@ -1,4 +1,5 @@ """Implementation of no-jinja-when rule.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/rules/no_prompting.py b/src/ansiblelint/rules/no_prompting.py index 7b6b987c9e8..c5d11d838c1 100644 --- a/src/ansiblelint/rules/no_prompting.py +++ b/src/ansiblelint/rules/no_prompting.py @@ -1,4 +1,5 @@ """Implementation of no-prompting rule.""" + from __future__ import annotations import sys @@ -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 [ diff --git a/src/ansiblelint/rules/no_relative_paths.py b/src/ansiblelint/rules/no_relative_paths.py index f1700782c2b..de22641cb57 100644 --- a/src/ansiblelint/rules/no_relative_paths.py +++ b/src/ansiblelint/rules/no_relative_paths.py @@ -1,4 +1,5 @@ """Implementation of no-relative-paths rule.""" + # Copyright (c) 2016, Tsukinowa Inc. # Copyright (c) 2018, Ansible Project diff --git a/src/ansiblelint/rules/no_same_owner.py b/src/ansiblelint/rules/no_same_owner.py index b4956ce647a..23290e06b53 100644 --- a/src/ansiblelint/rules/no_same_owner.py +++ b/src/ansiblelint/rules/no_same_owner.py @@ -1,4 +1,5 @@ """Optional rule for avoiding keeping owner/group when transferring files.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/rules/no_tabs.py b/src/ansiblelint/rules/no_tabs.py index 7bc48fe75b4..4951b564ed2 100644 --- a/src/ansiblelint/rules/no_tabs.py +++ b/src/ansiblelint/rules/no_tabs.py @@ -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 diff --git a/src/ansiblelint/rules/only_builtins.py b/src/ansiblelint/rules/only_builtins.py index 344df19affb..fd32eed5352 100644 --- a/src/ansiblelint/rules/only_builtins.py +++ b/src/ansiblelint/rules/only_builtins.py @@ -1,4 +1,5 @@ """Rule definition for usage of builtin actions only.""" + from __future__ import annotations import os diff --git a/src/ansiblelint/rules/package_latest.py b/src/ansiblelint/rules/package_latest.py index 0ed01b15287..9c8ce3cd4ef 100644 --- a/src/ansiblelint/rules/package_latest.py +++ b/src/ansiblelint/rules/package_latest.py @@ -1,4 +1,5 @@ """Implementations of the package-latest rule.""" + # Copyright (c) 2016 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/ansiblelint/rules/partial_become.py b/src/ansiblelint/rules/partial_become.py index 3988951d75a..b0dc4c2ea9a 100644 --- a/src/ansiblelint/rules/partial_become.py +++ b/src/ansiblelint/rules/partial_become.py @@ -1,4 +1,5 @@ """Implementation of partial-become rule.""" + # Copyright (c) 2016 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/ansiblelint/rules/playbook_extension.py b/src/ansiblelint/rules/playbook_extension.py index e853b6b6459..a08c98475c4 100644 --- a/src/ansiblelint/rules/playbook_extension.py +++ b/src/ansiblelint/rules/playbook_extension.py @@ -1,4 +1,5 @@ """Implementation of playbook-extension rule.""" + # Copyright (c) 2016, Tsukinowa Inc. # Copyright (c) 2018, Ansible Project from __future__ import annotations diff --git a/src/ansiblelint/rules/risky_octal.py b/src/ansiblelint/rules/risky_octal.py index e3651ea106f..e3dad389b45 100644 --- a/src/ansiblelint/rules/risky_octal.py +++ b/src/ansiblelint/rules/risky_octal.py @@ -1,4 +1,5 @@ """Implementation of risky-octal rule.""" + # Copyright (c) 2013-2014 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/ansiblelint/rules/risky_shell_pipe.py b/src/ansiblelint/rules/risky_shell_pipe.py index 68e06093491..b0c60632420 100644 --- a/src/ansiblelint/rules/risky_shell_pipe.py +++ b/src/ansiblelint/rules/risky_shell_pipe.py @@ -1,4 +1,5 @@ """Implementation of risky-shell-pipe rule.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/rules/role_name.py b/src/ansiblelint/rules/role_name.py index f8d9723296c..8a748bed71e 100644 --- a/src/ansiblelint/rules/role_name.py +++ b/src/ansiblelint/rules/role_name.py @@ -1,4 +1,5 @@ """Implementation of role-name rule.""" + # Copyright (c) 2020 Gael Chamoulaud # Copyright (c) 2020 Sorin Sbarnea # diff --git a/src/ansiblelint/rules/run_once.py b/src/ansiblelint/rules/run_once.py index eebdb4128c8..d6567118587 100644 --- a/src/ansiblelint/rules/run_once.py +++ b/src/ansiblelint/rules/run_once.py @@ -1,4 +1,5 @@ """Optional Ansible-lint rule to warn use of run_once with strategy free.""" + from __future__ import annotations import sys @@ -34,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/rules/sanity.py b/src/ansiblelint/rules/sanity.py index a8ad6dd2eb0..921e7126442 100644 --- a/src/ansiblelint/rules/sanity.py +++ b/src/ansiblelint/rules/sanity.py @@ -1,4 +1,5 @@ """Implementation of sanity rule.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/rules/schema.py b/src/ansiblelint/rules/schema.py index 0c3ccd31aff..1937d615f08 100644 --- a/src/ansiblelint/rules/schema.py +++ b/src/ansiblelint/rules/schema.py @@ -1,4 +1,5 @@ """Rule definition for JSON Schema Validations.""" + from __future__ import annotations import logging diff --git a/src/ansiblelint/rules/syntax_check.py b/src/ansiblelint/rules/syntax_check.py index 2b5b65b850b..0b5e2c66e74 100644 --- a/src/ansiblelint/rules/syntax_check.py +++ b/src/ansiblelint/rules/syntax_check.py @@ -1,4 +1,5 @@ """Rule definition for ansible syntax check.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/rules/var_naming.py b/src/ansiblelint/rules/var_naming.py index b64cb4029f1..14a4c405b12 100644 --- a/src/ansiblelint/rules/var_naming.py +++ b/src/ansiblelint/rules/var_naming.py @@ -1,4 +1,5 @@ """Implementation of var-naming rule.""" + from __future__ import annotations import keyword diff --git a/src/ansiblelint/rules/yaml_rule.py b/src/ansiblelint/rules/yaml_rule.py index e174d3fc9fe..3ec5b599571 100644 --- a/src/ansiblelint/rules/yaml_rule.py +++ b/src/ansiblelint/rules/yaml_rule.py @@ -1,4 +1,5 @@ """Implementation of yaml linting rule (yamllint integration).""" + from __future__ import annotations import logging diff --git a/src/ansiblelint/runner.py b/src/ansiblelint/runner.py index 9482d2eda4c..c27ecc495bd 100644 --- a/src/ansiblelint/runner.py +++ b/src/ansiblelint/runner.py @@ -1,4 +1,5 @@ """Runner implementation.""" + from __future__ import annotations import json @@ -184,9 +185,9 @@ def run(self) -> list[MatchError]: else: filename = warn.source match = MatchError( - message=warn.message - if isinstance(warn.message, str) - else "?", + message=( + warn.message if isinstance(warn.message, str) else "?" + ), rule=self.rules["warning"], filename=str(filename), ) diff --git a/src/ansiblelint/schemas/__main__.py b/src/ansiblelint/schemas/__main__.py index 41bdd41ab71..e216c0b1e6e 100644 --- a/src/ansiblelint/schemas/__main__.py +++ b/src/ansiblelint/schemas/__main__.py @@ -1,4 +1,5 @@ """Module containing cached JSON schemas.""" + import json import logging import os diff --git a/src/ansiblelint/schemas/main.py b/src/ansiblelint/schemas/main.py index c7467d12de7..ddd55afc8e4 100644 --- a/src/ansiblelint/schemas/main.py +++ b/src/ansiblelint/schemas/main.py @@ -1,4 +1,5 @@ """Module containing cached JSON schemas.""" + from __future__ import annotations import json diff --git a/src/ansiblelint/skip_utils.py b/src/ansiblelint/skip_utils.py index f2f6177b5be..1802e2617e2 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/stats.py b/src/ansiblelint/stats.py index 67320b862f7..79475d2ba02 100644 --- a/src/ansiblelint/stats.py +++ b/src/ansiblelint/stats.py @@ -1,4 +1,5 @@ """Module hosting functionality about reporting.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/src/ansiblelint/testing/__init__.py b/src/ansiblelint/testing/__init__.py index fe15c98264d..9c5463f8dfa 100644 --- a/src/ansiblelint/testing/__init__.py +++ b/src/ansiblelint/testing/__init__.py @@ -1,4 +1,5 @@ """Test utils for ansible-lint.""" + from __future__ import annotations import os diff --git a/src/ansiblelint/testing/fixtures.py b/src/ansiblelint/testing/fixtures.py index 010b0d73ffb..05e1ad782ab 100644 --- a/src/ansiblelint/testing/fixtures.py +++ b/src/ansiblelint/testing/fixtures.py @@ -5,6 +5,7 @@ pytest_plugins = ['ansiblelint.testing'] """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/src/ansiblelint/text.py b/src/ansiblelint/text.py index faa6905685e..3510f752789 100644 --- a/src/ansiblelint/text.py +++ b/src/ansiblelint/text.py @@ -1,4 +1,5 @@ """Text utils.""" + from __future__ import annotations import re diff --git a/src/ansiblelint/transformer.py b/src/ansiblelint/transformer.py index ffc3b2c5a3d..a6a62b174ce 100644 --- a/src/ansiblelint/transformer.py +++ b/src/ansiblelint/transformer.py @@ -1,4 +1,5 @@ """Transformer implementation.""" + from __future__ import annotations import logging @@ -98,9 +99,7 @@ def run(self) -> None: # any other files. (Based on suggestion from ruamel.yaml author) yaml = FormattedYAML( # Ansible only uses YAML 1.1, but others files should use newer 1.2 (ruamel.yaml defaults to 1.2) - version=(1, 1) - if file.is_owned_by_ansible() - else None, + version=(1, 1) if file.is_owned_by_ansible() else None, ) ruamel_data = yaml.load(data) diff --git a/src/ansiblelint/version.py b/src/ansiblelint/version.py index a65c3cfca81..80a0f7d7ef2 100644 --- a/src/ansiblelint/version.py +++ b/src/ansiblelint/version.py @@ -1,4 +1,5 @@ """Ansible-lint version information.""" + try: from ._version import version as __version__ except ImportError: # pragma: no cover diff --git a/src/ansiblelint/yaml_utils.py b/src/ansiblelint/yaml_utils.py index 6567531fe6f..92337e141d0 100644 --- a/src/ansiblelint/yaml_utils.py +++ b/src/ansiblelint/yaml_utils.py @@ -1,4 +1,5 @@ """Utility helpers to simplify working with yaml-based data.""" + # pylint: disable=too-many-lines from __future__ import annotations @@ -1141,9 +1142,9 @@ def _post_process_yaml(text: str, *, strip_version_directive: bool = False) -> s def clean_json( obj: Any, - func: Callable[[str], Any] = lambda key: key.startswith("__") - if isinstance(key, str) - else False, + func: Callable[[str], Any] = lambda key: ( + key.startswith("__") if isinstance(key, str) else False + ), ) -> Any: """Remove all keys matching the condition from a nested JSON-like object. diff --git a/test/conftest.py b/test/conftest.py index 6cb707e091d..35115b9494f 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,4 +1,5 @@ """PyTest fixtures for testing the project.""" + from __future__ import annotations import shutil diff --git a/test/rules/fixtures/ematcher.py b/test/rules/fixtures/ematcher.py index 1b04b6b5d93..b0340641226 100644 --- a/test/rules/fixtures/ematcher.py +++ b/test/rules/fixtures/ematcher.py @@ -1,4 +1,5 @@ """Custom rule used as fixture.""" + from ansiblelint.rules import AnsibleLintRule diff --git a/test/rules/fixtures/raw_task.py b/test/rules/fixtures/raw_task.py index 0d5b023d230..6dfd7d9a203 100644 --- a/test/rules/fixtures/raw_task.py +++ b/test/rules/fixtures/raw_task.py @@ -1,4 +1,5 @@ """Test Rule that needs_raw_task.""" + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/test/rules/fixtures/unset_variable_matcher.py b/test/rules/fixtures/unset_variable_matcher.py index 848600937c8..ea8b0c036ce 100644 --- a/test/rules/fixtures/unset_variable_matcher.py +++ b/test/rules/fixtures/unset_variable_matcher.py @@ -1,4 +1,5 @@ """Custom linting rule used as test fixture.""" + from ansiblelint.rules import AnsibleLintRule diff --git a/test/rules/test_deprecated_module.py b/test/rules/test_deprecated_module.py index a57d8db9cfd..6346b80be59 100644 --- a/test/rules/test_deprecated_module.py +++ b/test/rules/test_deprecated_module.py @@ -1,4 +1,5 @@ """Tests for deprecated-module rule.""" + from pathlib import Path from ansiblelint.rules import RulesCollection diff --git a/test/rules/test_inline_env_var.py b/test/rules/test_inline_env_var.py index 78d757e1f34..1405af75494 100644 --- a/test/rules/test_inline_env_var.py +++ b/test/rules/test_inline_env_var.py @@ -1,4 +1,5 @@ """Tests for inline-env-var rule.""" + from ansiblelint.rules import RulesCollection from ansiblelint.rules.inline_env_var import EnvVarsInCommandRule from ansiblelint.testing import RunFromText diff --git a/test/rules/test_no_changed_when.py b/test/rules/test_no_changed_when.py index c89d8f4c367..3316e125841 100644 --- a/test/rules/test_no_changed_when.py +++ b/test/rules/test_no_changed_when.py @@ -1,4 +1,5 @@ """Tests for no-change-when rule.""" + from ansiblelint.rules import RulesCollection from ansiblelint.rules.no_changed_when import CommandHasChangesCheckRule from ansiblelint.runner import Runner diff --git a/test/rules/test_package_latest.py b/test/rules/test_package_latest.py index fe0a2607142..972fced32e4 100644 --- a/test/rules/test_package_latest.py +++ b/test/rules/test_package_latest.py @@ -1,4 +1,5 @@ """Tests for package-latest rule.""" + from ansiblelint.rules import RulesCollection from ansiblelint.rules.package_latest import PackageIsNotLatestRule from ansiblelint.runner import Runner diff --git a/test/rules/test_role_names.py b/test/rules/test_role_names.py index 491cf1477d3..e13e56a64ad 100644 --- a/test/rules/test_role_names.py +++ b/test/rules/test_role_names.py @@ -1,4 +1,5 @@ """Test the RoleNames rule.""" + from __future__ import annotations from typing import TYPE_CHECKING, Any diff --git a/test/rules/test_syntax_check.py b/test/rules/test_syntax_check.py index 4efec8a6a04..04e5a07f499 100644 --- a/test/rules/test_syntax_check.py +++ b/test/rules/test_syntax_check.py @@ -1,4 +1,5 @@ """Tests for syntax-check rule.""" + from typing import Any from ansiblelint.file_utils import Lintable diff --git a/test/schemas/src/rebuild.py b/test/schemas/src/rebuild.py index 2378335c240..f0f164d09da 100644 --- a/test/schemas/src/rebuild.py +++ b/test/schemas/src/rebuild.py @@ -1,4 +1,5 @@ """Utility to generate some complex patterns.""" + import copy import json import keyword @@ -119,9 +120,9 @@ def is_ref_used(obj: Any, ref: str) -> bool: for key, value in combined_json["$defs"][subschema].items(): sub_json[key] = value sub_json["$comment"] = "Generated from ansible.json, do not edit." - sub_json[ - "$id" - ] = f"https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/{subschema}.json" + sub_json["$id"] = ( + f"https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/{subschema}.json" + ) # Remove all unreferenced ($ref) definitions ($defs) recursively while True: diff --git a/test/test_ansiblelintrule.py b/test/test_ansiblelintrule.py index 2ad5e461606..dcce2eafa92 100644 --- a/test/test_ansiblelintrule.py +++ b/test/test_ansiblelintrule.py @@ -1,4 +1,5 @@ """Generic tests for AnsibleLintRule class.""" + from __future__ import annotations from typing import TYPE_CHECKING, Any diff --git a/test/test_ansiblesyntax.py b/test/test_ansiblesyntax.py index f71a52553cf..649833ef361 100644 --- a/test/test_ansiblesyntax.py +++ b/test/test_ansiblesyntax.py @@ -3,6 +3,7 @@ This module contains tests that validate that linter does not produce errors when encountering what counts as valid Ansible syntax. """ + from ansiblelint.testing import RunFromText PB_WITH_NULL_TASKS = """\ diff --git a/test/test_app.py b/test/test_app.py index 140f5f671de..cbeae3d5feb 100644 --- a/test/test_app.py +++ b/test/test_app.py @@ -1,4 +1,5 @@ """Test for app module.""" + from pathlib import Path from ansiblelint.constants import RC diff --git a/test/test_cli.py b/test/test_cli.py index 967b61cf248..b2c3320e51b 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -1,4 +1,5 @@ """Test cli arguments and config.""" + from __future__ import annotations import os diff --git a/test/test_cli_role_paths.py b/test/test_cli_role_paths.py index f400fd485fb..d01a87cd44c 100644 --- a/test/test_cli_role_paths.py +++ b/test/test_cli_role_paths.py @@ -1,4 +1,5 @@ """Tests related to role paths.""" + from __future__ import annotations import os diff --git a/test/test_config.py b/test/test_config.py index 51a09b012bf..4c4ff5a0086 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -1,4 +1,5 @@ """Tests for config module.""" + from ansiblelint.config import PROFILES from ansiblelint.rules import RulesCollection diff --git a/test/test_constants.py b/test/test_constants.py index 52b297abec7..ad957e28b36 100644 --- a/test/test_constants.py +++ b/test/test_constants.py @@ -1,4 +1,5 @@ """Tests for constants module.""" + from ansiblelint.constants import States diff --git a/test/test_dependencies_in_meta.py b/test/test_dependencies_in_meta.py index 44007b7bb86..0206164f961 100644 --- a/test/test_dependencies_in_meta.py +++ b/test/test_dependencies_in_meta.py @@ -1,4 +1,5 @@ """Tests about dependencies in meta.""" + from ansiblelint.rules import RulesCollection from ansiblelint.runner import Runner diff --git a/test/test_examples.py b/test/test_examples.py index 64f48f75217..bdaec51e77a 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -1,4 +1,5 @@ """Assure samples produced desire outcomes.""" + import pytest from ansiblelint.app import get_app diff --git a/test/test_file_path_evaluation.py b/test/test_file_path_evaluation.py index 16267f4493b..088593f91d6 100644 --- a/test/test_file_path_evaluation.py +++ b/test/test_file_path_evaluation.py @@ -1,4 +1,5 @@ """Testing file path evaluation when using import_tasks / include_tasks.""" + from __future__ import annotations import textwrap diff --git a/test/test_file_utils.py b/test/test_file_utils.py index d040272f2b3..25d10b56c1e 100644 --- a/test/test_file_utils.py +++ b/test/test_file_utils.py @@ -1,4 +1,5 @@ """Tests for file utility functions.""" + from __future__ import annotations import copy diff --git a/test/test_formatter.py b/test/test_formatter.py index 1e351ff6a01..c41f673565a 100644 --- a/test/test_formatter.py +++ b/test/test_formatter.py @@ -1,4 +1,5 @@ """Test for output formatter.""" + # Copyright (c) 2016 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/test/test_formatter_base.py b/test/test_formatter_base.py index 2531ce6497f..d7fff4aa156 100644 --- a/test/test_formatter_base.py +++ b/test/test_formatter_base.py @@ -1,4 +1,5 @@ """Tests related to base formatter.""" + from __future__ import annotations from pathlib import Path diff --git a/test/test_formatter_json.py b/test/test_formatter_json.py index 198effaba1b..6bb09b1b944 100644 --- a/test/test_formatter_json.py +++ b/test/test_formatter_json.py @@ -1,4 +1,5 @@ """Test the codeclimate JSON formatter.""" + from __future__ import annotations import json diff --git a/test/test_formatter_sarif.py b/test/test_formatter_sarif.py index e23821544c8..c5ce31c9548 100644 --- a/test/test_formatter_sarif.py +++ b/test/test_formatter_sarif.py @@ -1,4 +1,5 @@ """Test the codeclimate JSON formatter.""" + from __future__ import annotations import json diff --git a/test/test_import_include_role.py b/test/test_import_include_role.py index bc3fdbe3320..b221646b6e3 100644 --- a/test/test_import_include_role.py +++ b/test/test_import_include_role.py @@ -1,4 +1,5 @@ """Tests related to role imports.""" + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/test/test_import_playbook.py b/test/test_import_playbook.py index 66d8763ee1b..f695581e89f 100644 --- a/test/test_import_playbook.py +++ b/test/test_import_playbook.py @@ -1,4 +1,5 @@ """Test ability to import playbooks.""" + from ansiblelint.rules import RulesCollection from ansiblelint.runner import Runner diff --git a/test/test_import_tasks.py b/test/test_import_tasks.py index aec1c255a0a..8018e08e528 100644 --- a/test/test_import_tasks.py +++ b/test/test_import_tasks.py @@ -1,4 +1,5 @@ """Test related to import of invalid files.""" + import pytest from ansiblelint.rules import RulesCollection diff --git a/test/test_include_miss_file_with_role.py b/test/test_include_miss_file_with_role.py index 6834758260f..599928eee66 100644 --- a/test/test_include_miss_file_with_role.py +++ b/test/test_include_miss_file_with_role.py @@ -1,4 +1,5 @@ """Tests related to inclusions.""" + import pytest from _pytest.logging import LogCaptureFixture diff --git a/test/test_internal_rules.py b/test/test_internal_rules.py index 9fa9bed9acf..19700156b4d 100644 --- a/test/test_internal_rules.py +++ b/test/test_internal_rules.py @@ -1,4 +1,5 @@ """Tests for internal rules.""" + from ansiblelint._internal.rules import BaseRule diff --git a/test/test_lint_rule.py b/test/test_lint_rule.py index 2e13aa205f0..db9395b45b4 100644 --- a/test/test_lint_rule.py +++ b/test/test_lint_rule.py @@ -1,4 +1,5 @@ """Tests for lintable.""" + # Copyright (c) 2013-2014 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/test/test_load_failure.py b/test/test_load_failure.py index 98d178f0f37..72112d6a97b 100644 --- a/test/test_load_failure.py +++ b/test/test_load_failure.py @@ -1,4 +1,5 @@ """Tests for LoadFailureRule.""" + import pytest from ansiblelint.rules import RulesCollection diff --git a/test/test_loaders.py b/test/test_loaders.py index b7d2fa294ce..6e8d66b66eb 100644 --- a/test/test_loaders.py +++ b/test/test_loaders.py @@ -1,4 +1,5 @@ """Tests for loaders submodule.""" + import os import tempfile import uuid diff --git a/test/test_local_content.py b/test/test_local_content.py index 8455aaf45e3..63472c226a0 100644 --- a/test/test_local_content.py +++ b/test/test_local_content.py @@ -1,4 +1,5 @@ """Test playbooks with local content.""" + from ansiblelint.rules import RulesCollection from ansiblelint.runner import Runner diff --git a/test/test_main.py b/test/test_main.py index 564907a5c4e..2a77b147385 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -1,4 +1,5 @@ """Tests related to ansiblelint.__main__ module.""" + import os import shutil import subprocess diff --git a/test/test_profiles.py b/test/test_profiles.py index 473015f4a7b..a1d98658b1a 100644 --- a/test/test_profiles.py +++ b/test/test_profiles.py @@ -1,4 +1,5 @@ """Tests for the --profile feature.""" + import platform import subprocess import sys diff --git a/test/test_rule_properties.py b/test/test_rule_properties.py index 7db3afd102d..3e5eb3e203f 100644 --- a/test/test_rule_properties.py +++ b/test/test_rule_properties.py @@ -1,4 +1,5 @@ """Tests related to rule properties.""" + from ansiblelint.rules import RulesCollection diff --git a/test/test_rules_collection.py b/test/test_rules_collection.py index f652ec84744..44317fe3b8f 100644 --- a/test/test_rules_collection.py +++ b/test/test_rules_collection.py @@ -1,4 +1,5 @@ """Tests for rule collection class.""" + # Copyright (c) 2013-2014 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/test/test_runner.py b/test/test_runner.py index b0788508b7f..0fcaa2328ac 100644 --- a/test/test_runner.py +++ b/test/test_runner.py @@ -1,4 +1,5 @@ """Tests for runner submodule.""" + # Copyright (c) 2013-2014 Will Thames # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/test/test_schemas.py b/test/test_schemas.py index cfa3bd17be3..7f5e4c933a6 100644 --- a/test/test_schemas.py +++ b/test/test_schemas.py @@ -1,4 +1,5 @@ """Test schemas modules.""" + import json import logging import os diff --git a/test/test_skip_import_playbook.py b/test/test_skip_import_playbook.py index 777fec679fc..8674c1637d8 100644 --- a/test/test_skip_import_playbook.py +++ b/test/test_skip_import_playbook.py @@ -1,4 +1,5 @@ """Test related to skipping import_playbook.""" + from pathlib import Path import pytest diff --git a/test/test_skip_inside_yaml.py b/test/test_skip_inside_yaml.py index f8b889c270c..fab03ea1276 100644 --- a/test/test_skip_inside_yaml.py +++ b/test/test_skip_inside_yaml.py @@ -1,4 +1,5 @@ """Tests related to use of inline noqa.""" + import pytest from ansiblelint.rules import RulesCollection diff --git a/test/test_skip_playbook_items.py b/test/test_skip_playbook_items.py index 2861c6aff3d..2fc05eafc84 100644 --- a/test/test_skip_playbook_items.py +++ b/test/test_skip_playbook_items.py @@ -1,4 +1,5 @@ """Tests related to use of noqa inside playbooks.""" + import pytest from ansiblelint.testing import RunFromText diff --git a/test/test_skiputils.py b/test/test_skiputils.py index fe2f20839bc..2975945b9a5 100644 --- a/test/test_skiputils.py +++ b/test/test_skiputils.py @@ -1,4 +1,5 @@ """Validate ansiblelint.skip_utils.""" + from __future__ import annotations from pathlib import Path diff --git a/test/test_strict.py b/test/test_strict.py index ba93d7cfca7..5994ffdfb86 100644 --- a/test/test_strict.py +++ b/test/test_strict.py @@ -1,4 +1,5 @@ """Test strict mode.""" + import os import pytest diff --git a/test/test_text.py b/test/test_text.py index fa91feeb7d2..22214c7adad 100644 --- a/test/test_text.py +++ b/test/test_text.py @@ -1,4 +1,5 @@ """Tests for text module.""" + from typing import Any import pytest diff --git a/test/test_transform_mixin.py b/test/test_transform_mixin.py index da78e8cbc20..44b851b717e 100644 --- a/test/test_transform_mixin.py +++ b/test/test_transform_mixin.py @@ -1,4 +1,5 @@ """Tests for TransformMixin.""" + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/test/test_transformer.py b/test/test_transformer.py index f373963a265..fabd5a34146 100644 --- a/test/test_transformer.py +++ b/test/test_transformer.py @@ -1,4 +1,5 @@ """Tests for Transformer.""" + from __future__ import annotations import os diff --git a/test/test_verbosity.py b/test/test_verbosity.py index 6dbcd1f4d8b..38df1708539 100644 --- a/test/test_verbosity.py +++ b/test/test_verbosity.py @@ -1,4 +1,5 @@ """Tests related to our logging/verbosity setup.""" + from __future__ import annotations from pathlib import Path diff --git a/test/test_with_skip_tagid.py b/test/test_with_skip_tagid.py index 5fbea8f9ae7..10e9493c26a 100644 --- a/test/test_with_skip_tagid.py +++ b/test/test_with_skip_tagid.py @@ -1,4 +1,5 @@ """Tests related to skip tag id.""" + from ansiblelint.rules import RulesCollection from ansiblelint.rules.yaml_rule import YamllintRule from ansiblelint.runner import Runner diff --git a/test/test_yaml_utils.py b/test/test_yaml_utils.py index 7ae75f37c9e..a868601e101 100644 --- a/test/test_yaml_utils.py +++ b/test/test_yaml_utils.py @@ -1,4 +1,5 @@ """Tests for yaml-related utility functions.""" + from __future__ import annotations from io import StringIO