question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use typing.Generic with pytypes

See original GitHub issue

Using 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:closed
  • Created 4 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
udimcommented, Oct 11, 2019

It works on master.

0reactions
Steworicommented, Oct 27, 2019

Also consider My[type(1)](1) or My[pytypes.deep_type(1)](1) to assess the type in more dynamic fashion.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found