Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python type hinting #117

Closed
jmakov opened this issue Mar 29, 2016 · 3 comments
Closed

Python type hinting #117

jmakov opened this issue Mar 29, 2016 · 3 comments

Comments

@jmakov
Copy link

jmakov commented Mar 29, 2016

Hi,

In the python style guide the part on comments only mention that the types should be described. However it doesn't mention the capability to declare types in docstrings e.g.
"""Args: my_house (lib.base.House): my new house """
Would adding type hinting break google style guide?

@gpshead
Copy link
Contributor

gpshead commented Mar 29, 2016

Authors are free to describe types however they want after the arg_name: that the code reviewer agrees with as being consistent within the file or library. Putting it before the : is not desirable as that would break pylint warnings about the contents of the Args: section. (Probably only in our internal pylint? I'm not sure at the moment if we have released that Google style docstring pylint checker) For example:

  Args:
      my_house: (lib.base.House) my new house.

We'll be adopting official Python PEP484 type annotation syntax in the future. It is not docstring based.

Docstrings are meant for human consumption, please keep them readable for us humans. :)

@jmakov
Copy link
Author

jmakov commented Mar 29, 2016

Ok, that helps and even answers the question. Thanks for the quick response!

@jmakov jmakov closed this as completed Mar 29, 2016
@gpshead
Copy link
Contributor

gpshead commented Mar 31, 2016

FYI, if you want a pylint plugin for Google Python style docstrings, the Chromium project has one:
https://chromium.googlesource.com/chromiumos/chromite/+/master/cli/cros/lint.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants