Cannot use typing.Generic with pytypes
See original GitHub issueUsing pytypes 1.0b5:
Python 3.7.3rc1 (default, Mar 13 2019, 11:01:15)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing
>>> import pytypes
>>> class PCollection(typing.Generic[typing.TypeVar('T')]):
... pass
...
>>> PCollection()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/google/home/ehudm/virtualenvs/beam-py37/lib/python3.7/site-packages/pytypes/__init__.py", line 567, in __Generic__new__
if cls.__origin__ is None:
AttributeError: type object 'PCollection' has no attribute '__origin__'
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Use of Generic and TypeVar - python - Stack Overflow
A typing.Generic represents the scoping of types, specifically to class scope. Notably, it is possible to use TypeVar without Generic ...
Read more >Type variables bounded by generic types cannot be used with ...
PEP 484 and typing docs currently allow only a class, a union of classes, and Any as arguments for Type[] and explicitly prohibit...
Read more >Generics - mypy 0.991 documentation
Generic types have one or more type parameters, which can be arbitrary types. ... TypeError: Type List cannot be instantiated; use list() instead....
Read more >typing — Support for type hints — Python 3.11.1 documentation
This module provides runtime support for type hints. The most fundamental support consists of the types Any , Union , Callable , TypeVar...
Read more >Documentation - Generics - TypeScript
Types which take parameters. ... This allows us to use our generic type variable Type as part of the types we're working with,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It works on master.
Also consider
My[type(1)](1)
orMy[pytypes.deep_type(1)](1)
to assess the type in more dynamic fashion.