A very rough implementation:
typing.py:
class _GenericMetaNoop(type):
def __getitem__(self, params):
return self
class _GenericNoop(metaclass=_GenericMetaNoop)
pass
GenericStub = Generic if TYPE_CHECKING else _GenericNoop
elsewhere.py:
import typing
T = typing.TypeVar('T')
class MyClass(typing.GenericStub[T]):
pass
Now when run under type checkers MyClass will inherit typing.Generic with all
runtime complexity.
However when run outside of them code will just work.
> On Nov 30, 2017, at 1:35 PM, Ivan Levkivskyi <[email protected]> wrote:
>
> Could you please give some examples for these statements? They still look to
> abstract for me.
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/