On Tue, Nov 30, 2021 at 8:19 PM Paul Moore <p.f.mo...@gmail.com> wrote:
> 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
>

My understanding is that it's precisely as wrong, or not wrong, as this:

def add(x, y):
   """Multiply two numbers"""
    return x / y

To my mind, annotations are machine-readable metadata, with no
inherent "correctness" to them (from the language's point of view),
other than syntactically.

ChrisA
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/54VRD5SJ3RQT6W4AX5WPIW2OUWZNWPZO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to