3 ms·
> In the case that the third party code does in fact always return no empty lists of positive numbers, the author might just type it as a list. Yes - but as I
by lmm 6y ago
> In the case that the third party code does in fact always return no empty lists of positive numbers, the author might just type it as a list.
Yes - but as I said, you can be confident that the list type is accurate, and if you want to convert that list to a specific-length list type then you're nudged towards doing it in a way where you handle the case where the list isn't actually the length you specified.
> And by the List[str] bit, I mean you can annotate it as doing whatever it in fact does. You aren’t protected if you get that wrong, of course
Not "of course"; the whole point of a type system is that it's automatically checked and therefore you can have reasonable confidence in the types you're given.
- 6gvONxR4sf7o 6y ago> You aren’t protected if you get that wrong, of course, and that’s where things like stubs come in to help.
- lmm 6y agoThey don't really though? Stubs are just as unchecked as writing the type signature yourself, so even if they're correct at a given point in time, they'll tend to become incorrect for subsequent releases of the libraries they cover.