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

fix: import failure on Python >=3.10 #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lucasew
Copy link

@lucasew lucasew commented Apr 10, 2022

My worry is that this breaks backward compatibility because the typing module was added on Python 3.5 [1], so it would only work on Python 3.5 and above.

We realized this because the nixpkgs CI [2] fails to package this library to be used by other dependents. It's not that a huge problem because basically all of the stuff depends on the version based on Python 3.9, that works fine [3].

[1] https://docs.python.org/3/library/typing.html

[2] https://hydra.nixos.org/job/nixpkgs/trunk/python310Packages.fn.x86_64-linux

[3] https://hydra.nixos.org/job/nixpkgs/trunk/python39Packages.fn.x86_64-linux

Closes #91 #86

@ftsfranklin
Copy link

Duplicate of #87, which has better compatibility.

typing.Iterable is just a generic fork of collections.abc.Iterable, and was deprecated in 3.9.

This one should work for newer Python versions, while not breaking compatibility with older ones:

try:
    from collections.abc import Iterable
except ImportError:  # py < 3.3
    from collections import Iterable

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

Successfully merging this pull request may close these issues.

ImportError: cannot import name Iterable from collections on Python 3.10
2 participants