[docs] Document recen changes in typing.py (issue 28644)

levkivskyi at gmail.com levkivskyi at gmail.com
Thu Nov 10 08:59:14 EST 2016


Reviewers: gvanrossum,


http://bugs.python.org/review/28644/diff/19105/Doc/library/typing.rst
File Doc/library/typing.rst (right):

http://bugs.python.org/review/28644/diff/19105/Doc/library/typing.rst#newcode444
Doc/library/typing.rst:444: .. class:: Tuple
On 2016/11/09 17:39:42, gvanrossum wrote:
> I'm not sure I'm comfortable advertising Tuple as a class. While
`class
> C(Tuple): pass` works, using `class C(Tuple[int, int]): pass` elicits
the error
> (from mypy) "error: Tuple[...] not supported as a base class outside a
stub
> file".

Everything else in docs is systematized by the actual implementation. I
am marking this simply as :data: (under your responsibility :-) if
someone will complain).

Actually, I think subclassing is also a way of annotating types.
Subclassing Tuple[int, str] means that the class supports a certain
"API". mypy already supports ``class C(Tuple[int, str]): ...`` this way
in stub files.

It looks like mypy rejects this for normal files only because of
previous limitations of typing.py. If I just remove the check, it also
works in normal files as well. Also, it looks like Jukka likes allowing
this, so that I will make a PR for mypy soon.



Please review this at http://bugs.python.org/review/28644/

Affected files:
  Doc/library/typing.rst




More information about the docs mailing list