Skip to content

Import ABC from collections.abc for Python 3.10 compatibility #1023

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

Merged
merged 9 commits into from
May 17, 2022

Conversation

kabilar
Copy link
Contributor

@kabilar kabilar commented May 13, 2022

Fix #1015. Since there was an issue with the certs in pull request #1002, I have opened this pull request. If there is a better strategy, feel free to close this pull request. Thanks!

Copy link
Collaborator

@guzman-raphael guzman-raphael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kabilar. 👍 Could you just update the changelog/releaselog and the version?

Also, didn't check but would you verify if the collections import is used across all files and apply this there too? I can verify once I am near my machine too.

@guzman-raphael
Copy link
Collaborator

Supersedes #1002

@guzman-raphael
Copy link
Collaborator

guzman-raphael commented May 13, 2022

Thanks @kabilar. Just checked and looks like we'll need to update the usage of import collections in the following submodules:

  • blob.py
  • condition.py
  • schemas.py
  • settings.py
  • table.py

Could you also update the docs-parts/intro/Releases_lang1.rst to reflect your entry in CHANGELOG.md? We need to improve this but currently it is managed in 2 places. 😅

@kabilar
Copy link
Contributor Author

kabilar commented May 13, 2022

Thanks @guzman-raphael! Good catch. I have incorporated your suggestions above. I did not update the import in schemas.py since the abc module does not appear to be used there. Please let me know if I am mistaken.

@kabilar
Copy link
Contributor Author

kabilar commented May 13, 2022

And in settings.py, I added an additional collections.abc import statement since the defaultdict subclass is used in this submodule.

@CBroz1
Copy link
Contributor

CBroz1 commented May 13, 2022

Should we incorporate something like this to retain backwards compatibility?

import collections

try:
    collectionsAbc = collections.abc
except AttributeError:
    collectionsAbc = collections

@dimitri-yatsenko
Copy link
Member

@CBroz1 No, we don't need to be compatible to Python 2.7 because we never supported it. The current change is already compatible with all supporting versions of Python 3.*

Copy link
Collaborator

@guzman-raphael guzman-raphael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there was some confusion on my part and realized now that defaultdict is actually available at collections top-level. We can actually revert this then. Sorry about that.

kabilar and others added 2 commits May 13, 2022 16:58
Co-authored-by: Raphael Guzman <[email protected]>
Co-authored-by: Raphael Guzman <[email protected]>
@kabilar
Copy link
Contributor Author

kabilar commented May 13, 2022

Thanks @guzman-raphael. I have updated this pull request.

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.

Python 3.10 AttributeError: module 'collections' has no attribute 'Mapping'
4 participants