
On Tue, 30 Nov 2021 at 02:52, Steve Dower <steve.dower@python.org> wrote:
THAT'S the kind of thing that also has been happening with typing, and why some of us feel the need to publicly re-state things that are all agreed upon within this group, but are struggling to be heard over the public discourse on the topics. And this kind of reiteration is easier when our official documents (PEPs, etc.) state it explicitly.
This is very definitely the case. There's a subtle (maybe not so subtle, actually) and increasing pressure on projects to add typing. Often with little or no justification beyond "you should", as if having typing is a sort of "obvious best practice". Sometimes "because it will make it easier for your users who use typing" is given as a justification, but while that's fair, it's also a disturbing gradual pressure for typing to extend everywhere, manifesting by making it feel like not adding typing is somehow "not caring about your users". Also, related to the question Terry raised, IMO it would be useful to have a clear statement on code that *does* use type annotations, but violates them at runtime. To be specific, is the following considered as an error?
def muladd(x: int, y: int, z: int) -> int: ... return x * (y+z) ... muladd(3.1459, 87.33, 2.7e2) 1124.124447
If (as in the current interpreter) typing is optional, this isn't an error. Certainly, running mypy over it fails, but the point here is that mypy is an external tool - the Python interpreter itself (and the language definition) allows it. I think it would be useful to have a clear message that this is intended, and won't be altered lightly. Remember that the "correct" annotation here is either muladd(x: Any, y: Any, z: Any) -> Any, or muladd(x: SomeMultiplyProtocol, y: SomeAddProtocol, z: SomeAddProtocol) -> Any, neither of which is particularly helpful... Paul