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.10 Import error with collections #27

Closed
dwsmith1983 opened this issue Oct 28, 2021 · 5 comments
Closed

Python 3.10 Import error with collections #27

dwsmith1983 opened this issue Oct 28, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@dwsmith1983
Copy link
Collaborator

dwsmith1983 commented Oct 28, 2021

With Python 3.10, we encounter an import error related to collections.

Similar issues:
rmartin16/qbittorrent-api#45
carbonblack/cbapi-python#298

[ImportError]
cannot import name 'Mapping' from 'collections' (/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/collections/__init__.py)

From this issue, they found an issue with

*rmartin Feb 2021
AttrDict finally broke with Python 3.10 since abstract base classes can no
longer be imported from collections but should use collections.abc instead.
Since AttrDict is abandoned, I've consolidated the code here for future use.
AttrMap and AttrDefault are left for posterity but commented out.
"""

from abc import ABCMeta
from abc import abstractmethod
from re import match as re_match

try:  # python 3
    from collections.abc import Mapping
    from collections.abc import MutableMapping
    from collections.abc import Sequence
except ImportError:  # python 2
    from collections import Mapping
    from collections import MutableMapping
    from collections import Sequence
@dwsmith1983 dwsmith1983 added the bug Something isn't working label Oct 28, 2021
@zifeo
Copy link
Owner

zifeo commented Oct 28, 2021

@dwsmith1983 I pushed an update of the deps in #28 and tested locally with python 3.10. It seems to work... Let's see.

@dwsmith1983
Copy link
Collaborator Author

dwsmith1983 commented Oct 28, 2021

@zifeo it happens during build. Did you test building locally on 3.10? Also, strange it just started to occur now when it was fine for the previous releases

@zifeo
Copy link
Owner

zifeo commented Oct 28, 2021

@dwsmith1983 yes, I can even publish without issue. I will investigate, this is curious

zifeo added a commit that referenced this issue Oct 28, 2021
@zifeo
Copy link
Owner

zifeo commented Oct 28, 2021

Root issue looks to be python-poetry/poetry#1733, downgrading to 3.8 or 3.9 should do the job.

@pirofti
Copy link

pirofti commented Apr 1, 2022

I have also ran into this issue and decided to fix this and release it on PyPI as AttrDict3. Feel free to use it or open issues on the forked repository. After install, you should not have to modify anything in your code-base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants