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

Unable to import 'collections.abc' using python 3.13.1 #10112

Open
Christian-B opened this issue Dec 6, 2024 · 19 comments · Fixed by pylint-dev/astroid#2647
Open

Unable to import 'collections.abc' using python 3.13.1 #10112

Christian-B opened this issue Dec 6, 2024 · 19 comments · Fixed by pylint-dev/astroid#2647
Labels
Bug 🪲 High priority Issue with more than 10 reactions
Milestone

Comments

@Christian-B
Copy link

Christian-B commented Dec 6, 2024

Bug description

import collections.abc

Configuration

Command used

We use a complex github actions but notice the change when python updated to 3.13.1
using pylint-3.3.2

Pylint output

************* Module spinn_utilities.checker
spinn_utilities/checker.py:1:0: C0304: Final newline missing (missing-final-newline)
spinn_utilities/checker.py:1:0: E0401: Unable to import 'collections.abc' (import-error)
spinn_utilities/checker.py:1:0: W0611: Unused import collections.abc (unused-import)

Expected behavior

Not seeing the Unable to import 'collections.abc' (import-error)

Other messages are due to the tiny example

likely due to
python/cpython@d46d291

Pylint version

Python 3.13.1

Did not happen with 
Python 3.13.0

OS / Environment

tested with github actions using
Ubuntu
22.04.5
LTS

Additional dependencies

@jacobtylerwalls
Copy link
Member

Thanks, we'll jump on this 👍

@jacobtylerwalls jacobtylerwalls added Bug 🪲 High priority Issue with more than 10 reactions and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Dec 7, 2024
@jacobtylerwalls
Copy link
Member

Reopening to keep visibility until we bump astroid later today.

@jacobtylerwalls
Copy link
Member

Polling other contributors, can anyone reproduce this locally? @zenlyj @mbyrnepr2

@mbyrnepr2
Copy link
Member

LGTM @jacobtylerwalls

(venv3131) markbyrne@Marks-MacBook-Air-2 programming % python -m pylint --version
pylint 4.0.0-dev0
astroid 3.3.6
Python 3.13.1 (v3.13.1:06714517797, Dec  3 2024, 14:00:22) [Clang 15.0.0 (clang-1500.3.9.4)]
(venv3131) markbyrne@Marks-MacBook-Air-2 programming % cat x.py
import collections.abc
(venv3131) markbyrne@Marks-MacBook-Air-2 programming % python -V
Python 3.13.1
(venv3131) markbyrne@Marks-MacBook-Air-2 programming % python -m pylint x.py
************* Module x
x.py:1:0: C0114: Missing module docstring (missing-module-docstring)
x.py:1:0: W0611: Unused import collections.abc (unused-import)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

(venv3131) markbyrne@Marks-MacBook-Air-2 programming % 

@zenlyj
Copy link
Contributor

zenlyj commented Dec 9, 2024

reproducible on my end

import.py:1:0: E0401: Unable to import 'collections.abc' (import-error)
import.py:1:0: W0611: Unused import collections.abc (unused-import)

with the following:

pylint 4.0.0-dev0 (latest main)
astroid 3.3.5 & 3.3.6
Python 3.13.1

@jacobtylerwalls
Copy link
Member

Thanks. By chance is anyone testing on linux locally? If it wasn't clear, I have doubts that astroid 3.3.6 fixed anything.

@Pierre-Sassoulas
Copy link
Member

I have linux but didn't find an easy way to install 3.13.1 yet.

@zenlyj
Copy link
Contributor

zenlyj commented Dec 9, 2024

i got the error testing with astroid 3.3.6

environment is WSL2, Ubuntu 20.04.6 LTS if it helps

@Torom
Copy link

Torom commented Dec 9, 2024

Here you can see my failed GitHub action due to the error: https://github.com/Torom/BotLi/actions/runs/12241011421/job/34145142509

Python 3.13.1
astroid-3.3.6
dill-0.3.9
isort-5.13.2
mccabe-0.7.0
platformdirs-4.3.6
pylint-3.3.2
tomlkit-0.13.2

@jacobtylerwalls
Copy link
Member

Thanks, our own actions are failing too, however I'm doubtful we can work on it until we have a contributor who can debug it locally.

@Torom
Copy link

Torom commented Dec 9, 2024

I have linux but didn't find an easy way to install 3.13.1 yet.

With https://github.com/pyenv/pyenv it is very easy to install any Python version, including 3.13.1.

@Pierre-Sassoulas
Copy link
Member

Thank you @Torom ! I managed to fix my issue with uv self update (then 3.13.1 is available)

@Pierre-Sassoulas
Copy link
Member

All right, I can reproduce the collections.abc issue locally. On main:

pylint 4.0.0-dev0
astroid 3.3.5
Python 3.13.1 (main, Dec  6 2024, 18:40:43) [Clang 18.1.8 ]

Switching to dependabot/pip/astroid-3.3.6 I also reproduce with:

pylint 4.0.0-dev0
astroid 3.3.6
Python 3.13.1 (main, Dec  6 2024, 18:40:43) [Clang 18.1.8 ]

I'm wondering if the race condition fixed in the initial issue is bypassing our astroid brain mechanism, but this is just intuition. Let me know if there's any particular test/debug I could do Jacob, I'll be able to dig into this in ~= 20 hours.

@jacobtylerwalls
Copy link
Member

Wonderful. I'd sniff around do_import_module(), maybe see if turning use_cache off helps? And also play with reverting the 3.3.6 change.

vhaldemar added a commit to yandex-cloud/yandex-cloud-ml-sdk that referenced this issue Dec 10, 2024
vhaldemar added a commit to yandex-cloud/yandex-cloud-ml-sdk that referenced this issue Dec 10, 2024
@Pierre-Sassoulas
Copy link
Member

I dug a little, it seems there's just no working finders (or meta finder) at all in _find_spec_with_path and we ends up hitting the ImportError from the last line:

https://github.com/pylint-dev/astroid/blob/ef33d0d7c6d3ecda0cbeb1a69d24f8b57cff6885/astroid/interpreter/_import/spec.py#L426

Image

Not sure when / if the brain should take over before that or not.

@jacobtylerwalls
Copy link
Member

Watch out, did you test collection.abc not collections.abc?

@Pierre-Sassoulas
Copy link
Member

heavy sigh hmm.. yes 😄 But basically the same thing is happening with the correct import..Image

@andy-maier
Copy link

andy-maier commented Dec 12, 2024

Just in case it helps, here is when it happens for one of our projects, all from https://github.com/zhmcclient/python-zhmcclient/actions/runs/12216477009

OS                          Python  pylint  astroid  Issue occurs 
-----------------------------------------------------------------
Ubuntu 22.04.5              3.13.1  3.3.2   3.3.5    Yes           
MacOS 14.7.1                3.13.0  3.3.2   3.3.5    No            
Windows Server 10.0.20348   3.13.1  3.3.2   3.3.5    Yes           

When re-running the failed jobs today, it used astroid 3.3.6, and the results are:

OS                          Python  pylint  astroid  Issue occurs 
-----------------------------------------------------------------
Ubuntu 22.04.5              3.13.1  3.3.2   3.3.6    Yes           
Windows Server 10.0.20348   3.13.1  3.3.2   3.3.6    Yes           

On my local macOS, I have Python 3.13.0 (latest from Homebrew) so I cannot reproduce it there.

@andy-maier
Copy link

andy-maier commented Dec 12, 2024

The change in Python 3.13.1 is that collections.abc no longer has a module file abc.py like it did up to 3.13.0 (e.g. https://github.com/python/cpython/blob/v3.13.0/Lib/collections/abc.py), but creates the module dynamically: https://github.com/python/cpython/blob/v3.13.1/Lib/collections/__init__.py#L29

Update: It seems I am a bit behind compared to what you already discovered. Please ignore the noise :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 High priority Issue with more than 10 reactions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants