-
Notifications
You must be signed in to change notification settings - Fork 636
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
Update to append skipped rules for nested task #2113
Changes from 3 commits
9a4a1db
b70f0a9
3032e9e
a07957c
01efe0a
64db1ef
7af8ed8
b30d980
fdb2363
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
import logging | ||
from functools import lru_cache | ||
from itertools import product | ||
from typing import TYPE_CHECKING, Any, Generator, List, Optional, Sequence | ||
from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional, Sequence | ||
|
||
# Module 'ruamel.yaml' does not explicitly export attribute 'YAML'; implicit reexport disabled | ||
from ruamel.yaml import YAML | ||
|
@@ -149,9 +149,13 @@ def _get_tasks_from_blocks(task_blocks: Sequence[Any]) -> Generator[Any, None, N | |
"""Get list of tasks from list made of tasks and nested tasks.""" | ||
|
||
def get_nested_tasks(task: Any) -> Generator[Any, None, None]: | ||
if not task: | ||
return | ||
for k in NESTED_TASK_KEYS: | ||
if task and k in task and task[k]: | ||
for subtask in task[k]: | ||
if is_nested_task(subtask): | ||
yield from get_nested_tasks(subtask) | ||
yield subtask | ||
|
||
for task in task_blocks: | ||
|
@@ -193,3 +197,12 @@ def normalize_tag(tag: str) -> str: | |
used_old_tags[tag] = RENAMED_TAGS[tag] | ||
return RENAMED_TAGS[tag] | ||
return tag | ||
|
||
|
||
def is_nested_task(task: Dict[str, Any]) -> bool: | ||
"""Check if task includes block/always/rescue.""" | ||
for key in NESTED_TASK_KEYS: | ||
if task.get(key): | ||
return True | ||
|
||
return False | ||
Comment on lines
+201
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a duplicate of what is in from ansiblelint.utils import is_nested_task There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. Yes, it is a duplicate now. If
I'm not sure but it can be caused because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added some tests in commit 7af8ed8 but |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do this:
Then that could slightly simplify the rest of the logic like this:
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. That is better and more efficient. Let me fix this part.