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

Stephen J. Turnbull stephen at xemacs.org
Fri Aug 15 07:46:10 CEST 2014


It was written:

 > a static type check that prevents it being used that way.

Can we please refrain from using the word "prevent" in this thread?

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?  If somebody else does the checking and believes the function is
properly prepared for those usages, they should prepare an RFE (*not*
a bug report! -- Ms. Author will have to recheck that the code works
as claimed in the more general context, and perhaps fix bugs to ensure
that it does work to *her* standards for code *she* distributes).



More information about the Python-ideas mailing list