Skip to content

chore: enable type checking cloudinit/distros/__init__.py#6646

Merged
blackboxsw merged 6 commits intocanonical:mainfrom
holmanb:holmanb/typing-distros
Jan 5, 2026
Merged

chore: enable type checking cloudinit/distros/__init__.py#6646
blackboxsw merged 6 commits intocanonical:mainfrom
holmanb:holmanb/typing-distros

Conversation

@holmanb
Copy link
Member

@holmanb holmanb commented Jan 5, 2026

Proposed Commit Message

chore: enable type checking on cloudinit/distros/__init__.py

Additional Context

The primary benefit of this change is the increased mypy coverage in a core module for future changes.

See comments below that explain the changes.

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

Comment on lines 1338 to 1348
@classmethod
def reload_init(cls, rcs=None):
"""
Reload systemd startup daemon.
May raise ProcessExecutionError
"""
init_cmd = cls.init_cmd
if cls.uses_systemd() or "systemctl" in init_cmd:
cmd = [init_cmd, "daemon-reload"]
return subp.subp(cmd, capture=True, rcs=rcs)

Copy link
Member Author

Choose a reason for hiding this comment

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

This has only one call site, and in that context this code is a no-op. We can delete this function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still think we can delete the method from the parent class as it is never called. freebsd's reload_init method is called instead and that is the only distro taking advantage of any supplemental functionality to force a reload of main RC services.

"""
init_cmd = cls.init_cmd
if cls.uses_systemd() or "systemctl" in init_cmd:
cmd = [init_cmd, "daemon-reload"]
Copy link
Member Author

Choose a reason for hiding this comment

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

If this had ever run, this would have thrown errors when calling subp because this creates a data structure like this:

[["systemctl"], "daemon-reload"]

Copy link
Collaborator

@blackboxsw blackboxsw Jan 5, 2026

Choose a reason for hiding this comment

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

Agreed to drop this from parent Distro class, it's only used by FreeBSD which has its own subclass-local definition.

Copy link
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.

Minor suggestion to keep the cloud.distro.reload_init() call in the BSD path of cc_rsyslog. Otherwise the rest looks good.

@holmanb holmanb requested a review from blackboxsw January 5, 2026 18:33
Copy link
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.

LGTM!

@blackboxsw blackboxsw merged commit fad68ab into canonical:main Jan 5, 2026
20 checks passed
@holmanb holmanb deleted the holmanb/typing-distros branch January 5, 2026 21:48
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