In article <c1d9c448-31b0-4bbc-8c6f-5194678a6...@googlegroups.com>, 
sohcahto...@gmail.com says...
> 
> >       def myfunction(arg1, arg2):
> >       """
> >       Normal docstring...
> >       @typehint: (str, int) -> bool
> >       """ 
> >           return True 
> > 
> 
> I really like that implementation.
> 
> Its unobtrusive and doesn't clutter the function definition, and
> putting in the docstring makes it get colored like a comment (At
> least, with my IDE setup it does) so it is easily ignored by my eyes
> as I'm scrolling through.

It has the side effect of being included in __doc__. A purist may have 
an issue with that, since type hinting, for the purposes of static 
analysis, should have no place in that attribute.

But you could always fall back to the previous version:

       def myfunction(arg1, arg2):
       """
       Normal docstring...
       """
       "@typehint: (str, int) -> bool"
           return True 

And __doc__ would be free of it. It would be up to the user to choose.

For something completely different, I like @hint: better than @typehint:
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to