-
Notifications
You must be signed in to change notification settings - Fork 49
DcnmBootflash: type hints, class property RestSend #553
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
base: develop
Are you sure you want to change the base?
Conversation
No functional changes in this commit. This commit adds type hints and removes class decorator @Properties.add_rest_send in favor of a class property for RestSend.
No functional changes in this commit. Run linters to fix Ansible sanity tests for dcnm_bootflash.py
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.
Pull Request Overview
This PR adds type hints to the dcnm_bootflash module and replaces the @Properties.add_rest_send decorator with an explicit rest_send property implementation. However, contrary to the claim of "no functional changes," the PR introduces several behavioral changes in validation logic and error handling.
Key Changes
- Added type hints throughout
Common,Deleted, andQueryclasses - Replaced
@Properties.add_rest_senddecorator with explicit property getter/setter forrest_send - Changed
_rest_sendinitialization fromNonetoRestSend({}) - Modified validation checks from
is Nonecomparisons to truthiness checks (not) - Added error handling for
task is Nonecase inmain()
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| plugins/modules/dcnm_bootflash.py | Added comprehensive type hints to all classes and methods; replaced decorator with explicit rest_send property; modified validation logic from is None to not checks; added error handling in main() |
| tests/unit/modules/dcnm/dcnm_bootflash/test_bootflash_common.py | Updated test assertions to verify RestSend({}) initialization instead of None; added import for RestSend |
| tests/unit/modules/dcnm/dcnm_bootflash/test_bootflash_deleted.py | Updated test assertions to verify RestSend({}) initialization instead of None |
| tests/unit/modules/dcnm/dcnm_bootflash/test_bootflash_query.py | Updated test assertions to verify RestSend({}) initialization instead of None |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/unit/modules/dcnm/dcnm_bootflash/test_bootflash_common.py
Outdated
Show resolved
Hide resolved
1. Address Copilot review commit regarding unused import. 2. Run black linter 3. Add pylint directive to suppress invalid-name.
This commit addresses technical debt in the main dcnm_bootflash.py module.
Per Copilot's review comments, I'm modifying the claim that "no functional changes" exist in this PR. In fact, the changes in this PR introduce subtle (but desired) behavioral changes.
These changes are related to:
Handling of "falsey" values (e.g. "", []) vs None. Since we are type-hinting and instantiating variables to str, list, etc, rather than e.g. Union[str, None], our conditionals need to change accordingly.
A small "fix" related to handling the case where task is None in the error path in main().