-
Notifications
You must be signed in to change notification settings - Fork 187
D401 implementation is very naive #68
Comments
I have found this rule useful, but perhaps it should not apply to properties. All other method docstrings should be imperative (and I can't really think of any false positives), but property docstrings are typically not going to be imperative unless you do something like "Get the value of...". |
Actually, this might read better as |
I found another good example of a false positive: Perhaps |
A whitelist would be unmaintainable in my opinion @jacebrowning |
It could be interesting to investigate using NLTK (http://www.nltk.org/) here, although that would almost certainly be massive overkill. |
I asked about this in English StackExchange: http://english.stackexchange.com/questions/216043/telling-if-a-word-is-a-verb-in-the-imperative-mood |
This could be fixed by listing imperative forms of verbs and comparing with, say, a Porter stemmer (assuming English). If the stemmed form of the word is in the stemmed list of verbs, then it's probably a verb. But if the unstemmed form is not in the unstemmed list, it's not in the imperative form. This would have a much lower false positive rate than the current heuristic, but a somewhat larger false negative rate, depending on the size of the word list. But I'm guessing that relatively small lists of verbs would cover a high percentage of docstrings, due to the constrained nature of the language used (outside of domain-specific jargon). We could generate a reasonably good word list by scanning docstrings of a few largish Python projects and manually removing words that are not imperative verbs. |
Also it's out of scope to do a full grammar analysis, so we could never detect imperative or not in a docstring like
We could only flag up words that are verbs but not in an imperative form. |
I started scanning my codebase for the verbs we use here. We could also add a blacklist approach - there are words that are very much indicators of non-imperative docstrings. |
Use a stemmer and word list to check for imperative mood in a number of common verbs. Also use a blacklist of words that indicate a phrase not in imperative mood. PyCQA#68
Can this issue be closed, now #235 is merged? |
I think this issue should be reopened as #235 does not seem to affect the general case where a method decorated with |
Large neural network language models such as GPT-3 open up completely new possibilities to check if a sentence is in imperative mode. Maybe this should be added to this project. I don think this would impair productivity even more than attempting to check if docstrings are in imperative to begin with. |
I'd also support reopening this. Imperative mood checking is a very promising feature but enforcing it for |
I would too. Or at least allow "The" or "A" for them. |
Please open a new issue if you think D401 should not apply to * But I would argue it should because if you allow a noun phrase for the getter what do you write in the docstring for a setter or a deleter? |
You don’t write docstring for them :) |
I've started a new thread: #566. |
I have the following docstring.
The error is
While the intent is noble, I think that the current implementation is not helpful.
Is there anyone using this check in production code?
If a check could not be done, I prefer to not try to automate it as it is not fun to maintain a list of ignored values..
Thanks!
The text was updated successfully, but these errors were encountered: