Skip to content

Conversation

@allenrobel
Copy link
Collaborator

@allenrobel allenrobel commented Dec 6, 2025

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

  • Only the four files below were changed by this PR. The other 22 files listed in "Files changed" are due to merging other PRs.
  • I understand this PR may not be reviewed soon due to higher-priority tasks.
  • Copilot reviewed these changes and generated one (inaccurate) comment.

Files changed

plugins/modules/dcnm_maintenance_mode.py

  • Replace results import with results_v2
  • Update results.changed call to use v2’s results.add_changed()
  • Update results.failed call to use v2’s results.add_failed()

plugins/module_utils/common/maintenance_mode.py

  • Replace results import with results_v2
  • import OperationType used by Results (v2)
  • Instantiate Results in init()
  • Set results.operation_type in the results.setter
  • Add type hints where missing
  • Modify several item.get() calls to default to “” to match the target var’s type.

plugins/module_utils/common/maintenance_mode_info.py

  • Remove TODOs associated with SwitchDetails and Results after addressing them.
  • Replace switch_details import with switch_details_v2
  • Replace results import with results_v2
  • Update results instantiation in init_
  • Add type hints where missing
  • Update conditionals to accommodate differences in return values from SwitchDetails (v2) vs v1.

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
# 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.
@allenrobel allenrobel self-assigned this Dec 6, 2025
@allenrobel allenrobel added Work in Progress Code not ready for review. ready for review PR is ready to be reviewed and removed Work in Progress Code not ready for review. labels Dec 6, 2025
@allenrobel allenrobel requested a review from Copilot December 6, 2025 06:59
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 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() and add_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.py with MaintenanceModeSetEnum and MaintenanceModeGetEnum for 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.

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