Skip to content

Commit

Permalink
Disable FA100, FA102
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock committed Oct 6, 2023
1 parent 6e33e71 commit e20bb71
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 61 deletions.
31 changes: 15 additions & 16 deletions plugins/action/git_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""The git_publish action plugin."""

from __future__ import absolute_import, annotations, division, print_function
from __future__ import absolute_import, division, print_function

import shutil
import webbrowser

from contextlib import suppress
from dataclasses import asdict
from typing import TYPE_CHECKING, Dict, List, TypeVar, Union
from dataclasses import asdict, dataclass
from typing import Dict, List, Optional, TypeVar, Union

from ansible.errors import AnsibleActionFail

# pylint: disable=import-error, useless-suppression
from ansible.parsing.dataloader import DataLoader
from ansible.playbook.play_context import PlayContext
from ansible.playbook.task import Task
from ansible.plugins import loader as plugin_loader
from ansible.plugins.connection.local import Connection
from ansible.template import Templar

# pylint: disable=import-error
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
AnsibleArgSpecValidator,
)
Expand All @@ -24,21 +30,14 @@
from ..plugin_utils.git_base import ActionInit, GitBase, ResultBase


if TYPE_CHECKING:
from ansible.parsing.dataloader import DataLoader
from ansible.playbook.play_context import PlayContext
from ansible.playbook.task import Task
from ansible.plugins import loader as plugin_loader
from ansible.plugins.connection.local import Connection
from ansible.template import Templar


# pylint: disable=invalid-name
__metaclass__ = type
# pylint: enable=invalid-name

JSONTypes = Union[bool, int, str, Dict, List]


@dataclass(frozen=False)
class Result(ResultBase):
"""Data structure for the task result."""

Expand Down Expand Up @@ -249,8 +248,8 @@ def _remove_repo(self: T) -> None:
def run(
self: T,
tmp: None = None,
task_vars: dict[str, JSONTypes] | None = None,
) -> dict[str, JSONTypes]:
task_vars: Optional[Dict[str, JSONTypes]] = None,
) -> Dict[str, JSONTypes]:
"""Run the action plugin.
:param tmp: The temporary directory
Expand Down
37 changes: 18 additions & 19 deletions plugins/action/git_retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""The git_retrieve action plugin."""

from __future__ import absolute_import, annotations, division, print_function
from __future__ import absolute_import, division, print_function

import datetime
import re
import tempfile

from dataclasses import asdict
from dataclasses import asdict, dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING, ClassVar, Dict, List, TypeVar, Union
from typing import Dict, List, Optional, Tuple, TypeVar, Union

from ansible.errors import AnsibleActionFail

# pylint: disable=import-error, useless-suppression
from ansible.parsing.dataloader import DataLoader
from ansible.playbook.play_context import PlayContext
from ansible.playbook.task import Task
from ansible.plugins import loader as plugin_loader
from ansible.plugins.connection.local import Connection
from ansible.template import Templar

# pylint: disable=import-error
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
AnsibleArgSpecValidator,
)
Expand All @@ -25,26 +31,19 @@
from ..plugin_utils.git_base import ActionInit, GitBase, ResultBase


if TYPE_CHECKING:
from ansible.parsing.dataloader import DataLoader
from ansible.playbook.play_context import PlayContext
from ansible.playbook.task import Task
from ansible.plugins import loader as plugin_loader
from ansible.plugins.connection.local import Connection
from ansible.template import Templar


# pylint: disable=invalid-name
__metaclass__ = type
# pylint: enable=invalid-name

JSONTypes = Union[bool, int, str, Dict, List]


@dataclass(frozen=False)
class Result(ResultBase):
"""Data structure for the task result."""

branch_name: str = ""
branches: ClassVar[list[str]] = []
branches: List[str] = field(default_factory=list)
name: str = ""
path: str = ""

Expand Down Expand Up @@ -89,8 +88,8 @@ def __init__( # noqa: PLR0913
),
)

self._base_command: tuple[str, ...]
self._branches: list[str]
self._base_command: Tuple[str, ...]
self._branches: List[str]
self._branch_name: str
self._parent_directory: str
self._repo_path: str
Expand Down Expand Up @@ -327,8 +326,8 @@ def _pull_upstream(self: T) -> None:
def run(
self: T,
tmp: None = None,
task_vars: dict[str, JSONTypes] | None = None,
) -> dict[str, JSONTypes]:
task_vars: Optional[Dict[str, JSONTypes]] = None,
) -> Dict[str, JSONTypes]:
"""Run the action plugin.
:param tmp: The temporary directory
Expand Down
16 changes: 8 additions & 8 deletions plugins/plugin_utils/command.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Definitions for the command runner."""
from __future__ import absolute_import, annotations, division, print_function
from __future__ import absolute_import, division, print_function

import shlex

Expand All @@ -10,7 +10,7 @@


from dataclasses import dataclass, field
from typing import TypeVar
from typing import Dict, List, Optional, TypeVar, Union


T = TypeVar("T", bound="Command") # pylint: disable=invalid-name, useless-suppression
Expand All @@ -26,16 +26,16 @@ class Command:

# pylint: disable=too-many-instance-attributes

command_parts: list[str]
command_parts: List[str]
fail_msg: str

env: dict[str, str] | None = None
no_log: dict[str, str] = field(default_factory=dict)
env: Optional[Dict[str, str]] = None
no_log: Dict[str, str] = field(default_factory=dict)
return_code: int = -1
stdout: str = ""
stderr: str = ""
stdout_lines: list[str] = field(default_factory=list)
stderr_lines: list[str] = field(default_factory=list)
stdout_lines: List[str] = field(default_factory=list)
stderr_lines: List[str] = field(default_factory=list)

@property
def command(self: T) -> str:
Expand All @@ -46,7 +46,7 @@ def command(self: T) -> str:
return shlex.join(self.command_parts)

@property
def cleaned(self: T) -> dict[str, int | dict[str, str] | list[str] | str]:
def cleaned(self: T) -> Dict[str, Union[int, Dict[str, str], List[str], str]]:
"""Return the sanitized details of the command for the log.
:return: The sanitized details of the command for the log.
Expand Down
16 changes: 5 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,7 @@ enable = [

# Run with xdist 1 until molecule has shared scenario state
[tool.pytest.ini_options]
addopts = [
"-n",
"1",
"--log-level",
"WARNING",
"--color",
"yes"
]
addopts = ["-n", "1", "--log-level", "WARNING", "--color", "yes"]
testpaths = ["tests"]
filterwarnings = ['ignore:AnsibleCollectionFinder has already been configured']

Expand All @@ -51,8 +44,9 @@ select = ["ALL"]
# ARG = flake8 argument, overlap with pylint
# FBT = flake8 boolean, silly
# TID = flake8 tidy imports, need relative for pylint
ignore = ["ARG", "FBT", "TID"]
target-version = "py38"
# FA100, FA102 issues with 3.8/3.9 + 2.12
ignore = ["ARG", "FBT", "TID", "FA100", "FA102"]
# target-version = "py38"

[tool.ruff.per-file-ignores]
# D100 Missing docstring in public module (ansible)
Expand Down Expand Up @@ -80,7 +74,7 @@ target-version = "py38"
lines-after-imports = 2 # Ensures consistency for cases when there's variable vs function/class definitions after imports
lines-between-types = 1 # Separate import/from with 1 line
required-imports = [
"from __future__ import absolute_import, division, print_function"
"from __future__ import absolute_import, division, print_function",
]

[tool.ruff.pydocstyle]
Expand Down
12 changes: 5 additions & 7 deletions tests/unit/test_smoke.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
"""Some basic smoke tests."""

from __future__ import absolute_import, annotations, division, print_function
from __future__ import absolute_import, division, print_function


# pylint: disable=invalid-name
__metaclass__ = type
# pylint: enable=invalid-name

from typing import TYPE_CHECKING
from typing import Union

import pytest

from ansible.errors import AnsibleActionFail

# pylint: disable=import-error, useless-suppression
# pylint: disable=import-error
from ansible_collections.ansible.scm.plugins.action.git_publish import (
ActionModule as GitPublishActionModule,
)
from ansible_collections.ansible.scm.plugins.action.git_retrieve import (
ActionModule as GitRetrieveActionModule,
)


if TYPE_CHECKING:
from .definitions import ActionModuleInit
from .definitions import ActionModuleInit


@pytest.mark.parametrize(
Expand All @@ -33,7 +31,7 @@
)
def test_fail_argspec(
action_init: ActionModuleInit,
module: GitPublishActionModule | GitRetrieveActionModule,
module: Union[GitPublishActionModule, GitRetrieveActionModule],
) -> None:
"""Test an argspec failure.
Expand Down

0 comments on commit e20bb71

Please sign in to comment.