You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cattrs 1.7.0 fails to import _LiteralGenericAlias on Python 3.9.0 #150
These classes weren't introduced with the first release of Python 3.9.0 but with Python 3.9.1. See comparison between Python 3.9.0 and 3.9.1: python/cpython@v3.9.0...v3.9.1
File \"mycode.py\", line 7, in <module>
import cattr
File \"venv/lib/python3.9/site-packages/cattr/__init__.py\", line 1, in <module>
from .converters import Converter, GenConverter, UnstructureStrategy
File \"venv/lib/python3.9/site-packages/cattr/converters.py\", line 10, in <module>
from ._compat import (
File \"venv/lib/python3.9/site-packages/cattr/_compat.py\", line 191, in <module>
from typing import (
ImportError: cannot import name '_LiteralGenericAlias' from 'typing' (/usr/lib/python3.9/typing.py)
Because of that also importing the _LiteralGenericAlias class is failing:
from typing_extensions import _LiteralGenericAlias
ImportError: cannot import name '_LiteralGenericAlias' from 'typing_extensions' (/workspace/venv/lib/python3.9/site-packages/typing_extensions.py)
I took a look at the internal implementation of the module, but it looks like there are several implementations of the Literal alias. In the interest of simplicity I'll just change it so literals don't work if they aren't present in typing.
I took a look at the internal implementation of the module, but it looks like there are several implementations of the Literal alias. In the interest of simplicity I'll just change it so literals don't work if they aren't present in typing.
Very nice! Do you plan a bugfix release like 1.7.1 for that fix or will the change be part of the next upcoming release?
Activity
Tinche commentedon May 27, 2021
Bleh, you have to be kidding me.
Ok, I need to conditionally import this :/
Tinche commentedon May 27, 2021
@ferraith Can you import
_LiteralGenericAliasfromtyping_extensionsif you pip install it? We could fall back to that.ferraith commentedon May 27, 2021
@Tinche
I installed typing_extensions==3.10.0.0
Successfully installed typing-extensions-3.10.0.0But if you have a look in the typing_extensions module there is no
_LiteralGenericAlias. Only aLiteralclass is available:https://github.com/python/typing/blob/3.10.0.0/typing_extensions/src_py3/typing_extensions.py
Because of that also importing the
_LiteralGenericAliasclass is failing:Tinche commentedon May 27, 2021
I took a look at the internal implementation of the module, but it looks like there are several implementations of the
Literalalias. In the interest of simplicity I'll just change it so literals don't work if they aren't present intyping.ferraith commentedon May 27, 2021
Very nice! Do you plan a bugfix release like 1.7.1 for that fix or will the change be part of the next upcoming release?
Tinche commentedon May 27, 2021
I can put out a hotfix tonight!
ferraith commentedon May 27, 2021
@Tinche A hotfix would be excellent. Thanks a lot for your work!
Tinche commentedon May 28, 2021
I pushed a fix to master, can you install from git and verify it works for you? I can release then.
ferraith commentedon May 28, 2021
@Tinche I tested your fix in my Python 3.9.0 environment and the import is now working like expected. Thanks for that fix!
Tinche commentedon May 28, 2021
1.7.1 released!
chore(deps): update cattrs requirement from <1.10,>=1.8 to >=1.8,<1.1…