-
Notifications
You must be signed in to change notification settings - Fork 189
D403 has a very simplistic definition of word #167
Comments
I think the first case is worth breaking.
(I'd also argue that functions should have a single responsibility but whatever. ;P) The other could also be rewritten with I think this rule will make your docstrings better if they're all like this. If you have other examples, I'd be interested in seeing those. |
As I indicated in the opening issue description, I am not disputing the docstrings can be better, and this change has highlighted some cases which should be improved, especially to benefit people with ESL. I raised this to ensure we're happy the current code is implementing PEP 257 and not unintentionally over-reaching. A lot is being read into the PEP 257 phrase:
I can't see anything else in PEP 257 which relates to this new rule. Did I miss something? You can see the full list of our errors on the linked task: https://phabricator.wikimedia.org/T121365 . Another interesting one is:
-> D403: First word of the first line should be properly capitalized ('Setup', not 'SetUp') Again I repeat, I'm not opposing this recommendation; switching to 'Setup' is certainly doable, but I can see people arguing that it has slightly more meaning when the capitalisation is 'SetUp'. @sigmavirus24 , fwiw, in your own github3.py, there is a very similar case. In fact, it is the most common error that this change will cause, with the following occurring eight (8) times:
Again I would call this a corner case. The all-caps GET gives the reader more meaning. I expect you also would be happier with better docstrings for those. Pywikibot has lots of docstrings starting with The question to consider is whether those docstrings are sufficiently legal that they shouldn't be an error. As with any new rules, there will be people complaining, and they will complain more fervently after a release so it is better to assess corner cases before the release to ensure the released solution is optimal and defensible. Is there a list of large projects which use pep257 rather strictly, that we can use to assess the impact of new rules? |
Eh, github3.py already fails with pep257. I don't disagree that there will be corner cases, I just don't know if they'll be worth the hassle of adding work-arounds for them beyond allowing people to silence D403. Another large project using pep257 (by way of flake8-docstrings) is keystone and other OpenStack projects are beginning to adopt that flake8 plugin as well. |
keystone has two normal errors, and one interesting one
That 'should' be something like "Do LDAP initialisation..." , but that change wouldnt aid understanding at all; it would be a change purely to bypass the pep257 rule. git-review has one error, and it is quite interesting as "SSH" is IMO a very appropriate action word to begin the docstring.
It could be changed to something like: "Run command on the Gerrit server over a new SSH connection." |
So I will both agree and disagree. I agree because as a large and broad technical community (of which I've only experienced the English language portion) we absolutely do use SSH as a verb. This has everything to do with So I agree, to a tool that only cares about English grammar (in spite of the fact that the English language has no such verb), SSH is a verb. How many other similar cases can we come up with to make this generalizable enough to hack around in pep257. |
How about making |
Also, regarding the interpretation of PEP 257, I got an answer from Guido by mail:
|
Just some more analysis on a range of projects I have local checkouts of, not necessarily all sync'd up. I notice that django and python-future (not users of pep257...) is also abusing the docstring, prefixing it with I'm seeing quite a few cases, especially in docutils and epydoc, of the one-liner being gcloud uses a Only one error in coveragepy:
One error in cyordereddict
oauth2client has four errors:
oauth-dropins mentions the project name as the first word.
python-mcollective has four errors:
|
Please see #170. |
#170 improves the situation a lot but there are still some cases that are problematic. For example, |
@SamiHiltunen, I suspect those should probably be rewritten with an action word as the first word. e.g. """OAuth login function.""" could be """Perform OAuth login.""". I'm not sure how """OpenID implementation.""" should be updated to start with an action word. However if you want to exclude specific errors on specific lines, https://github.com/jayvdb/flake8-putty might be a solution. Rather than ignoring this error for specific docstrings, it might be useful to have a configuration variable of whitelisted words that can be used at the beginning of a docstring. One case that needs rethinking (possibly improvement to the PEP) is the docstring of properties. It is very common for the docstring of the getter to describe the value and not start with "Return ...". fwiw, I am happy for this issue to be closed now that D403 has been released with #170, as more specific issues will be created for remaining corner cases. |
I've put the Pywikibot code through the new D403 rule from #164 (love it!), and it has turned up a lot of errors for cases where we have been liberal about the pep257 phrase/command first-liner.
Results can be seen at https://phabricator.wikimedia.org/T121365
Many great errors for us to improve, and two where pep257 is probably being too strict/simplistic are:
-> D403: First word of the first line should be properly capitalized ('Create/edit', not 'Create/Edit')
-> D403: First word of the first line should be properly capitalized ('(un)protect', not '(Un)protect')
(This error message is interesting...)
We can and will improve our docstrings due to this rule, and can live with the current simplistic split and capitalize approach by amending the above docstrings and others to be simpler.
However if there is interest in pep257 handling corner cases like those, we should collect them and determine which are able to be reasonably resolved without undue complexity.
The text was updated successfully, but these errors were encountered: