Skip to content
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

Refactor and update plugin configuration and utility functions #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kani999
Copy link

@Kani999 Kani999 commented Feb 28, 2025

Closes #4

Support NetBox 4.2

  • Reorganized and improved readability of the AutoCableLabelsConfig class in init.py
    • Grouped related attributes (metadata, requirements, URL config, settings)
    • Added docstrings and comments for better clarity
  • Updated utils.py to use the correct import path for get_plugin_config
    • Changed import from extras.plugins.utils to netbox.plugins.utils
    • Added a fallback import from netbox.plugins with type ignore for compatibility

Summary by CodeRabbit

  • New Features

    • Enhanced the plugin’s configuration with a clearer description of its automatic cable labeling based on user-defined templates.
    • Introduced new options to streamline configuration and navigation for a better user experience.
  • Chores

    • Updated the plugin version and compatibility requirements to ensure optimal integration.

…port NetBox 4.2

- Reorganized and improved readability of the AutoCableLabelsConfig class in __init__.py
  - Grouped related attributes (metadata, requirements, URL config, settings)
  - Added docstrings and comments for better clarity
- Updated utils.py to use the correct import path for get_plugin_config
  - Changed import from extras.plugins.utils to netbox.plugins.utils
  - Added a fallback import from netbox.plugins with type ignore for compatibility
@Kani999
Copy link
Author

Kani999 commented Feb 28, 2025

Walkthrough

The pull request updates the plugin configuration by incrementing the version number and modifying several import paths. In the main configuration file, new metadata attributes and clearer docstrings have been added, along with updated version requirements and the introduction of additional configuration attributes. A similar update is applied in the utility module, where the import for get_plugin_config now points to a new module path.

Changes

File Changes
netbox_cable_labels/__init__.py - Increment version from "0.0.3" to "0.0.4"
- Change import of PluginConfig from extras.plugins to netbox.plugins
- Update class docstring to detail auto-labeling functionality
- Update min_version to "4.2.0" and add max_version "4.99.99"
- Add base_url ("cable-labels") and empty required_settings
- Enhance ready method docstring and update signals import
netbox_cable_labels/utils.py - Update import for get_plugin_config so it is sourced from netbox.plugins.utils instead of extras.plugins.utils, including changes in the fallback import path

Sequence Diagram(s)

sequenceDiagram
    participant Django
    participant AutoCableLabelsConfig
    Django->>+AutoCableLabelsConfig: Django is ready (initializes plugins)
    AutoCableLabelsConfig-->>-Django: Executes initialization tasks (signals, config setup)
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a527d12 and 1945be2.

📒 Files selected for processing (2)
  • netbox_cable_labels/__init__.py (1 hunks)
  • netbox_cable_labels/utils.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • netbox_cable_labels/utils.py
🧰 Additional context used
🪛 Ruff (0.8.2)
netbox_cable_labels/__init__.py

39-39: netbox_cable_labels.signals imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

🔇 Additional comments (7)
netbox_cable_labels/__init__.py (7)

5-5: Version increment looks good.

The version is updated from "0.0.3" to "0.0.4" to reflect the changes in this PR.


7-7: Import path update is correct.

This change from extras.plugins to netbox.plugins aligns with NetBox 4.2's module structure reorganization.


11-14: Clear and descriptive docstring.

The expanded docstring provides better clarity about the plugin's purpose and functionality.


16-23: Well-organized metadata section.

Good job grouping related attributes under a clear comment heading and using the module-level variables for author information.


24-27: Version requirements appropriately updated.

The updated version requirements properly reflect compatibility with NetBox 4.2 and establish a reasonable upper bound with max_version.


28-33: Well-structured configuration sections.

The organization of URL configuration and plugin settings with clear section comments enhances code readability.


36-39: Improved method documentation and signal import.

The docstring clarifies the method's purpose, and the comment explains the reason for the signal import.

Note: The static analysis tool flagged the signals import as unused, but this is a false positive since the import is intentionally used for its side effects (to register signals), which is a common pattern in Django applications.

🧰 Tools
🪛 Ruff (0.8.2)

39-39: netbox_cable_labels.signals imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to install plugin
1 participant