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

Fix missing model #77

Merged
merged 2 commits into from
Mar 5, 2024
Merged

Fix missing model #77

merged 2 commits into from
Mar 5, 2024

Conversation

snaselj
Copy link
Contributor

@snaselj snaselj commented Mar 1, 2024

Closes NaN

What's Changed

  • Fixed failing check on Golden Config for missing model.

@snaselj snaselj marked this pull request as ready for review March 1, 2024 12:41
@snaselj snaselj requested review from cmsirbu, Kircheneer and a team as code owners March 1, 2024 12:41
@Kircheneer
Copy link
Contributor

Can you provide an/the example of where this is happening? I don't quite get the problem case here.

@snaselj
Copy link
Contributor Author

snaselj commented Mar 4, 2024

Can you provide an/the example of where this is happening? I don't quite get the problem case here.

When running the latest develop of pylint-nautobot on nautobot-app-golden-config, you get the following error:

pylint crashed with a AstroidError and with the following stacktrace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 811, in _lint_file
    check_astroid_module(module)
  File "/usr/local/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1085, in check_astroid_module
    retval = self._check_astroid_module(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1135, in _check_astroid_module
    walker.walk(node)
  File "/usr/local/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File "/usr/local/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File "/source/pylint_nautobot/sub_class_name.py", line 90, in visit_classdef
    expected_name = get_model_name(node) + ancestor.suffix
                    ^^^^^^^^^^^^^^^^^^^^
  File "/source/pylint_nautobot/utils.py", line 125, in get_model_name
    raise NotImplementedError("This class does not have a Meta class.")
NotImplementedError: This class does not have a Meta class.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 775, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File "/usr/local/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 813, in _lint_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError

@Kircheneer
Copy link
Contributor

Sorry I'm still not 100% clear, can you also link the actual class this fails on? I'm failing to see why this should be reportable, but probably I am missing something

@snaselj
Copy link
Contributor Author

snaselj commented Mar 5, 2024

Sorry I'm still not 100% clear, can you also link the actual class this fails on? I'm failing to see why this should be reportable, but probably I am missing something

Failing here: https://github.com/nautobot/pylint-nautobot/blob/develop/pylint_nautobot/sub_class_name.py#L90

I4282 is an INFO severity, and should not affect total score:

https://pylint.pycqa.org/en/latest/user_guide/messages/message_control.html

$ pylint --help

...

  --evaluation <python_expression>
                        Python expression which should return a score less than or equal to 10. You have access to the variables 'fatal', 'error', 'warning', 'refactor', 'convention', and 'info' which
                        contain the number of messages in each category, as well as 'statement' which is the total number of statements analyzed. This score is used by the global evaluation report (RP0004).
                        (default: max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)))

...

@Kircheneer
Copy link
Contributor

Ahh info severity, good then we're good!

@Kircheneer Kircheneer merged commit baefb71 into develop Mar 5, 2024
15 checks passed
@Kircheneer Kircheneer deleted the u/snaselj-fix-gc-missing-model branch March 5, 2024 12:28
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.

2 participants