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

Refactor: remove obsolete odict class alias #2452

Merged
merged 1 commit into from
Sep 19, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ noqa
norole
nostderr
notest
odict
openshift
outdir
parseable
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@
("py:class", "ansible.template.Templar"),
("py:class", "handlers"),
("py:class", "meta"),
("py:class", "odict"),
("py:class", "playbook"),
("py:class", "requirements"),
("py:class", "role"),
Expand Down
5 changes: 1 addition & 4 deletions src/ansiblelint/_internal/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from ansiblelint.constants import RULE_DOC_URL

if TYPE_CHECKING:
from typing import Optional

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

Expand Down Expand Up @@ -117,7 +114,7 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
"""Return matches found for a specific YAML text."""
return []

def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
"""Return matches found for a specific playbook."""
return []

Expand Down
4 changes: 0 additions & 4 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ def main():
]


# odict is the base class used to represent data model of Ansible
# playbooks and tasks.
odict = dict # pylint: disable=invalid-name

# Aliases for deprecated tags/ids and their newer names
RENAMED_TAGS = {
"102": "no-jinja-when",
Expand Down
5 changes: 1 addition & 4 deletions src/ansiblelint/rules/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

from ansiblelint.constants import odict
from ansiblelint.file_utils import Lintable


Expand All @@ -25,7 +22,7 @@ class GalaxyRule(AnsibleLintRule):
tags = ["metadata", "opt-in", "experimental"]
version_added = "v6.6.0 (last update)"

def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
"""Return matches found for a specific play (entry in playbook)."""
if file.kind != "galaxy": # type: ignore
return []
Expand Down
7 changes: 3 additions & 4 deletions src/ansiblelint/rules/meta_no_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
if TYPE_CHECKING:
from typing import Any, Tuple

from ansiblelint.constants import odict

META_STR_INFO = ("author", "description")
META_INFO = tuple(
Expand All @@ -26,7 +25,7 @@


def _platform_info_errors_itr(
platforms: list[odict[str, str]],
platforms: list[dict[str, str]],
) -> Generator[str, None, None]:
if not isinstance(platforms, list):
yield "Platforms should be a list of dictionaries"
Expand All @@ -40,7 +39,7 @@ def _platform_info_errors_itr(


def _galaxy_info_errors_itr(
galaxy_info: odict[str, Any],
galaxy_info: dict[str, Any],
info_list: tuple[str, ...] = META_INFO,
str_info_list: tuple[str, ...] = META_STR_INFO,
) -> Generator[str, None, None]:
Expand All @@ -66,7 +65,7 @@ class MetaMainHasInfoRule(AnsibleLintRule):
tags = ["metadata"]
version_added = "v4.0.0"

def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
if file.kind != "meta":
return []

Expand Down
1 change: 0 additions & 1 deletion src/ansiblelint/rules/meta_no_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
if TYPE_CHECKING:
from typing import Any

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

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

if TYPE_CHECKING:
from typing import Any

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

Expand Down
3 changes: 1 addition & 2 deletions src/ansiblelint/rules/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
if TYPE_CHECKING:
from typing import Optional

from ansiblelint.constants import odict
from ansiblelint.file_utils import Lintable


Expand All @@ -27,7 +26,7 @@ class NameRule(AnsibleLintRule):
tags = ["idiom"]
version_added = "v6.5.0 (last update)"

def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
"""Return matches found for a specific play (entry in playbook)."""
results = []
if file.kind != "playbook":
Expand Down
5 changes: 1 addition & 4 deletions src/ansiblelint/rules/no_jinja_when.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from typing import Optional

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

Expand All @@ -31,7 +28,7 @@ def _is_valid(when: str) -> bool:
return True
return when.find("{{") == -1 and when.find("}}") == -1

def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
errors: list[MatchError] = []
if isinstance(data, dict):
if "roles" not in data or data["roles"] is None:
Expand Down
3 changes: 1 addition & 2 deletions src/ansiblelint/rules/no_prompting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
if TYPE_CHECKING:
from typing import Optional

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

Expand All @@ -27,7 +26,7 @@ class NoPromptingRule(AnsibleLintRule):
severity = "VERY_LOW"
version_added = "v6.0.3"

def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
"""Return matches found for a specific playbook."""
# If the Play uses the 'vars_prompt' section to set variables

Expand Down
9 changes: 4 additions & 5 deletions src/ansiblelint/rules/partial_become.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
from ansiblelint.rules import AnsibleLintRule

if TYPE_CHECKING:
from ansiblelint.constants import odict
from ansiblelint.errors import MatchError
from ansiblelint.file_utils import Lintable


def _get_subtasks(data: odict[str, Any]) -> list[Any]:
def _get_subtasks(data: dict[str, Any]) -> list[Any]:
result: list[Any] = []
block_names = [
"tasks",
Expand All @@ -50,15 +49,15 @@ def _get_subtasks(data: odict[str, Any]) -> list[Any]:
return result


def _nested_search(term: str, data: odict[str, Any]) -> Any:
def _nested_search(term: str, data: dict[str, Any]) -> Any:
if data and term in data:
return True
return reduce(
(lambda x, y: x or _nested_search(term, y)), _get_subtasks(data), False
)


def _become_user_without_become(becomeuserabove: bool, data: odict[str, Any]) -> Any:
def _become_user_without_become(becomeuserabove: bool, data: dict[str, Any]) -> Any:
if "become" in data:
# If become is in lineage of tree then correct
return False
Expand Down Expand Up @@ -97,7 +96,7 @@ class BecomeUserWithoutBecomeRule(AnsibleLintRule):
tags = ["unpredictability"]
version_added = "historic"

def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
if file.kind == "playbook":
result = _become_user_without_become(False, data)
if result:
Expand Down
3 changes: 1 addition & 2 deletions src/ansiblelint/rules/var_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from ansiblelint.utils import parse_yaml_from_file

if TYPE_CHECKING:
from ansiblelint.constants import odict
from ansiblelint.errors import MatchError


Expand Down Expand Up @@ -101,7 +100,7 @@ def is_invalid_variable_name(self, ident: str) -> bool:
# safety measure.
return not bool(self.re_pattern.match(ident))

def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
"""Return matches found for a specific playbook."""
results: list[MatchError] = []
raw_results: list[MatchError] = []
Expand Down