Skip to content

chore: add type annotation to cloudinit.config.cc_growpart - #7063

Open
JaneSoo wants to merge 2 commits into
canonical:mainfrom
JaneSoo:type-annotation-cc-growpart
Open

JaneSoo wants to merge 2 commits into
canonical:mainfrom
JaneSoo:type-annotation-cc-growpart

Conversation

@JaneSoo

@JaneSoo JaneSoo commented Sep 1, 2026

Copy link
Copy Markdown

ref: #5445 (comment)
chore: add type annotation to cloudinit.config.cc_growpart

  • Added type annotations to all functions and methods
    • fs as Optional[str]: Can be None based on filesystem detection
    • info will be List[Tuple[str, str, str]] of device name, action/status and message. Eg: ("/dev/sda1", "CHANGED", "changed (/dev/sda, 1) from 1024 to 2048")
  • Removed cloudinit.config.cc_growpart from mypy exclusion list

Comment thread cloudinit/config/cc_growpart.py Outdated
Comment on lines +93 to +99
diskdev: Optional[str],
partnum: Optional[str],
partdev: str,
fs: Optional[str],
) -> Tuple[Optional[int], Optional[int]]:
assert diskdev is not None
assert partnum is not None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This defeats the purpose of type annotations. You label it as Optional, but then throw an exception on the first line - this means that a caller that passes a NoneType will not by warned by type checking that this will crash the program.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

thanks for reviewing, I've removed the assert part and make them required str.

@JaneSoo
JaneSoo force-pushed the type-annotation-cc-growpart branch from b455f8c to 65aaa9a Compare September 1, 2026 14:11
@JaneSoo
JaneSoo requested a review from holmanb September 1, 2026 14:15

@holmanb holmanb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Without dropping the module from the mypy overrides, this doesn't enable type checking on the module.

Comment thread cloudinit/config/cc_growpart.py Outdated
@JaneSoo
JaneSoo force-pushed the type-annotation-cc-growpart branch from b78477e to 79f6e51 Compare September 7, 2026 11:14
@JaneSoo

JaneSoo commented Sep 7, 2026

Copy link
Copy Markdown
Author

Without dropping the module from the mypy overrides, this doesn't enable type checking on the module.

@holmanb I think the module was dropped in this commit 3082dcb#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L39

@github-actions

Copy link
Copy Markdown

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging blackboxsw, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag blackboxsw to reopen it.)

@github-actions github-actions Bot added the stale-pr Pull request is stale; will be auto-closed soon label Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale-pr Pull request is stale; will be auto-closed soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants