-
Notifications
You must be signed in to change notification settings - Fork 50
dcnm_maintenance_mode: remove results v1 #580
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. Run black and isort.
No functional changes in this commit. Run black and isort linters against MaintenanceMode.
No functional changes in this commit. Run black and isort linters against dcnm_maintenance_mode.py.
No functional changes in this commit. Run black and isort linters against unit test files for dcnm_maintenance_mode.
No functional changes in this commit. This commit updates all docstrings to conform to the standards defined in CLAUDE.md (not in this repository). These standards include: 1. Structured headings # Summary ## Raises ### ValueError ## Other heading …etc 2. Single backticks around class, method, var, names, exception names, etc.
Fix below error: ERROR: tests/unit/module_utils/common/test_maintenance_mode.py:1238:161: E501: line too long (181 > 160 characters)
Add type hints for all vars and type annotations for all methods.
Certain dcnm_maintenance_mode unit test asserts will fail due to the changes in the last commit. Fixing that in this commit.
No functional changes in this commit. 1. Update all docstrings to conform to Markdown format. 2. Add module dostrings where missing. 3. Add pylint supression directive for __metaclass__ invalid-name
No functional changes in this commit. Update copyright dates for all unit test files associuated with dcnm_maintenance_mode.
1. Suppress invalid-name for __metaclass__ 2. Add module docstring
1. Add type hints for dcnm_maintenance_mode module and support classes. 2. Replace class decorators for RestSend and Results with local properties. - plugins/module_utils/common/maintenance_mode.py - plugins/module_utils/common/maintenance_mode_info.py - plugins/modules/dcnm_maintenance_mode.py 3. Update unit tests for the above 4. Some unit tests related to verifying Results is set are removed since they are no longer needed given that Results is instantiated in class initializers. 5. Add enums for maintenance mode values (e.g, “normal” “maintenance”).
1. Add blank lines where linters prefer them. 2. Move import after DOCUMENTATION.
Use the standard fabric_type and fabric_name numbering, e.g.: fabric_name_00 - VXLAN_EVPN fabric_type_00 - VXLAN_EVPN
…-mode-integration-tests
# Summary This commit replaces Results (v1) with Results (v2) in the dcnm_maintenance_mode module and its supporting libraries. This is made possible by leveraging SwitchDetails (v2). ## Files changed 1. plugins/modules/dcnm_maintenance_mode.py 1a. Replace results import with results_v2 1b. Update results.changed call to use v2’s results.add_changed() 1c. Update results.failed call to use v2’s results.add_failed() 2. plugins/module_utils/common/maintenance_mode.py 2a. Replace results import with results_v2 2b. import OperationType used by Results (v2) 2c. Instantiate Results in __init__() 2d. Set results.operation_type in the results.setter 2e. Add type hints where missing 2f. Modify several item.get() calls to default to “” to match the target var’s type. 3. plugins/module_utils/common/maintenance_mode_info.py 3a. Remove TODOs associated with SwitchDetails and Results after addressing them. 3b. Replace switch_details import with switch_details_v2 3c. Replace results import with results_v2 3d. Update results instantiation in _init__ 3e. Add type hints where missing 3f. Update conditionals to accommodate differences in return values from SwitchDetails (v2) vs v1.
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 replaces Results (v1) with Results (v2) in the dcnm_maintenance_mode module and its supporting libraries. The migration leverages SwitchDetails (v2) and introduces comprehensive type hints, documentation improvements, and test updates.
Key Changes
- Results API Migration: Updated from Results (v1) to Results (v2) with new methods
add_changed()andadd_failed() - SwitchDetails Migration: Replaced with SwitchDetails (v2) which returns empty strings instead of None for missing values
- Type Annotations: Added comprehensive type hints using
from __future__ import annotations - Enum Introduction: Created new
enums.pywithMaintenanceModeSetEnumandMaintenanceModeGetEnumfor valid maintenance mode values - Initialization Changes: Updated default values from None to appropriate empty types ([], {}, "")
- Documentation: Converted docstrings to Markdown format with improved structure
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
plugins/modules/dcnm_maintenance_mode.py |
Main module updated with Results v2, type hints, rest_send property, and results operation_type |
plugins/module_utils/common/maintenance_mode.py |
Updated with Results v2, type hints, custom rest_send/results setters, and enums |
plugins/module_utils/common/maintenance_mode_info.py |
Migrated to SwitchDetails v2, Results v2, added type hints and property setters |
plugins/module_utils/common/enums.py |
New file defining MaintenanceModeSetEnum and MaintenanceModeGetEnum |
tests/unit/modules/dcnm/dcnm_maintenance_mode/*.py |
Updated tests for new initialization patterns and removed obsolete test cases |
tests/unit/module_utils/common/test_*.py |
Updated tests with new assertion patterns and type ignore comments |
tests/integration/targets/dcnm_maintenance_mode/tests/*.yaml |
Updated fabric name variables for consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This commit replaces Results (v1) with Results (v2) in the dcnm_maintenance_mode module and its supporting libraries.
This is made possible by leveraging SwitchDetails (v2).
Notes to reviewers
Files changed
plugins/modules/dcnm_maintenance_mode.py
plugins/module_utils/common/maintenance_mode.py
plugins/module_utils/common/maintenance_mode_info.py