-
Notifications
You must be signed in to change notification settings - Fork 187
Check __doc__ assignments #185
Comments
It would be a nightmare to parse and understand assignments. Since we're not importing the code, we would only be able to deal with extremely basic cases. Do you have a use case which justifies this? |
My idea was that it was the extremely basic cases where pydocstyle can require that the I guess the crux of this issue is whether pydocstyle considers Then the question is whether it is useful to allow |
This case would just generate a "Missing Docstring" error, which seems enough to me - it will point you in the right direction. |
Why not import the code? It seems like it would solve the parsing issues? We have such a use case. We have many function/method pairs, where the method docstring is identical to that of the function (but |
Executing the code could have side-effects. Even importing and not executing the code can have side effects. There are a few alternatives that might work for your scenario. Is your reoo public so I can look for viable options? |
The decorator is here (which is quite a few lines): https://github.com/mne-tools/mne-python/blob/master/mne/utils.py#L860 But we also do things like I don't think it's reasonable to have
I'm not proposing to execute the code, but rather do some AFAIK other widely used introspection tools like IPython and Spyder get the docstrings this way (they at least parse our wacky docstrings properly), so there is at least some reasonable precedent for doing it this way without too horrible of side effects.
This is true, it can, but my guess is the number of repos that suffer from this issue is quite small. What if it were made optional via |
What exactly do you think happens when you use
Neither of those are static analysis tools (which is what pydocstyle is). They're both tools (REPL/Environment/what have you) that are already running Python code and already have users import your project. That's not how users tend to expect a tool like pydocstyle to work. Further, that just adds to our runtime because importing one file, as I'm sure you're aware, can lead to importing other files just through that one file's |
Yes it executes code. By this I mean that it's a simple implementation to make via import methods, as opposed to manually parsing
I hadn't considered that. It sounds like you find the disadvantages of dynamic analysis not to be worth it, which is fine. But why not allow users the ability to opt into it? For devs with dynamic docstrings, the ~100 ms or so to import the package (especially when the
Hmm, I'm not sure. I for one expected |
Note that what I'm talking about would also take care of things like #163, so @sigmavirus24 I suspect this functionality would be more useful than you give it credit for. |
No #163 is asking to use pydocstyle like a library as in "Here's a docstring. Analyze it for me"
Okay, I should rephrase. People who're familiar with tools like eslint, rubocop, pylint, mccabe, pyflakes, pycodestyle, flake8, bandit, etc. all are not expecting their code to be executed.
Because someone still has to maintain it. The current maintainers of this project don't have that kind of time and so it seems best to avoid the complexity until there are people who can afford to deal with the bugs this would cause. |
First of all, def foo():
return
foo.__doc__ = "Do foo." ... is not readable, which is the purpose of coding conventions to begin with. Obviously there are cases where assigning with As I said, |
Is it worth checking runtime assignments to
__doc__
?One obscure case which could be an error is explicit setting of
__doc__
to a literal where an implicit docstring would suffice.The text was updated successfully, but these errors were encountered: