[Python-ideas] Type hints for text/binary data in Python 2+3 code
Guido van Rossum
guido at python.org
Tue Mar 22 13:58:15 EDT 2016
One thing I can do without committing to too much is to add a Text
type to typing.py. It would have no (defined) behavior but it could be
imported and used in annotations. Then mypy and other checkers could
start using it and we could even experiment with different proposals
without having to make more changes to typing.py (which we've found
are hard to push out, because it's in the 3.5 stdlib -- it's
provisional so we can change it, but we can't easily change what's
already in 3.5.0 or 3.5.1).
Should it be possible to subclass Text, and what should it mean?
Or perhaps at runtime (i.e. in typing.py) Text would just be an alias
for str in Python 3 and an alias for unicode in Python 2? That's
easiest.
More information about the Python-ideas
mailing list