[Python-ideas] Proposal: Use mypy syntax for function annotations

Steven D'Aprano steve at pearwood.info
Mon Aug 25 02:51:31 CEST 2014


On Sun, Aug 24, 2014 at 04:59:02PM -0700, Ethan Furman wrote:

> 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.  If static checking is only 
> available at the top level I think a lot of power/usefulness is gone.

That's entirely up to Mypy or whatever linter, compiler, editor or other 
tool being used, and has nothing to do with this proposal, which is only 
to standardize on the syntax. I would expect different static tools 
would have different levels of ability to deal with dynamically created 
classes like that.



-- 
Steven


More information about the Python-ideas mailing list