-
Notifications
You must be signed in to change notification settings - Fork 908
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
fix untyped-defs on /cloudinit/config & /tests/config/ #5985
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contributing to GH5445 as part of my on-boarding.
I've signed the CLA and ran the test.
Thanks to take a loot and check if anything else is needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MostafaTarek124eru welcome to cloud-init! I left two comments inline. Also, please sign the cla.
cloudinit/config/cc_ubuntu_pro.py
Outdated
@@ -225,7 +226,10 @@ def configure_pro(token, enable=None): | |||
# related. We can distinguish them by checking if `service` is non-null | |||
# or null respectively. | |||
|
|||
enable_errors: List[dict] = [] | |||
|
|||
def handle_enable_errors(enable_resp: Dict[str, Any]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this a separate function makes the comment above nonsensical - it was describing this code yet it is no longer co-located with the code.
cloudinit/config/cc_rsyslog.py
Outdated
@@ -246,6 +246,7 @@ def __init__( | |||
self.proto = proto | |||
|
|||
self.addr = addr | |||
self.port = int(port) if port else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic looks functionally identical to the next four lines. Why is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it in the new commit
cloudinit/config/cc_rsyslog.py
Outdated
@@ -246,7 +246,7 @@ def __init__( | |||
self.proto = proto | |||
|
|||
self.addr = addr | |||
self.port = int(port) if port else None | |||
self.port = port |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.port
is assigned in both branches of the following if / else. This does nothing.
cloudinit/config/cc_ubuntu_pro.py
Outdated
except json.JSONDecodeError as e: | ||
raise RuntimeError( | ||
f"Pro response was not json: {enable_stdout}" | ||
) from e | ||
|
||
|
||
def handle_enable_errors(enable_resp: Dict[str, Any]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This silences valid mypy warnings without solving the underlying issue
consider:
>>> import json
>>> json.loads("[]")
[]
But this just told mypy that the type will be Dict[str, Any]
.
Related to 5445
Part of the Onboarding.
✓ cloudinit.config.cc_power_state_change
✓ cloudinit.config.cc_rsyslog
✓ cloudinit.config.cc_ubuntu_pro
✓ tests/unittests/config/test_cc_rsyslog
✓ tests/unittests/config/test_cc_ubuntu_pro
✓ests/unittests/config/test_cc_power_state_change
Proposed Commit Message
Additional Context
Test Steps
Merge type