Skip to content

Conversation

@allenrobel
Copy link
Collaborator

@allenrobel allenrobel commented Dec 3, 2025

Summary

  1. Add type-hints where missing.

  2. Add pylint suppression directive for invalid-name (metaclass) where needed

  3. Make variables private when not externally accessed.

  4. Appease mypy through several means including

  • Asserting for not None in unit tests prior to asserting for dict-like behavior
  • Ensuring str and dict objects are treated as such e.g. foo.get(“str_obj”, “”) rather than foo.get(“str_obj”, None)
  • Testing for ‘if not foo’ rather than ‘if foo is None’ in conditionals.
  • directly raise exceptions rather than calling a function that raises an exception (mypy does not understand this pattern).
  1. bootflash_info.py
  • Move validation of rest_send.params to the setter rather than the getter.
  1. Update unit tests where needed to align with the above changes.

Notes to reviewers

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

Copilot AI left a 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 None to appropriate empty values ("" for strings, {} for dicts) for better type safety
  • Moved validation of RestSend.params from 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 None to if not foo for consistency with new initialization patterns
  • Enhanced unit tests with not None assertions 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.

@allenrobel allenrobel added ready for review PR is ready to be reviewed and removed Work in Progress Code not ready for review. labels Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants