Skip to content

Commit d1ff289

Browse files
authored
Improve logic of find_children (#4161)
1 parent 983d251 commit d1ff289

File tree

15 files changed

+130
-18
lines changed

15 files changed

+130
-18
lines changed

.github/workflows/tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
env:
7373
# Number of expected test passes, safety measure for accidental skip of
7474
# tests. Update value if you add/remove tests.
75-
PYTEST_REQPASS: 879
75+
PYTEST_REQPASS: 882
7676
steps:
7777
- uses: actions/checkout@v4
7878
with:

examples/playbooks/common-include-1.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
- name: Some include_tasks with file and jinja2
99
ansible.builtin.include_tasks:
1010
file: "{{ 'tasks/included-with-lint.yml' }}"
11+
- name: Some include 3
12+
ansible.builtin.include_tasks: file=tasks/included-with-lint.yml
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Fixture for test coverage
3+
hosts: localhost
4+
gather_facts: false
5+
tasks:
6+
- name: Some include with invalid syntax
7+
ansible.builtin.include_tasks: "file="
8+
- name: Some include with invalid syntax
9+
ansible.builtin.include_tasks: other=tasks/included-with-lint.yml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: Fixture for test coverage
3+
hosts: localhost
4+
gather_facts: false
5+
tasks:
6+
- name: Some include with invalid syntax
7+
ansible.builtin.include_tasks:
8+
file: null
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Fixture
3+
hosts: localhost
4+
tasks:
5+
- name: Fixture
6+
ansible.builtin.include_role:
7+
name: include_wrong_syntax

examples/playbooks/include.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
tasks:
1212
- ansible.builtin.include_tasks: tasks/x.yml
1313
- ansible.builtin.include_tasks: tasks/x.yml y=z
14+
- ansible.builtin.include_tasks: file=tasks/x.yml
1415

1516
handlers:
1617
- ansible.builtin.include_tasks: handlers/y.yml
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
- name: Invalid syntax for import (coverage)
3+
ansible.builtin.import_tasks: wrong=imported_tasks.yml

examples/roles/var_naming_pattern/tasks/include_task_with_vars.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
---
2-
- name: include_task_with_vars | Foo
2+
- name: include_task_with_vars | Var1
3+
ansible.builtin.include_tasks: file=../tasks/included-task-with-vars.yml
4+
5+
- name: include_task_with_vars | Var2
36
ansible.builtin.include_tasks: ../tasks/included-task-with-vars.yml
47
vars:
58
var_naming_pattern_1: bar
69
_var_naming_pattern_2: ... # we allow _ before the prefix
710
__var_naming_pattern_3: ... # we allow __ before the prefix
811

9-
- name: include_task_with_vars | Foo
12+
- name: include_task_with_vars | Var3
1013
ansible.builtin.include_role:
1114
name: bobbins
1215
vars:

playbook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
- name: Example
33
hosts: localhost
4+
gather_facts: false
45
tasks:
56
- name: include extra tasks
67
ansible.builtin.include_tasks:

src/ansiblelint/rules/role_name.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _infer_role_name(meta: Path, default: str) -> str:
164164
if meta_data:
165165
try:
166166
return str(meta_data["galaxy_info"]["role_name"])
167-
except KeyError:
167+
except (KeyError, TypeError):
168168
pass
169169
return default
170170

0 commit comments

Comments
 (0)