-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
Back-end code style discussion #2307
Comments
@noliveleger, @joshuaberetta, @JacquelineMorrissette, this kind of stuff seems obsolete now that there's type hinting:
Has anybody seen Python 3 docstring guidance that they like? |
What about going back to old way def method(param1: str, param2: list) -> bool:
"""
Description of the method
:param param1: Description for param1
:param param2: Description for param2
:return: Description for return (useless in that case)
"""
value = False
...
return value
|
Does the |
It looks like the I can't say I have a preference for any docstring guides. |
I think I lean more this way. After looking at a couple big projects that use annotations, most of them don't include that boilerplate and rather just have a description and maybe something about what's returned. Some also include what kind of error response could be expected which is nice. So something more like: def method(something: str) -> bool:
"""
Return True if `something` is equal to 'nothing'
"""
return something == 'nothing' |
The boilerplate is used by IDEs to explain each parameter. Modern IDEs do not only use 70% of your memory for nothing. They are capable of such things :-D Ok, Let's remove the boilerplate, use human readable description. |
😂
My poor laptop struggles enough with the VM running and a browser open that I can barely open anything else 💀 Sometimes even vim struggles 😂 |
Updated description; closed; unpinned |
Current approach
Use type hinting and write docstrings that are helpful to humans. From discussion below:
Outdated
Internal discussion: https://chat.kobotoolbox.org/#narrow/stream/4-KoBo-Dev/topic/Python.20coding.20style
Let's use this type of documentation going forward:…and let's update existing code as we're able.
According to https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html,
The text was updated successfully, but these errors were encountered: