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

Invalid import of OrderedDict from collections.abc #766

Open
kelvins opened this issue Jan 8, 2020 · 2 comments
Open

Invalid import of OrderedDict from collections.abc #766

kelvins opened this issue Jan 8, 2020 · 2 comments
Labels

Comments

@kelvins
Copy link

kelvins commented Jan 8, 2020

OrderedDict should be imported from collections instead of collections.abc.

For example:

try:
from collections.abc import OrderedDict, MutableMapping
except ImportError:
# TODO Remove this to drop Python2 support
from collections import OrderedDict, MutableMapping

When trying to import it gives the following error:

>>> from collections.abc import OrderedDict
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'OrderedDict' from 'collections.abc'

I have manually tested it on Python versions: 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8.

The current code is not failing because of the try-except.

For tracking purposes, this change was made on PR #732 and is related to issue #727.

Can I submit a PR to solve this issue?

@kelvins kelvins added the bug label Jan 8, 2020
@Colin-b
Copy link
Contributor

Colin-b commented Jan 8, 2020

Indeed you are right, OrderedDict is not an abstract base class and is not within collections.abc as stated in python documentation. I can also submit a PR to fix my initial mistake.

@kelvins
Copy link
Author

kelvins commented Jan 10, 2020

Thanks for the comment @Colin-b, I would like to submit a PR to solve this issue as my first contribution to the project, if you don't mind!? 😁

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

No branches or pull requests

2 participants