[Python-ideas] Proposal: Use mypy syntax for function annotations
Andrew Barnert
abarnert at yahoo.com
Fri Aug 15 08:08:15 CEST 2014
On Thursday, August 14, 2014 10:46 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> I suggest instead
>
> a static type check that generates [scads of|tons of|way too many]
> [spurious|bogus|annoying] warnings when used that way.
>
> which is IMO a genuine concern but also probably has technological
> fixes like the one Andrew proposes (automatically promoting many
> container types to the ABC actually needed).
>
> In some sense I'm not really bothered by this (I'd be willing to omit
> all the bracketed phrases :-). If an upstream author writes
>
> def somefilter(l_of_s: List[str]) -> List[int]:
> pass
>
> I think it's reasonable to assume that Ms. U. S. Author didn't think
> about the implications of tuples or dictionary views or iterators or
> whatever. I personally think a warning here is a *good* thing: if
> Ms. Author didn't intend those usages, why should she have to check
> them?
You're forgetting that linting is not the only purpose of static type annotations in this proposal.
If you write what should be perfectly valid code and it spits out scads of warnings when linted, yes, you can quickly figure out that it's a bug in the library and report it upstream.
But if, say, your IDE doesn't suggest a function that it could have, you may never notice the problem, and just find the library to be less fun to use than you expected.
More information about the Python-ideas
mailing list