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 <levkivs...@gmail.com> wrote:
> 
> Could you please give some examples for these statements? They still look to 
> abstract for me.

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to