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

python 3.13.0rc3 and collections.abc #10000

Closed
stanislavlevin opened this issue Oct 3, 2024 · 15 comments · Fixed by pylint-dev/astroid#2598
Closed

python 3.13.0rc3 and collections.abc #10000

stanislavlevin opened this issue Oct 3, 2024 · 15 comments · Fixed by pylint-dev/astroid#2598
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable python 3.13
Milestone

Comments

@stanislavlevin
Copy link
Contributor

stanislavlevin commented Oct 3, 2024

Bug description

False positive error of missing name in collections.abc.
For example linting over the code:

from collections.abc import MutableMapping

reports:

No name 'MutableMapping' in module 'collections.abc' (no-name-in-module)

This error started with updating Python from 3.13.0rc2 to 3.13.0rc3.
Most likely caused by python/cpython#124735

Command used

pylint

Pylint output

No name 'MutableMapping' in module 'collections.abc' (no-name-in-module)

Expected behavior

No error

Pylint version

Python 3.13.0rc3
astroid-3.3.4
pylint-3.3.1

@stanislavlevin stanislavlevin added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 3, 2024
@julian-smith-artifex-com
Copy link

julian-smith-artifex-com commented Oct 3, 2024

I've just seen almost exactly the same problem today, with from collections.abc import Sequence.

On a Github Ubuntu machine and local Devuan machine.

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code python 3.13 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 3, 2024
@nitzmahone
Copy link

nitzmahone commented Oct 4, 2024

Yep, it looks like the static analysis can't follow the runtime-swap-a-dee-doo that's now happening when collections.abc loads. That's a gnarly one...

@jacobtylerwalls
Copy link
Member

Fixed in astroid 3.3.5 if anyone needs this right away.

@nitzmahone
Copy link

Yep, works for us now- thanks for the quick fix and release!

haukex added a commit to haukex/unzipwalk that referenced this issue Oct 6, 2024
@cavo789
Copy link

cavo789 commented Nov 12, 2024

Hello

I got the same (I think) i.e. I'm using f.i. Callable (from typing import Callable) and pylint ask to replace by collections.abc.Callable but that module seems to not exists.

I'm using a Docker base image Python 3.13.0.

Pylint seems to be up to date (i've fired pip install --upgrade), can you guide me please?

What should I do to be able to respect suggestions from pylint?

Thanks!

@Pierre-Sassoulas
Copy link
Member

collections.abc.Callable but that module seems to not exists.

Not sure what the problem is but I think it exists since python 3.9 ; https://docs.python.org/3.9/library/collections.abc.html#collections.abc.Callable (also in 3.13 : https://docs.python.org/3.13/library/collections.abc.html#collections.abc.Callable)

@jacobtylerwalls
Copy link
Member

What is your version of astroid? You would need 3.3.5 to get this fix. There has not yet been a patch release of pylint to enforce that.

@cavo789
Copy link

cavo789 commented Nov 12, 2024

So fast, thanks !

Ok so perhaps my editor is incorrectly configured.

Vscode throws that error while editing my .py script. I should admit that i've trust him (not fired the script in my console, will do tomorrow).

I got the error for Callable and for Sequence too...

If it helps, i'm using a .pylintrc file and start pylint in my console.

Thanks for any suggestions...

@cavo789
Copy link

cavo789 commented Nov 12, 2024

What is your version of astroid? You would need 3.3.5 to get this fix. There has not yet been a patch release of pylint to enforce that.

Oh sorry i'm in a train (back to home) and was trying to find ressources so I can continue on this tomorrow...

I'm not sure about the version of astroid (will check tomorrow) and more didn't know what astroid is (i'm a junior in python's world).

I'm using python 3.13.0 (docker image) and i've installed pylint days ago with pip install pylint.

@Pierre-Sassoulas
Copy link
Member

Try doing something like pip install astroid -U on pip (i.e. upgrade astroid to 3.3.5 explicitly)

@cavo789
Copy link

cavo789 commented Nov 13, 2024

Hi all

Here is my current configuration:

> /usr/local/bin/python3 --version

Python 3.13.0
> pylint --version

pylint 3.3.1
astroid 3.3.5
Python 3.13.0 (main, Nov 12 2024, 02:27:08) [GCC 12.2.0]

(just to be sure, I've well fired pip install astroid -U; no change)

By running pylint on the command line here is some errors I got:

************* Module core.Entity
src/core/Entity.py:238:30: W6001: 'typing.Callable' is deprecated, use 'collections.abc.Callable' instead (deprecated-typing-alias)
src/core/Entity.py:303:33: W6001: 'typing.Callable' is deprecated, use 'collections.abc.Callable' instead (deprecated-typing-alias)

Then, I edit that file and replace from typing import Callable .

My trouble comes from VSCode:

Image

I'm using the latest version of Pylint addon i.e. v2024.1.13171016 (last updated: 2024-11-13, 08:01:24).

Perhaps a setting in VSCode; I'll search in that direction.

@cavo789
Copy link

cavo789 commented Nov 13, 2024

Solved. It was well a setting to add in my vscode settings.json file : "pylint.args": [ "--rcfile /app/.config/.pylintrc"] i.e. the path to my configuration file and where I've set the minimum version of Python with that line py-version = 3.13.0.

Thanks for the support guys!

thozza added a commit to thozza/osbuild that referenced this issue Nov 20, 2024
Update pylint to the latest upstream version, to fix a false positive
with Python 3.13, that was resolved in `astroid` dependency in version
`3.3.5`. In order to update the dependency, the `pylint` version itself
needs to be bumped to at least version `3.0.0`.

The error was:
test/run/test_stages.py:21:0: E0611: No name 'Mapping' in module 'collections.abc' (no-name-in-module)

More details: pylint-dev/pylint#10000

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
thozza added a commit to thozza/osbuild that referenced this issue Nov 20, 2024
Update pylint to the latest upstream version, to fix a false positive
with Python 3.13, that was resolved in `astroid` dependency in version
`3.3.5`. In order to update the dependency, the `pylint` version itself
needs to be bumped to at least version `3.0.0`.

The error was:
test/run/test_stages.py:21:0: E0611: No name 'Mapping' in module 'collections.abc' (no-name-in-module)

More details: pylint-dev/pylint#10000

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
thozza added a commit to thozza/osbuild that referenced this issue Nov 21, 2024
Update pylint to the latest upstream version, to fix a false positive
with Python 3.13, that was resolved in `astroid` dependency in version
`3.3.5`. In order to update the dependency, the `pylint` version itself
needs to be bumped to at least version `3.0.0`.

The error was:
test/run/test_stages.py:21:0: E0611: No name 'Mapping' in module 'collections.abc' (no-name-in-module)

More details: pylint-dev/pylint#10000

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
thozza added a commit to thozza/osbuild that referenced this issue Nov 21, 2024
Update pylint to the latest upstream version, to fix a false positive
with Python 3.13, that was resolved in `astroid` dependency in version
`3.3.5`. In order to update the dependency, the `pylint` version itself
needs to be bumped to at least version `3.0.0`.

The error was:
test/run/test_stages.py:21:0: E0611: No name 'Mapping' in module 'collections.abc' (no-name-in-module)

More details: pylint-dev/pylint#10000

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
thozza added a commit to thozza/osbuild that referenced this issue Nov 22, 2024
Update pylint to the latest upstream version, to fix a false positive
with Python 3.13, that was resolved in `astroid` dependency in version
`3.3.5`. In order to update the dependency, the `pylint` version itself
needs to be bumped to at least version `3.0.0`.

The error was:
test/run/test_stages.py:21:0: E0611: No name 'Mapping' in module 'collections.abc' (no-name-in-module)

More details: pylint-dev/pylint#10000

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
thozza added a commit to thozza/osbuild that referenced this issue Nov 22, 2024
Update pylint to the latest upstream version, to fix a false positive
with Python 3.13, that was resolved in `astroid` dependency in version
`3.3.5`. In order to update the dependency, the `pylint` version itself
needs to be bumped to at least version `3.0.0`.

The error was:
test/run/test_stages.py:21:0: E0611: No name 'Mapping' in module 'collections.abc' (no-name-in-module)

More details: pylint-dev/pylint#10000

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
mvo5 pushed a commit to osbuild/osbuild that referenced this issue Nov 25, 2024
Update pylint to the latest upstream version, to fix a false positive
with Python 3.13, that was resolved in `astroid` dependency in version
`3.3.5`. In order to update the dependency, the `pylint` version itself
needs to be bumped to at least version `3.0.0`.

The error was:
test/run/test_stages.py:21:0: E0611: No name 'Mapping' in module 'collections.abc' (no-name-in-module)

More details: pylint-dev/pylint#10000

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
nemacysts added a commit to nemacysts/python-telegram-bot that referenced this issue Dec 4, 2024
Without this change, running `pre-commit` inside a Python 3.13 venv
results in errors as described in pylint-dev/pylint#10000

e.g.:
```
************* Module telegram._bot
telegram/_bot.py:26:0: E0611: No name 'Sequence' in module 'collections.abc' (no-name-in-module)
```

Bumping this hook required ignoring a new check added in pylint 3.3.0:
`too-many-positional-arguments` as there's a significant amount of
violations and picking a value for `--max-positional-arguments` seems
non-trivial as there are functions with 80+ args (e.g.,
`Message::__init__()` in `telegram/_message.py`)
ccwienk added a commit to gardener/cc-utils that referenced this issue Dec 5, 2024
ccwienk added a commit to gardener/cc-utils that referenced this issue Dec 5, 2024
@antoni-szych-rtbhouse
Copy link

antoni-szych-rtbhouse commented Dec 5, 2024

Seems like it stopped working in 3.13.1 (Release date: 2024-12-03) again :(

public repo jobs:
✅ python 3.13.0, pylint (3.3.2), astroid (3.3.5): https://github.com/rtbhouse-apps/rtbhouse-python-sdk/actions/runs/12123430319/job/33798902493
❌ python 3.13.1, pylint (3.3.2), astroid (3.3.5): https://github.com/rtbhouse-apps/rtbhouse-python-sdk/actions/runs/12171673933/job/33949004704

rtbhouse_sdk/client.py:6:0: E0401: Unable to import 'collections.abc' (import-error)

python changelog shows 2 collections-related changes:

@hofrob
Copy link
Contributor

hofrob commented Dec 16, 2024

Can confirm that something changed in 3.13.1.

  • python 3.13.1
  • astroid==3.3.6
import astroid
ast = astroid.MANAGER.ast_from_string("from collections import abc")
import_node = list(ast.get_children())[0]
import_node.do_import_module("collections").import_module("abc", relative_only=True)

I'm doing some custom linting and now I have to set relative_only=False only for the collections package. Since I don't fully understand what this flag does, I might just be doing this incorrectly though 😬

@jacobtylerwalls
Copy link
Member

Yep, we're tracking the new problem in #10112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable python 3.13
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants