-
Notifications
You must be signed in to change notification settings - Fork 49
dcnm_fabric: max line length 160 #565
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
1. Unit tests for FabricSummary (v2) - This class did not have unit tests, added unit tests and fixtures - Updated dcnm_fabric/utils.py with FabricSummary (v2) support 2. FabricSummary (v2) - Added type hints throughout - Updated docstrings to use Markdown throughout - Made several public instances private (e.g. self.conversion -> self._conversion) - Updated rest_send and results properties with enhanced versions we use in other classes
No functional changes in this commit
…evice count. Use private attributes instead of property getters when calculating device count. The current code calls property getters (self.leaf_count, self.spine_count, self.border_gateway_count) which invoke verify_refresh_has_been_called(), adding unnecessary overhead. Co-authored-by: Copilot <[email protected]>
No functional changes in this commit. Addressing a Copilot comment regarding commented lines in fabric_summary_v2.py
…oDevNet/ansible-dcnm into tech-debt-fabric-summary-v2
Address below Copilot review comment.
[nitpick] Remove redundant empty data check in all_data property. After a successful call to refresh(), self.data cannot be empty ({}) because _verify_controller_response() at line 212 would have raised a ControllerResponseError. The verify_refresh_has_been_called() call at line 318 already ensures refresh() completed successfully. This additional check is unnecessary and inconsistent with other properties like border_gateway_count, device_count, etc.
Co-authored-by: Copilot <[email protected]>
Addressing the below Copilot review comment. [nitpick] The rest_send property getter validation prevents accessing the property before calling the setter, which is overly restrictive. Internal methods like _set_fabric_summary_endpoint() (line 176) use self.rest_send.path, which would fail this check. While refresh() validates params at line 245 before calling _set_fabric_summary_endpoint(), this getter-level validation adds unnecessary coupling and prevents legitimate use cases like inspecting the rest_send object. Consider removing lines 457-460 from the getter, as the setter and refresh() method already provide adequate validation. Co-authored-by: Copilot <[email protected]>
There are no functional changes in this PR. 1. Lint with black after change of max line length to 160.
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 applies Black code formatting with a maximum line length of 160 characters to the dcnm_fabric module, with no functional changes. The changes are preparatory work for removing version 1 of several support libraries (as noted in the PR description, this should be merged after PR #564).
Key changes:
- Consolidated multi-line import statements into single lines where they fit within 160 characters
- Reformatted multi-line function signatures, assertions, and method calls to fit within the line length limit
- Added comprehensive unit tests for FabricSummary v2 class
- Enhanced type annotations and documentation in fabric_summary_v2.py
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/modules/dcnm/dcnm_fabric/utils.py | Consolidated imports to single lines; added docstring, pylint disable comment, FabricSummaryV2 import, fixture, and response helper |
| tests/unit/modules/dcnm/dcnm_fabric/test_verify_playbook_params.py | Consolidated multi-line imports and monkeypatch.setattr() calls to single lines |
| tests/unit/modules/dcnm/dcnm_fabric/test_template_get_all.py | Consolidated imports and reformatted multi-line assertions |
| tests/unit/modules/dcnm/dcnm_fabric/test_template_get.py | Consolidated multi-line imports to single lines |
| tests/unit/modules/dcnm/dcnm_fabric/test_ruleset.py | Consolidated imports and reformatted multi-line assertions |
| tests/unit/modules/dcnm/dcnm_fabric/test_param_info.py | Consolidated imports to single lines |
| tests/unit/modules/dcnm/dcnm_fabric/test_fabric_types.py | Consolidated imports and reformatted function signatures |
| tests/unit/modules/dcnm/dcnm_fabric/test_fabric_summary_v2.py | New comprehensive unit test file for FabricSummary v2 class with 811 lines of test coverage |
| tests/unit/modules/dcnm/dcnm_fabric/test_fabric_details_v2.py | Consolidated imports and reformatted assertions and function signatures |
| tests/unit/modules/dcnm/dcnm_fabric/test_fabric_details_by_nv_pair_v2.py | Consolidated imports and reformatted multi-line assertions |
| tests/unit/modules/dcnm/dcnm_fabric/test_fabric_details_by_name_v2.py | Consolidated imports to single lines |
| tests/unit/modules/dcnm/dcnm_fabric/test_fabric_config_save.py | Consolidated imports and reformatted function signatures |
| tests/unit/modules/dcnm/dcnm_fabric/fixtures/responses_FabricSummary_V2.json | New fixture file with mocked controller responses for FabricSummary v2 tests |
| plugins/module_utils/fabric_group/query.py | Updated documentation example to reference results_v2 |
| plugins/module_utils/fabric_group/fabric_groups.py | Updated documentation example to reference results_v2 |
| plugins/module_utils/fabric_group/fabric_group_details.py | Updated documentation examples to reference results_v2 |
| plugins/module_utils/fabric_group/create.py | Updated documentation example to reference results_v2 |
| plugins/module_utils/fabric/template_get_all.py | Consolidated import statement to single line |
| plugins/module_utils/fabric/template_get.py | Consolidated import statement to single line |
| plugins/module_utils/fabric/fabric_summary_v2.py | Added typing imports, enhanced type annotations throughout, improved docstrings, refactored initialization order, and added comprehensive documentation |
| plugins/module_utils/fabric/config_save_v2.py | Consolidated import statement to single line |
| plugins/module_utils/fabric/config_save.py | Consolidated import statement to single line |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR contains no functional changes (but is based on branch tech-debt-fabric-summary-v2 (PR #564) so includes those changes).
Black was used to align line lengths to max 160.
This is in preparation for changes to remove version 1 of several support libraries.
Notes for reviewers