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

Enable Pylint or Replace it with ruff #2840

Closed
asadali145 opened this issue Dec 6, 2023 · 2 comments · Fixed by #2865
Closed

Enable Pylint or Replace it with ruff #2840

asadali145 opened this issue Dec 6, 2023 · 2 comments · Fixed by #2865
Assignees

Comments

@asadali145
Copy link
Contributor

Description:
While working on the Wagtail upgrade #2830, we disabled Pylint as we were facing issues with the string-based model field references. It was taking extra time to find the correct versions for the Pylint upgrade. In this issue, we would like to either enable Pylint or replace it with ruff for the lining and formatting. It was suggested to use Ruff in a Tech Talk.

Steps to reproduce the issue:
Run Pylint against any file locally and you will get an error with the stacktrace:

Traceback (most recent call last):
  File "/opt/venv/bin/pylint", line 5, in <module>
    run_pylint()
  File "/opt/venv/lib/python3.9/site-packages/pylint/__init__.py", line 24, in run_pylint
    PylintRun(sys.argv[1:])
  File "/opt/venv/lib/python3.9/site-packages/pylint/lint/run.py", line 358, in __init__
    linter.check(args)
  File "/opt/venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 876, in check
    self._check_files(
  File "/opt/venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 910, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/opt/venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 936, in _check_file
    check_astroid_module(ast_node)
  File "/opt/venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1070, in check_astroid_module
    retval = self._check_astroid_module(
  File "/opt/venv/lib/python3.9/site-packages/pylint/lint/pylinter.py", line 1115, in _check_astroid_module
    walker.walk(ast_node)
  File "/opt/venv/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/opt/venv/lib/python3.9/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 58, in __call__
    self.augmentation_func(Chain(self.old_method, node), node)
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 115, in __call__
    chain()
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 67, in __call__
    self.old_method(self.node)
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 58, in __call__
    self.augmentation_func(Chain(self.old_method, node), node)
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 115, in __call__
    chain()
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 67, in __call__
    self.old_method(self.node)
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 58, in __call__
    self.augmentation_func(Chain(self.old_method, node), node)
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 115, in __call__
    chain()
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 67, in __call__
    self.old_method(self.node)
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 58, in __call__
    self.augmentation_func(Chain(self.old_method, node), node)
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 115, in __call__
    chain()
  File "/opt/venv/lib/python3.9/site-packages/pylint_plugin_utils/__init__.py", line 67, in __call__
    self.old_method(self.node)
  File "/opt/venv/lib/python3.9/site-packages/pylint/checkers/classes.py", line 796, in visit_classdef
    self._check_bases_classes(node)
  File "/opt/venv/lib/python3.9/site-packages/pylint/checkers/classes.py", line 1619, in _check_bases_classes
    unimplemented_abstract_methods(node, is_abstract).items(),
  File "/opt/venv/lib/python3.9/site-packages/pylint/checkers/utils.py", line 884, in unimplemented_abstract_methods
    inferred = safe_infer(obj)
  File "/opt/venv/lib/python3.9/site-packages/pylint/checkers/utils.py", line 1206, in safe_infer
    value = next(infer_gen)
  File "/opt/venv/lib/python3.9/site-packages/astroid/node_classes.py", line 355, in infer
    yield from self._infer(context, **kwargs)
  File "/opt/venv/lib/python3.9/site-packages/astroid/decorators.py", line 136, in raise_if_nothing_inferred
    yield next(generator)
  File "/opt/venv/lib/python3.9/site-packages/astroid/decorators.py", line 100, in wrapped
    res = next(generator)
  File "/opt/venv/lib/python3.9/site-packages/astroid/bases.py", line 146, in _infer_stmts
    for inferred in stmt.infer(context=context):
  File "/opt/venv/lib/python3.9/site-packages/astroid/node_classes.py", line 345, in infer
    results = tuple(self._explicit_inference(self, context, **kwargs))
  File "/opt/venv/lib/python3.9/site-packages/astroid/inference_tip.py", line 23, in _inference_tip_cached
    result = func(*args, **kwargs)
  File "/opt/venv/lib/python3.9/site-packages/pylint_django/transforms/foreignkey.py", line 96, in infer_key_classes
    MANAGER.ast_from_module_name(module_name)
  File "/opt/venv/lib/python3.9/site-packages/astroid/manager.py", line 213, in ast_from_module_name
    raise e
  File "/opt/venv/lib/python3.9/site-packages/astroid/manager.py", line 162, in ast_from_module_name
    found_spec = self.file_from_module_name(modname, context_file)
  File "/opt/venv/lib/python3.9/site-packages/astroid/manager.py", line 264, in file_from_module_name
    raise value.with_traceback(None)
astroid.exceptions.AstroidImportError: Failed to import module wagtailcore.models with error:
No module named wagtailcore.models.
@asadali145 asadali145 added Bug Something isn't working Blocked and removed Bug Something isn't working labels Dec 6, 2023
@asadali145
Copy link
Contributor Author

Blocked by #2830

But we can start using the wagtail upgrade branch asad/wagtail-upgrade

@asadali145
Copy link
Contributor Author

asadali145 commented Apr 5, 2024

We have disabled D401 by adding it to the ignores list in pyproject.toml. We will be fixing the docstrings in a followup PR later.

CC: @arslanashraf7

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

Successfully merging a pull request may close this issue.

1 participant