8000 Add type annotations to the `Role.__init__()` method by monsdar · Pull Request #85346 · ansible/ansible · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add type annotations to the Role.__init__() method #85346

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

Merged
merged 12 commits into from
Jun 23, 2025

Conversation

monsdar
Copy link
Contributor
@monsdar monsdar commented Jun 17, 2025
SUMMARY

This is a minor bugfix that adds type-checking to the Role.__init__ method. This has been discussed within this PR #85249 first. See this comment.

ISSUE TYPE
  • Bugfix Pull Request

@monsdar monsdar changed the title Added type-cehcking to Role.__init__ Added type-checking to Role.__init__ Jun 17, 2025
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jun 17, 2025
@ansibot
Copy link
Contributor
ansibot commented Jun 17, 2025

The test ansible-test sanity --test pep8 [explain] failed with 13 errors:

lib/ansible/playbook/role/__init__.py:110:34: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:35: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:73: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:74: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:98: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:99: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:120: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:121: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:139: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:140: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:158: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:159: E252: missing whitespace around parameter equals
lib/ansible/playbook/role/__init__.py:110:161: E501: line too long (164 > 160 characters)

The test ansible-test sanity --test mypy [explain] failed with 9 errors:

lib/ansible/playbook/role/__init__.py:114:9: var-annotated: Need type annotation for "_role_params" (hint: "_role_params: dict[<type>, <type>] = ...")
lib/ansible/playbook/role/__init__.py:131:9: var-annotated: Need type annotation for "_parents" (hint: "_parents: list[<type>] = ...")
lib/ansible/playbook/role/__init__.py:132:9: var-annotated: Need type annotation for "_dependencies" (hint: "_dependencies: list[<type>] = ...")
lib/ansible/playbook/role/__init__.py:134:9: var-annotated: Need type annotation for "_task_blocks" (hint: "_task_blocks: list[<type>] = ...")
lib/ansible/playbook/role/__init__.py:135:9: var-annotated: Need type annotation for "_handler_blocks" (hint: "_handler_blocks: list[<type>] = ...")
lib/ansible/playbook/role/__init__.py:137:9: var-annotated: Need type annotation for "_default_vars" (hint: "_default_vars: dict[<type>, <type>] = ...")
lib/ansible/playbook/role/__init__.py:138:9: var-annotated: Need type annotation for "_role_vars" (hint: "_role_vars: dict[<type>, <type>] = ...")
lib/ansible/playbook/role/__init__.py:139:9: var-annotated: Need type annotation for "_had_task_run" (hint: "_had_task_run: dict[<type>, <type>] = ...")
lib/ansible/playbook/role/__init__.py:140:9: var-annotated: Need type annotation for "_completed" (hint: "_completed: dict[<type>, <type>] = ...")

click here for bot help

@monsdar monsdar marked this pull request as draft June 17, 2025 08:15
@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jun 17, 2025
@ansibot
Copy link
Contributor
ansibot commented Jun 17, 2025

The test ansible-test sanity --test mypy [explain] failed with 1 error:

lib/ansible/playbook/role/__init__.py:124:43: assignment: Incompatible types in assignment (expression has type "DataLoader | None", base class "FieldAttributeBase" defined the type as "None")

click here for bot help

@ansibot ansibot removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. ci_verified Changes made in this PR are causing tests to fail. labels Jun 17, 2025
@monsdar monsdar marked this pull request as ready for review June 17, 2025 10:43
@s-hertel s-hertel removed the needs_triage Needs a first human triage before being processed. label Jun 17, 2025
@s-hertel s-hertel requested a review from webknjaz June 17, 2025 15:19
@webknjaz webknjaz changed the title Added type-checking to Role.__init__ Add type annotations to the Role.__init__() method Jun 17, 2025
monsdar and others added 5 commits June 19, 2025 07:21
Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
… change is about

Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
@monsdar
Copy link
Contributor Author
monsdar commented Jun 19, 2025

Thank you all for the input. I applied all the requested changes.

@webknjaz
Copy link
Member

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@webknjaz webknjaz enabled auto-merge (squash) June 23, 2025 15:48
@webknjaz webknjaz merged commit 578d25f into ansible:devel Jun 23, 2025
81 checks passed
@monsdar monsdar deleted the role_init_add_type_checking branch June 24, 2025 06:04
mattclay pushed a commit that referenced this pull request Jun 24, 2025
PR #85346

This patch adds type-checking to the `Role.__init__()` method.

Context: #85249 (comment)

Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
Co-authored-by: Nils Brinkmann <nils.brinkmann@rheinmetall.com>
(cherry picked from commit 578d25f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0