[Python-ideas] Proposal: Use mypy syntax for function annotations

Antoine Pitrou antoine at python.org
Thu Aug 14 16:20:44 CEST 2014


Hi,

So a couple more comments:

- there seems to be no detailed description of mypy's typing.py.  There 
are some docstrings in the module but they don't really explain the 
intended semantics of using those types (and, most importantly, 
combining and extending them). Or is the tutorial the description?

- mypy is a young module; is it actually proven on real-world codebases? 
if a PEP gets written, typing.py should be proposed on the "provisional" 
basis as described in PEP 411

- for the two reasons above I would expect a PEP to spell out and 
somehow motivate the typing semantics (by "typing" I do not mean the 
actual algorithm of a type checker, but the semantics of combining types 
and the mechanisms for extension), rather than defer to third-party docs 
and source code

- many discussion topics seems to revolve around the syntax for 
declarations; besides syntactic sugar for declarations, though, there 
should probably be a hook to describe typing in a more programmatic way, 
especially when parametric types ("generic"?) are involved. I can't 
think of an example, so I realize this comment may not be very helpful 
(!), but I'm sure we'll hit the limits of what declarative syntax can 
give us, especially once people try it out on non-trivial code bases. Do 
such hooks already exist?

- the typing module apparently has its own brand of generic functions 
(with multiple dispatch?). Are they actually necessary for typing 
declarations and type inference? If so, it would be nice if this could 
be unified with functools.singledispatch, or at least put in the 
functools namespace, and sufficiently similar API-wise that it doesn't 
stand out.

- it would be nice if the PEP could discuss at least a little bit the 
performance expectations of using the type system, and if there are 
design decisions that can have a (positive or negative) performance 
impact on the algorithms using it. I realize this is not top-priority 
for the linting use case, but it's still important (especially for 
linting large code bases, which is one of the proclaimed use cases).

(this reminds me how annoyed I am at the slowness of Sphinx on non-small 
reST docs)

Regards

Antoine.




More information about the Python-ideas mailing list