I forget to add python-ideas@python.orgmailto:python-ideas@python.org in CC, let me retell to the others:
I mean real check by the interpreter, not an '__annotations__' attribute.
And I just had a look, mypy is a static checker, without actually running the code.
My thought is modifying CALL_FUNCTION and RETURN_VALUE of the interpreter, so that allow them to check in each function calling when option enalbed.
Cite a case:
def fun(a: str, b: int) -> int:
return len(a) + b
fun('arg1', 'arg2')
Whit the option and run this code, the interpreter will give an error prompt:
Type of argument b is wrong. (or something like this)
This is very useful for development and debugging.
Without the option, the interpreter just ignores Type Hints in runtime, so no performance lose in project's final deploy.
IMO, this will maximize the benefit of Type Hints within a small cost.
在 7-8 周五 14:42, David Mertz 写道:
This exists already. All the annotations love on the '__annotations__' attribute is a function or method. Check that at runtime however you like!
On Jul 7, 2016 11:39 PM, "Ma Lin"