-
Notifications
You must be signed in to change notification settings - Fork 41
Usage question: short docstring vs full-docstring #26
Comments
That sounds reasonable, so long as it's not the default. It should be pretty easy to implement. I'll see what I can do (or if anyone else wants to tackle this, I can point them in the right spot to do it.) |
@terrencepreilly awesome! Thanks you. As soon as this feature will be implemented and released I will add your package to our project: https://github.com/wemake-services/wemake-python-styleguide |
@terrencepreilly I can help you with this task. Any guides about how to get started and where to look? Thanks! |
Sorry for the late response: I was in a place with no internet access this whole weekend. So you could make this change by editing a couple of files. First, you'd want to edit config.py to add the option as a configuration option, and also driver.py to add a command line flag. Once you've done that, there's a file called integrity_checker.py, which does all of the checks for errors. You'd want to add a guard around here to check for that configuration option and whether the docstring has only one line. That should handle it, I think. Let me know if you run into problems. |
Hi, @terrencepreilly! I am terribly sorry, but I don't have the time to work on this. RoadmapHere's the project roadmap:
I would really love to see Feature descriptionWe write a lot of docstrings. There are several types of them:
def some(arg: int) -> int:
"""This function does this and that."""
def other(arg: int) -> int:
"""
First line.
Description.
Examples:
>>> other(1)
2
>>> other(2)
3
"""
def __init__(
self,
tree: ast.AST,
file_tokens: Sequence[tokenize.TokenInfo],
filename: str = constants.STDIN,
) -> None:
"""
Creates new checker instance.
These parameter names should not be changed.
``flake8`` has special API that passes concrete parameters to
the plugins that ask for them.
``flake8`` also decides how to execute this plugin
based on its parameters. This one is executed once per module.
Parameters:
tree: ``ast`` parsed by ``flake8``.
Differs from ``ast.parse`` since it is mutated by multiple
``flake8`` plugins. Why mutated? Since it is really expensive
to copy all ``ast`` information in terms of memory.
file_tokens: ``tokenize.tokenize`` parsed file tokens.
filename: module file name, might be empty if piping is used.
""" So, I guess there might be a setting to allow certain level of details before checking actual docs.
These levels are sorted from the strictest to the mildest. Thanks for your wonderful work! 👍 Would be happy to include this plugin to our project. |
No problem. I just finished rewriting the parser, and was about to merge it in, so I was hesitant to make too many changes. I've got to do some regression testing and cleanup anyway, so I'll see if I can squeeze it in this week some time. |
Changed the strictness arguments to "short", "long", and "full", which should be a little easier to specify and test on the command line. Resolves: Issue #26
I've implemented this under the flag/configuration option, "strictness". You should be able to put
In your configuration to allow for one-line docstrings. (If the docstring has anything more than one line, it will be checked.) You can also specify it by the command-line argument,
There's a more complete description, as well as examples of how this changes the checking of docstrings, in the README, here. Let me know if it doesn't work, or if it's unexpected in some way. I'm going to freeze any other feature work until I've merged in the new parser. Resolved in v0.6.0 |
AWESOME! I would like to buy you a beer/pizza/coffee if that's possible. (paypal, opencollective, patreon, bitcoins, etc) You have saved so much time for me! Thanks a lot! 🤝 |
That's kind of you. I haven't set anything up: this is just a fun project. Maybe I will at some point in the future. |
Hi, thanks for this project! It is awesome!
My question is about two different modes of docstrings that I use in my apps.
I can either write a short one like:
Or full one like here:
Full source here: https://github.com/wemake-services/wemake-python-styleguide/blob/master/wemake_python_styleguide/violations/base.py
The problem is that I get an error from the short version:
What do I suggest? Allow short docstring (= docstrings without ANY arguments/returns/raises/etc declarations) or require to write a full one (in case ANY formatters are found).
It might be a configuration option turned off by default.
How does it sound to you?
The text was updated successfully, but these errors were encountered: