diff options
author | kj <28750310+Fidget-Spinner@users.noreply.github.com> | 2020-11-01 18:13:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-01 18:13:38 (GMT) |
commit | 1f7dfb277e5b88cddc13e5024766be787a3e9127 (patch) | |
tree | 042580f940e32cb44182c0aafd31710610efa455 /Lib/typing.py | |
parent | 148c76b27ce3823ff7e3ccb1d3a6b4598ce9b35b (diff) | |
download | cpython-1f7dfb277e5b88cddc13e5024766be787a3e9127.zip cpython-1f7dfb277e5b88cddc13e5024766be787a3e9127.tar.gz cpython-1f7dfb277e5b88cddc13e5024766be787a3e9127.tar.bz2 |
bpo-42233: Correctly repr GenericAlias when used with typing module (GH-23081)
Noticed by @serhiy-storchaka in the bpo. `typing`'s types were not showing the parameterized generic.
Eg. previously:
```python
>>> typing.Union[dict[str, float], list[int]]
'typing.Union[dict, list]'
```
Now:
```python
>>> typing.Union[dict[str, float], list[int]]
'typing.Union[dict[str, float], list[int]]'
```
Automerge-Triggered-By: GH:gvanrossum
Diffstat (limited to 'Lib/typing.py')
-rw-r--r-- | Lib/typing.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index 0f457ab..3fa97a4 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -162,6 +162,8 @@ def _type_repr(obj): typically enough to uniquely identify a type. For everything else, we fall back on repr(obj). """ + if isinstance(obj, types.GenericAlias): + return repr(obj) if isinstance(obj, type): if obj.__module__ == 'builtins': return obj.__qualname__ |