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

Sunjay Varma varma.sunjay at gmail.com
Thu Aug 14 21:21:59 CEST 2014


Frankly, I'd just really like to get all of this noise out of the function
declaration. Any reasonable, readable and consistent documentation format
is fine with me. I chose the sphinx format because it is already well
supported in pycharm and that was mentioned in the first few responses.

I actually don't like the colon syntax very much (it's awkward and
unnatural to type), so if anyone has a different suggestion I'd be very
open to that.

Mainly I want to ensure that Python doesn't sacrifice readability and line
length (which is part of readability) just because annotations are already
built in.

I suggest we decide on a standard format that can be used in documentation
strings and also used with type checking.

Let's enhance our documentation with types, not obfuscate function
declarations.

Sunjay
On Aug 14, 2014 3:14 PM, "Nathaniel Smith" <njs at pobox.com> wrote:

> On 14 Aug 2014 17:02, "Sunjay Varma" <varma.sunjay at gmail.com> wrote:
> > Here's a taste of what that looks like:
> >     class SimpleEquation(object):
> >
> >         def demo(self, a, b, c):
> >             """
> >             This function returns the product of a, b and c
> >             @type self: SimpleEquation
> >             :param a: int - The first number
> >             :param b: int
> >             :param c: int - The third number should not be zero and
> should also
> >                 only be -1 if you enjoy carrots (this comment spans 2
> lines)
> >             :return: int
> >             """
> >             return a * b * c
>
> There are at least three existing, popular, standardized syntaxes for
> these kinds of docstring annotations in use: plain ReST, Google's docstring
> standard, and numpy's docstring standard. All are supported by Sphinx out
> of the box. (The latter two require enabling the "napolean" extension, but
> this is literally a one line config file switch.)
>
> Would you suggest that python-dev should pick one of these and declare it
> to be the official standard, or...?
>
> -n
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140814/d7b8e013/attachment.html>


More information about the Python-ideas mailing list