Skip to content

Commit

Permalink
Refactor: remove use of typing Optional (#2453)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Sep 19, 2022
1 parent 9186f2c commit ac72842
Show file tree
Hide file tree
Showing 28 changed files with 3 additions and 68 deletions.
4 changes: 1 addition & 3 deletions docs/custom-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ import ansiblelint.utils
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable

class TaskHasTag(AnsibleLintRule):
Expand All @@ -63,7 +61,7 @@ class TaskHasTag(AnsibleLintRule):
description = 'Tasks must have tag'
tags = ['productivity']

def matchtask(self, task: Dict[str, Any], file: 'Optional[Lintable]' = None) -> Union[bool,str]:
def matchtask(self, task: Dict[str, Any], file: 'Lintable' | None = None) -> Union[bool,str]:
# If the task include another task or make the playbook fail
# Don't force to have a tag
if not set(task.keys()).isdisjoint(['include','fail']):
Expand Down
2 changes: 0 additions & 2 deletions examples/rules/task_has_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
15 changes: 1 addition & 14 deletions src/ansiblelint/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,7 @@
from functools import lru_cache
from importlib import import_module
from pathlib import Path
from typing import (
Any,
Dict,
Iterable,
Iterator,
List,
MutableMapping,
MutableSequence,
Optional,
Sequence,
Set,
Union,
cast,
)
from typing import Any, Iterable, Iterator, MutableMapping, MutableSequence, cast

from ruamel.yaml.comments import CommentedMap, CommentedSeq

Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/command_instead_of_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from ansiblelint.utils import convert_to_boolean, get_first_cmd_arg, get_second_cmd_arg

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/command_instead_of_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/deprecated_bare_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/deprecated_command_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from ansiblelint.utils import convert_to_boolean, get_first_cmd_arg

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/deprecated_local_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/deprecated_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/empty_string_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from ansiblelint.yaml_utils import nested_items_path

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/ignore_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/inline_env_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from ansiblelint.utils import get_first_cmd_arg

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/literal_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from ansiblelint.yaml_utils import nested_items_path

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/no_changed_when.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/no_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/no_log_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
from ansiblelint.utils import convert_to_boolean

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/no_loop_var_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from ansiblelint.text import toidentifier

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/no_prompting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.errors import MatchError
from ansiblelint.file_utils import Lintable

Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/no_relative_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/no_same_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/no_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from ansiblelint.yaml_utils import nested_items_path

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/package_latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/risky_file_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/risky_octal.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 0 additions & 2 deletions src/ansiblelint/rules/risky_shell_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from ansiblelint.utils import convert_to_boolean

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.file_utils import Lintable


Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import subprocess
import sys
import tempfile
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from typing import TYPE_CHECKING, Any

from ansiblelint.app import get_app
from ansiblelint.rules import RulesCollection
Expand Down

0 comments on commit ac72842

Please sign in to comment.