[Python-ideas] Proposal: Use mypy syntax for function annotations
Antoine Pitrou
antoine at python.org
Mon Aug 25 02:24:27 CEST 2014
Le 24/08/2014 19:59, Ethan Furman a écrit :
>
> Is this workable? If I have a nested class in a function:
>
> def spam():
> class fribble:
> def __init__(self, x:int):
> blahblah
>
> I would expect MyPy to be able to retrieve and use the annotations from
> fribble without actually calling spam.
I don't know. But that's not really the point, because you are still
able to do, say:
my_type = some_invocation(...)
def spam():
class fribble:
def __init__(self, x: my_type):
blahblah
... as far as the type checker uses module imports, that is. Of course,
/after/ importing the module it can also walk the bytecode defined in
that module.
Regards
Antoine.
More information about the Python-ideas
mailing list