Skip to content

fix(cmd): enable mypy strict checking for cloudinit.cmd#6861

Open
jaborvs wants to merge 8 commits into
canonical:mainfrom
jaborvs:fix/typing-cloudinit-cmd
Open

fix(cmd): enable mypy strict checking for cloudinit.cmd#6861
jaborvs wants to merge 8 commits into
canonical:mainfrom
jaborvs:fix/typing-cloudinit-cmd

Conversation

@jaborvs
Copy link
Copy Markdown

@jaborvs jaborvs commented May 4, 2026

Partially-fixes: GH-5445

As part of my onboarding, I fixed the untyped defs errors found the following files:

  • cloudinit.cmd.devel.make_mime
  • cloudinit.cmd.devel.net_convert
  • cloudinit.cmd.main

Proposed Commit Message

fix(typing): Enable mypy strict checking for cloudinit.cmd

Remove cloudinit.cmd.main, cloudinit.cmd.devel.net_convert and
cloudinit.cmd.devel.make_mime from the check_untyped_defs=false
override list in pyproject.toml and resolve all mypy errors for
each module.

Partially-fixes: GH-5445

Additional Context

N/A

Test Steps

N/A

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>)

@jaborvs jaborvs changed the title Enable mypy strict checking for cloudinit.cmd (Partially-fixes GH-5445) Enable mypy strict checking for cloudinit.cmd (partially-fixes GH-5445) May 4, 2026
@jaborvs jaborvs marked this pull request as draft May 4, 2026 13:36
@jaborvs jaborvs force-pushed the fix/typing-cloudinit-cmd branch 5 times, most recently from 7599c4f to db7b5a7 Compare May 5, 2026 09:38
@jaborvs jaborvs marked this pull request as ready for review May 5, 2026 09:48
@jaborvs
Copy link
Copy Markdown
Author

jaborvs commented May 5, 2026

There is an extra commit I will remove once the review is completed. This is to fix the error in the "Unit: Alternate Distros / build (pull_request)" job, which fails if the package py3-python-discovery is not installed in the install dependencies step. There is an open PR which implements this fix, pending to be approved and merged (see PR-6864)

@jaborvs jaborvs changed the title Enable mypy strict checking for cloudinit.cmd (partially-fixes GH-5445) fix: enable mypy strict checking for cloudinit.cmd (partially-fixes GH-5445) May 5, 2026
@jaborvs jaborvs changed the title fix: enable mypy strict checking for cloudinit.cmd (partially-fixes GH-5445) fix: enable mypy strict checking for cloudinit.cmd May 5, 2026
@jaborvs jaborvs changed the title fix: enable mypy strict checking for cloudinit.cmd fix(cmd): enable mypy strict checking for cloudinit.cmd May 5, 2026
Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I left some feedback.

Comment thread cloudinit/cmd/devel/make_mime.py Outdated
Comment thread cloudinit/cmd/main.py
Comment thread cloudinit/cmd/main.py Outdated
@jaborvs jaborvs force-pushed the fix/typing-cloudinit-cmd branch from 4e7b475 to 79370b4 Compare May 11, 2026 13:19
@jaborvs jaborvs requested a review from holmanb May 18, 2026 07:43
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor thoughts here. Thanks a log @jaborvs for the help.

Comment thread .github/workflows/23-pr-unit-distro.yml
Comment thread cloudinit/cmd/devel/make_mime.py Outdated
Comment thread cloudinit/cmd/main.py Outdated
Comment thread cloudinit/cmd/main.py
Comment thread cloudinit/cmd/main.py
Comment thread cloudinit/net/eni.py Outdated
@jaborvs jaborvs force-pushed the fix/typing-cloudinit-cmd branch from 79370b4 to 0af0090 Compare May 28, 2026 07:05
@jaborvs jaborvs force-pushed the fix/typing-cloudinit-cmd branch from 0af0090 to 68194c6 Compare May 28, 2026 08:14
@jaborvs jaborvs force-pushed the fix/typing-cloudinit-cmd branch from 68194c6 to d165457 Compare May 28, 2026 08:20
@jaborvs
Copy link
Copy Markdown
Author

jaborvs commented May 28, 2026

@blackboxsw i have reviewed all the comments and implemented the suggested fixes! let me know if there is anything else you would like me to fix before proceeding with the merge.
i have left all the comments unresolved so that you can review the code and then mark them as resolved if the fixes are correct :)
thanks a lot for alll the feedback!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR advances GH-5445 by enabling stricter mypy checking for cloudinit.cmd modules, removing them from the check_untyped_defs=false override list and applying targeted typing/logic adjustments to satisfy strict type checking.

Changes:

  • Removed cloudinit.cmd.devel.make_mime, cloudinit.cmd.devel.net_convert, and cloudinit.cmd.main from mypy overrides disabling check_untyped_defs.
  • Added/adjusted type annotations and small control-flow tweaks in cloudinit.cmd.main and related modules to satisfy mypy strictness.
  • Tightened type hints for datasource fetching and renderer configuration inputs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Removes mypy override exemptions so cmd modules are checked with check_untyped_defs=true.
cloudinit/stages.py Adds a concrete return type for Init.fetch and clarifies its docstring.
cloudinit/net/eni.py Broadens renderer config typing to Mapping[str, Any] for stricter typing compatibility.
cloudinit/cmd/main.py Updates CLI error handling, status typing, log exporter selection, and hostname handler call args for mypy strictness.
cloudinit/cmd/devel/net_convert.py Minor typing-related cleanup (import/use) to satisfy mypy for renderer typing.
cloudinit/cmd/devel/make_mime.py Minor refactor of warning string assembly/variable naming.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cloudinit/cmd/main.py Outdated
Comment thread cloudinit/cmd/main.py
@jaborvs jaborvs requested review from blackboxsw and Copilot June 3, 2026 09:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment thread cloudinit/stages.py
Comment thread cloudinit/cmd/main.py
Comment thread cloudinit/cmd/main.py
Comment thread cloudinit/cmd/devel/make_mime.py
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good @jaborvs with the exception of adding that !r per copilot suggestion. Thanks for this we'll get things landed when that's in place.

@jaborvs jaborvs force-pushed the fix/typing-cloudinit-cmd branch 2 times, most recently from b3aba4c to c114222 Compare June 4, 2026 07:47
@jaborvs
Copy link
Copy Markdown
Author

jaborvs commented Jun 4, 2026

All changes are ready! Thank you very much for all the feedback :)

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.

[enhancement]: fix typing of untyped-defs

4 participants