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

[PKG SUPPORT] pylint <3 and Python 3.12 #641

Closed
valeriupredoi opened this issue Oct 18, 2023 · 26 comments · Fixed by #642
Closed

[PKG SUPPORT] pylint <3 and Python 3.12 #641

valeriupredoi opened this issue Oct 18, 2023 · 26 comments · Fixed by #642
Milestone

Comments

@valeriupredoi
Copy link
Collaborator

Hey fellas, a quick touching base from one of your conda-feedstock maintainers here - the new v1.10.3 builds well now conda-forge/prospector-feedstock#43 - but I had to pin upper pylint to <3, see failed test with pylint=3 - and since I vaguely understand poetry environment files, I wanted to double check pylint is upper pinned to <3 upstream (here) too. Incidentally, Python 3.12 support seems to work fine for you, so I'd suggest you included a Github Action test for 3.12 as well (seen you guys have them all Pythons but no 3.12 GA test yet). Cheers and keep up the good work 🍺

@carlio
Copy link
Member

carlio commented Oct 18, 2023

Hi there, thank you for the report, I will add it to my TODO list along with pylint-dev/pylint-django#405
to handle some small changes needed to support the pylint3 release

@valeriupredoi
Copy link
Collaborator Author

Good man, Carl! Cheers 🍺

@ryancausey
Copy link

Is there anything I can do to help resolve this? I'm still running into the issue originally noted in #651.

@Pierre-Sassoulas
Copy link
Collaborator

The pipeline is broken on main, there's a potential fix in #658, you can review that, or propose another approach. Then #645 is addressing this issue directly and could be merged after a rebase.

@ryancausey
Copy link

#658 seems like a reasonable workaround to get 3.12 support out the door, but I'm also not an expert in prospector or pyroma. Assuming there are other pyroma tests in the suite, there should be some confidence that it doesn't actually break prospector's integration with pyroma.

@valeriupredoi
Copy link
Collaborator Author

@ryancausey cheers, mate! That's what my take is too - also, one clue is that workaround in #658 is needed only for when tests run on Github Actions, local tests run fine without it - beats me what changes in the file that the test runs on GA, but I suspect that's just a minor change like a trailing white space or some newline char, that gets picked up by the pyroma test

@ryancausey
Copy link

#658 seems like a reasonable workaround to get 3.12 support out the door, but I'm also not an expert in prospector or pyroma. Assuming there are other pyroma tests in the suite, there should be some confidence that it doesn't actually break prospector's integration with pyroma.

@Pierre-Sassoulas was my review above of any use?

@ryancausey
Copy link

Anything more I can do to help move this along?

@carlio
Copy link
Member

carlio commented Jun 3, 2024

Sorry that I have been absent for a while, I will try to get onto this in the next few days...

@valeriupredoi
Copy link
Collaborator Author

very happy to see you back @carlio - we was getting concerned 🍺

@robertalexa
Copy link

hey @carlio, any status update on this?

@ryancausey
Copy link

@carlio anything I can do to help move this along?

wmfgerrit pushed a commit to wikimedia/operations-software-netbox-extras that referenced this issue Aug 8, 2024
CI image now supports Python 3.12, which revealed an incompatibility
with Prospector.
prospector-dev/prospector#641

Change-Id: I3d434bc46ad8e30a4a7c3cbec153b43405dbbcc7
@ryancausey
Copy link

Sorry to ask again, but @carlio is there anything I can do to help resolve this? Prospector is currently the only dependency blocking me from moving a lot of projects to Python 3.12.

@nfelt14
Copy link

nfelt14 commented Sep 17, 2024

Sorry to ask again, but @carlio is there anything I can do to help resolve this? Prospector is currently the only dependency blocking me from moving a lot of projects to Python 3.12.

I am in the same boat. Any updates on this?

@robertalexa
Copy link

Hey @Pierre-Sassoulas , is this something that can be picked up by another contributor in @carlio 's absence? Or is there any perspective/ETA on this? Should the community start looking for alternatives? Thanks

@Pierre-Sassoulas
Copy link
Collaborator

As far as I remember the blocker is a review for #658 where I don't have enough knowledge in prospector to decide if this is the right way to fix the pipeline or not. After that a lot of pipeline will be able to be rebased and merged/upgraded once the pipeline is green.

@Pierre-Sassoulas
Copy link
Collaborator

The new blocker for pylint 3.0+ is requirements detector that is incompatible with it because it requires astroid between 2 and 3 and pylint requires astroid 3+.

This MR needs to be merged and released: prospector-dev/requirements-detector#49, and I can't do it

@sbrunner
Copy link
Member

sbrunner commented Oct 4, 2024

@Pierre-Sassoulas Thanks for the release, it makes Prospector compatible with Python 3.12

@robertalexa
Copy link

Hi @Pierre-Sassoulas

Thank you for giving it your best to get this moving along!

Went and done some testing at my end this morning, now on python 3.12 and prospector on 1.11.0 without being fully successful.

A full on error on astroid, but i suppose that is related to your statements around astroid, as well as false positives relating to native django. In the case of those files, they are not even explicitly importing those files. But i guess that may also have been dealt with in pylint 3.

I guess now we wait again.

REDACTED_PATH.py
  Line: 1
    pylint: astroid-error / /REDACTED_PATH.py: Fatal error while checking '/REDACTED_PATH'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/home/REDACTED/.cache/pylint/pylint-crash-2024-10-04-10-03-12.txt'.
    pylint: ungrouped-imports / Imports from package django are not grouped
    pylint: wrong-import-order / third party import "from django.conf import settings" should be placed before "from app.REDACTED import REDACTED"
    pylint: wrong-import-position / Import "from django.conf import settings" should be placed at the top of the module
  Line: 3
    pylint: ungrouped-imports / Imports from package app are not grouped
    pylint: wrong-import-position / Import "from app.REDACTED import REDACTED" should be placed at the top of the module

@Pierre-Sassoulas
Copy link
Collaborator

Hey @robertalexa do you mind showing the content of /home/REDACTED/.cache/pylint/pylint-crash-2024-10-04-10-03-12.txt, please ? (At least the traceback without the code)

@robertalexa
Copy link

Hi @Pierre-Sassoulas

See below traceback. I have omitted the code completely, but if this becomes mandatory i will do my best to provide a non-sensitive version of it.

Thanks for the effort you are putting in to support us with this transition!

pylint crashed with a AstroidError and with the following stacktrace:

Traceback (most recent call last):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/checkers/utils.py", line 1390, in safe_infer
    value = next(infer_gen)
            ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/inference.py", line 334, in infer_import_from
    module = self.do_import_module()
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/builder.py", line 169, in _post_build
    self.delayed_assattr(delayed)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/builder.py", line 240, in delayed_assattr
    for inferred in node.expr.infer():
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/inference.py", line 1162, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/protocols.py", line 412, in _arguments_infer_argname
    is_metaclass = isinstance(cls, nodes.ClassDef) and cls.type == "metaclass"
                                                       ^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1874, in _class_type
    if _is_metaclass(klass):
       ^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1845, in _is_metaclass
    for baseobj in base.infer():
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/inference.py", line 358, in infer_attribute
    for owner in self.expr.infer(context):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/inference.py", line 341, in infer_import_from
    stmts = module.getattr(name, ignore_locals=module is self.root())
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 414, in getattr
    result = [self.import_module(name, relative_only=True)]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/builder.py", line 169, in _post_build
    self.delayed_assattr(delayed)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/builder.py", line 240, in delayed_assattr
    for inferred in node.expr.infer():
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/inference.py", line 1162, in infer_assign
    stmts = list(self.assigned_stmts(context=context))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/protocols.py", line 412, in _arguments_infer_argname
    is_metaclass = isinstance(cls, nodes.ClassDef) and cls.type == "metaclass"
                                                       ^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1874, in _class_type
    if _is_metaclass(klass):
       ^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1845, in _is_metaclass
    for baseobj in base.infer():
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/inference.py", line 431, in infer_subscript
    for value in self.value.infer(context):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/inference.py", line 334, in infer_import_from
    module = self.do_import_module()
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/builder.py", line 144, in file_build
    module, builder = self._data_build(data, modname, path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/builder.py", line 204, in _data_build
    module = builder.visit_module(node, modname, node_file, package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/rebuilder.py", line 254, in visit_module
    [self.visit(child, newnode) for child in node.body],
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/rebuilder.py", line 609, in visit
    visit_method = getattr(self, visit_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TreeRebuilder' object has no attribute 'visit_typealias'

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

Traceback (most recent call last):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 811, in _lint_file
    check_astroid_module(module)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1085, in check_astroid_module
    retval = self._check_astroid_module(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1135, in _check_astroid_module
    walker.walk(node)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 1528, in visit_assign
    self._append_context_managers_to_stack(node)
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 1583, in _append_context_managers_to_stack
    inferred = utils.safe_infer(value.func)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/checkers/utils.py", line 1394, in safe_infer
    raise AstroidError from e
astroid.exceptions.AstroidError

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

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

@Pierre-Sassoulas
Copy link
Collaborator

Ha ! pip only finds a match for pylint < 3 for python 3.12 (2.17.7) because there's a problem with pylint metadata. We assume astroid is going to be usable with next version of python interpreter because it's often the case, but in this case there's actually a fix to do that is only in pylint 3.0. So we do need #671 to be merged and a new release of prospector to be made.

@robertalexa
Copy link

@Pierre-Sassoulas I've been keeping an eye on the activity here and I have now tried the new 1.12.0 release, and there still seem to be some issues, at least when running on django

REDACTED@4d9d48d81f89:/opt/REDACTED$ prospector --version
prospector 1.12.0

REDACTED@4d9d48d81f89:/opt/REDACTED$ prospector
Traceback (most recent call last):
  File "/home/REDACTED/.local/bin/prospector", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/prospector/run.py", line 198, in main
    prospector.execute()
  File "/home/REDACTED/.local/lib/python3.12/site-packages/prospector/run.py", line 73, in execute
    for tool in self.config.get_tools(found_files):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/prospector/config/__init__.py", line 68, in get_tools
    config_result = tool.configure(self, found_files)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/prospector/tools/pylint/__init__.py", line 114, in configure
    config_messages, configured_by = self._get_pylint_configuration(
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/prospector/tools/pylint/__init__.py", line 173, in _get_pylint_configuration
    config_messages = self._prospector_configure(prospector_config, linter)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/prospector/tools/pylint/__init__.py", line 39, in _prospector_configure
    linter.load_plugin_modules(["pylint_django"])
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 378, in load_plugin_modules
    module = astroid.modutils.load_module_from_name(modname)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/REDACTED/.local/lib/python3.12/site-packages/astroid/modutils.py", line 182, in load_module_from_name
    module = importlib.import_module(dotted_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint_django/__init__.py", line 6, in <module>
    from pylint_django import plugin
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint_django/plugin.py", line 9, in <module>
    from pylint_django.checkers import register_checkers
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint_django/checkers/__init__.py", line 2, in <module>
    from pylint_django.checkers.auth_user import AuthUserChecker
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint_django/checkers/auth_user.py", line 7, in <module>
    class AuthUserChecker(checkers.BaseChecker):
  File "/home/REDACTED/.local/lib/python3.12/site-packages/pylint_django/checkers/auth_user.py", line 8, in AuthUserChecker
    __implements__ = (interfaces.IAstroidChecker,)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pylint.interfaces' has no attribute 'IAstroidChecker'

It now fatally crashes straight away, but still related to AstroidChecker.

Any thoughts?

@Pierre-Sassoulas
Copy link
Collaborator

This is due to pylint-django see pylint-dev/pylint-django#432. Carlio gave me permissions to take decisions regarding dropping interpreter in pylint-django so I might fix that next.

@carlio
Copy link
Member

carlio commented Oct 8, 2024 via email

@Pierre-Sassoulas
Copy link
Collaborator

I think this is unfixable until pylint-django has a release compatible with python 3.12. pylint-django is incompatible with pylint 3+ / astroid 3+ (still uses the old __implements__ pylint-dev/pylint#8404) and pylint 2.x / astroid 2.X is incompatible with python 3.12 so it's not possible to downgrade astorid either.

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