Skip to content

chore: fix mypy issues in distros modules - #7060

Open
sshedi wants to merge 6 commits into
canonical:mainfrom
sshedi:fix-mypy-distros-modules
Open

chore: fix mypy issues in distros modules#7060
sshedi wants to merge 6 commits into
canonical:mainfrom
sshedi:fix-mypy-distros-modules

Conversation

@sshedi

@sshedi sshedi commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Proposed Commit Message

chore: fix mypy issues in distros modules

Additional Context

Test Steps

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@sshedi sshedi changed the title chore: fix mypy distros modules chore: fix mypy issues in distros modules Aug 30, 2026
Comment thread cloudinit/distros/parsers/hostname.py Outdated
@sshedi
sshedi force-pushed the fix-mypy-distros-modules branch from 4904ced to a51d559 Compare September 1, 2026 16:45
sshedi and others added 6 commits September 4, 2026 20:20
Add assert guards after parse() calls to narrow self._contents from
Optional to non-None, and split the StringIO/str variable in __str__
to satisfy mypy's type assignment checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Add assert guards to narrow self._contents from Optional to non-None
before each access in __str__, _retr_option, add_nameserver,
_remove_option, and add_search_domain.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Annotate nconf as Dict[str, Any] in generate_fallback_config so mypy
can resolve the value type of the mixed-type dict and allow .append().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Annotate _preferred_ntp_clients in the base Distro class as
Optional[List[str]] so mypy allows list assignments in preferred_ntp_clients
properties in both the base class and subclasses such as OpenSUSE.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Add @classmethod to shutdown_command to match base class signature,
rename first parameter to cls in manage_service (already a classmethod).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Declare network_conf_fn as Dict[str, str] at class level to shadow
rhel.Distro's str type, allowing dict assignment and indexing in __init__.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
@sshedi
sshedi force-pushed the fix-mypy-distros-modules branch from a51d559 to 2b36b9d Compare September 4, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants