Andrew Barnert writes:
On Thursday, August 14, 2014 10:46 PM, Stephen J. Turnbull
wrote:
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.
Hardly.
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.
But who decides it *should* be perfectly valid code? *Somebody* has to check that, and if code is used naively in a case where it shouldn't be (cf the "why doesn't sum() handle iter_of_str" thread!), the user is screwed again. Have you never written code that was perfectly sound for your purpose, but could be used in other contexts according to ducktyping? Are you *sure* that it is valid in those other contexts? (Think sum vs. math.fsum -- accuracy matters.) Of course it's a matter of balance, and *maybe* it tips more in the direction of "default to the most general type where the code will run without crashing or raising". I'm just saying it's not obvious to me that it's such a bad thing that one-off piece of junk libraries may not be as re-abusable if you use a type checker as they are when you don't.