-
Notifications
You must be signed in to change notification settings - Fork 50
dcnm_bootflash: 02 type hints #571
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
This commit (and PR) does not contain any functional changes. It merely cleans up docstrings to conform to proper Markdown and adds module docstrings.
No functional changes.
No functional changes in this commit. 1. Fix typos 2. Remove extra backtick 3. Remove extra blank line 4. Minor reformatting of docstrings
# Summary 1. Add type-hints where missing. 2. Make variables private when not externally accessed. 3. Appease mypy through several means including a. Asserting for not None in unit tests prior to asserting for dict-like behavior b. Ensuring str and dict objects are treated as such e.g. foo.get(“str_obj”, “”) rather than foo.get(“str_obj”, None) c. Testing for ‘if not foo’ rather than ‘if foo is None’ in conditionals. d. directly raise exceptions rather than calling a function that raises. 4. bootflash_info.py a. Move validation of rest_send.params to the setter rather than the getter. 5. Update unit tests where needed to align with the above changes.
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 comprehensive type hints to the dcnm_bootflash module and makes related improvements to satisfy mypy type checking requirements. The changes enhance code quality through better type safety, improved validation patterns, and standardized documentation formatting.
Key Changes
- Added type hints to function signatures, return types, and class attributes across all bootflash module files
- Changed default values from
Noneto appropriate empty values (""for strings,{}for dicts) for better type safety - Moved validation of
RestSend.paramsfrom getters to setters, ensuring invalid states cannot be set - Standardized documentation formatting from
###to#/##headers and from double backticks to single backticks - Updated conditional checks from
if foo is Nonetoif not foofor consistency with new initialization patterns - Enhanced unit tests with
not Noneassertions before dict-like operations to satisfy mypy
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/modules/dcnm/dcnm_bootflash/test_convert_target_to_params.py | Updated test assertions to match new default values (empty strings/dicts instead of None); added module docstring |
| tests/unit/modules/dcnm/dcnm_bootflash/test_convert_file_info_to_target.py | Updated test assertions and error message expectations; added module docstring |
| tests/unit/modules/dcnm/dcnm_bootflash/test_bootflash_query.py | Added assertions for not None before accessing dict-like attributes to satisfy mypy; added module docstring |
| tests/unit/modules/dcnm/dcnm_bootflash/test_bootflash_info.py | Updated error message expectations to reflect validation moved to setter; updated RestSend initialization with params; added module docstring |
| tests/unit/modules/dcnm/dcnm_bootflash/test_bootflash_deleted.py | Added pylint disable comment for metaclass |
| plugins/modules/dcnm_bootflash.py | Added module docstring; standardized documentation formatting; added validation for ip_address with appropriate error handling |
| plugins/module_utils/bootflash/convert_target_to_params.py | Added comprehensive type hints; changed default values to empty strings/dicts; standardized documentation; updated conditional checks to use if not foo pattern |
| plugins/module_utils/bootflash/convert_file_info_to_target.py | Added comprehensive type hints; changed default values to empty strings/dicts; standardized documentation; updated error raising pattern |
| plugins/module_utils/bootflash/bootflash_info.py | Added type hints; moved RestSend.params validation from getter to setter; standardized documentation; updated conditional checks and dict.get() calls with default values |
| plugins/module_utils/bootflash/bootflash_files.py | Added type hints; standardized documentation formatting; updated docstrings for clarity and consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No functional changes in this commit. 1. Add module docstring 2. Add pylint suppression directive for invalid-name
Summary
Add type-hints where missing.
Add pylint suppression directive for invalid-name (metaclass) where needed
Make variables private when not externally accessed.
Appease mypy through several means including
Notes to reviewers