nautobot / pylint-nautobot

Custom Pylint Rules for Nautobot
https://docs.nautobot.com/projects/pylint-nautobot/en/latest/
Other
4 stars 0 forks source link

Decouple nautobot version checks from installed version of nautobot #101

Open glennmatthews opened 6 days ago

glennmatthews commented 6 days ago

Environment

Proposed Functionality

It would be easier, when planning an upgrade to a new major version of Nautobot, to be able to enable and run the pylint-nautobot checks for the new major version without first needing to install said Nautobot version. I.e. if my app(s) currently require Nautobot 1.x, I'd like to be able to run the Nautobot 2.x checks before actually changing the packaging dependencies, installing Nautobot 2.x., and so forth.

Use Case

itdependsnetworks commented 6 days ago

I am going to guess you are running into the issue documented here: https://github.com/nautobot/nautobot/blob/094c17679c770d80229d230b544f4d33c9148c37/nautobot/docs/development/apps/migration/from-v1.md?plain=1#L24

I do not think there is an issue with pylint-nautobot (I may be wrong) but instead, pylint-django does code inspection instead of all AST. pylint-nautobot should be using all AST and not provide such issues.

Again, I may be wrong, as I am guessing the actual issue you are running into.

glennmatthews commented 6 days ago

Doesn't work as documented - without installing Nautobot v2 in my workspace, the v2 rules cannot be enabled in pylint-nautobot. (Also the specific rule names mentioned in the docs there appear incorrect/nonexistent in the latest version of pylint-nautobot)

itdependsnetworks commented 6 days ago

Doesn't work as documented - without installing Nautobot v2 in my workspace, the v2 rules cannot be enabled in pylint-nautobot

I am not sure I understand the use case in general. You can't mix and match environments, so you have to be in 1 environment or the other so what does this actually provide?

Also the specific rule names mentioned in the docs there appear incorrect/nonexistent in the latest version of pylint-nautobot

Just worked for me and matches query in pylint-nautobot.

root@3fc85e36be0b:/source# pylint -v --disable=all --enable=nautobot-code-location-changes,nautobot-replaced-models *
Using config file /source/pyproject.toml
************* Module nautobot_data_orchestrator.models
nautobot_data_orchestrator/models.py:5:0: E4214: Imports a model that has been replaced (dcim.Region -> dcim.Location). (nb-replaced-region)
************* Module nautobot_data_orchestrator.jobs
nautobot_data_orchestrator/jobs.py:9:0: E4252: Import location has changed for TreeModelSerializerMixin (nautobot.core.api.utils -> nautobot.core.api.serializers). (nb-code-location-changed-object)
nautobot_data_orchestrator/jobs.py:10:0: E4214: Imports a model that has been replaced (dcim.Region -> dcim.Location). (nb-replaced-region)

---------------------------------------------------------------------------------------------------
Your code has been rated at 9.42/10 (previous run: 9.42/10, +0.00)
Checked 0 files, skipped 0 files