Skip to content
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

Mypy fixes #5733

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Mypy fixes #5733

merged 1 commit into from
Sep 23, 2024

Conversation

holmanb
Copy link
Member

@holmanb holmanb commented Sep 23, 2024

Proposed Commit Message

fix: type annotations for several modules

Remove those modeles from the override list.

Test Steps

See CI coverage

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

Copy link
Collaborator

@a-dubs a-dubs left a comment

Choose a reason for hiding this comment

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

Left one nit. Also, where did you remove from the override list?

cloudinit/net/__init__.py Show resolved Hide resolved
Remove those modeles from the override list.
Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

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

One inline question and I think we should be preferring List until 3.9.

@@ -654,7 +654,7 @@ def dhcp_discovery(
if is_ib_interface(interface):
infiniband_argument = ["--clientid"]
command = [
self.dhcp_client_path, # pyright: ignore
self.client_name,
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to update the constructor so that the path can only have a string?
E.g., instead of

    def __init__(self):
        self.dhcp_client_path = subp.which(self.client_name)
        if not self.dhcp_client_path:
            raise NoDHCPLeaseMissingDhclientError()

do something like

    def __init__(self):
        dhcp_client_path = subp.which(self.client_name)
        if not dhcp_client_path:
            raise NoDHCPLeaseMissingDhclientError()
        self.dhcp_client_path = dhcp_client_path

Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be better to update the constructor so that the path can only have a string?

I'm fine with checking in __init__(), but passing absolute paths to subp isn't necessary and makes the logged commands more noisy to read.

@holmanb
Copy link
Member Author

holmanb commented Sep 23, 2024

I think we should be preferring List until 3.9.

Why? What we would gain by preferring the deprecated version? This is forwards compatible and cloud-init's codebase uses list and dict extensively in type annotations where not subscripted.

Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

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

LGTM

@holmanb holmanb changed the title Holmanb/mypy fixes Mypy fixes Sep 23, 2024
@holmanb holmanb merged commit 1dd6850 into canonical:main Sep 23, 2024
21 checks passed
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.

3 participants