-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Integrate flake8_rst into ./ci/code_check.sh #23381
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
Conversation
Added flake8-rst as development dependency Added flake8-rst configuration Added checks to code_checks.sh Signed-off-by: Fabian Haase <[email protected]>
Signed-off-by: Fabian Haase <[email protected]>
Signed-off-by: Fabian Haase <[email protected]>
cookbook.rst:971 -> python of .. code-block:: deleted to disable flake8-rst checks. %timeit is invalid Syntax, # noqa: E999 does not have an effect. Signed-off-by: Fabian Haase <[email protected]>
Signed-off-by: Fabian Haase <[email protected]>
readding F401 detection Signed-off-by: Fabian Haase <[email protected]>
# Conflicts: # ci/code_checks.sh
Hello @FHaase! Thanks for submitting the PR.
|
adding flake8-rst to travis-36.yaml reverting changes to requirements-optional-pip.txt pytables seems to be tables on PyPI [running ./scripts/convert_deps.py previously changed it] Signed-off-by: Fabian Haase <[email protected]>
421577e
to
77df97f
Compare
Codecov Report
@@ Coverage Diff @@
## master #23381 +/- ##
=======================================
Coverage 92.25% 92.25%
=======================================
Files 161 161
Lines 51262 51262
=======================================
Hits 47292 47292
Misses 3970 3970
Continue to review full report at Codecov.
|
If this gets merged, an issue should be created for this. |
Really nice work, thank you for it. But I don't think this is really validating the docstrings, just the rst files. We surely have plenty of pep8 errors in docstrings that are not detected here. Besides that, in #23154, the goal was to validate pep8 of docstrings from Happy to merge this, but let's remove the "Closes #23154" from the description, and let's create the issues for the pep8 errors being ignored as @gfyoung says. Also, can't check well from my phone, but when adding flake8-rst to the dependencies, there are some files that are automatically generated. Did you edit them manually, or did you run @jorisvandenbossche, @WillAyd, if you can also take a look here. |
Okay let me summarize what I did:
What does flake8-rst do?
Does it find everything?
Regarding integration in Why do I think it closes #23154 ? |
3624260
to
ee36f34
Compare
@datapythonista
Is that what you had in mind? |
As I said, I was happy to merge the PR as it was. Just, we can't close the issue you referenced yet, as there is more to do. If you can add those new changes in a separate PR I can give you more precise feedback. But summarizing, Besides that, I don't like using subprocess. I guess flake8-rst is a Python program, so we should be able to import it and call the appropriate functions. In any case, validating the docstrings is for another PR, as it's independent of checking the code blocks. |
31fb4dd
to
77df97f
Compare
doc/source/basics.rst
Outdated
@@ -302,23 +302,17 @@ To evaluate single-element pandas objects in a boolean context, use the method | |||
|
|||
.. warning:: | |||
|
|||
You might be tempted to do the following: | |||
Using a DataFrame as a condition will raise errors, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the point of changing this? We always ask changes to have one focus to keep diff minimal. Would prefer if you could back out anything unrelated to the flake8 and do in a separate PR
Signed-off-by: Fabian Haase <[email protected]>
doc/source/basics.rst
Outdated
|
||
These will both raise errors, as you are trying to compare multiple values. | ||
|
||
.. code-block:: python | ||
.. code-block:: console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does python-traceback
render here? Might be a better choice than console
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 didn't know that directive.
doc/source/basics.rst
Outdated
|
||
Or | ||
|
||
.. code-block:: python | ||
|
||
>>> df and df2 | ||
>>> df and df2 # noqa: E999 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally what kind of E999 errors are you getting? Not terribly familiar with this code but seems to come as a result of AST issues, but am wondering if that's more of a Python versioning issue than an actual styling violation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the and
tricked me into thinking it was an if-statement like a couple of lines above.
@@ -189,31 +189,34 @@ infinitive verb. | |||
|
|||
.. code-block:: python | |||
|
|||
def astype(dtype): | |||
def astype(dtype): # noqa: F811 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the noqa
needed for the first definition? Would ideally like to minimize if not eliminate the commented exceptions as I could imagine a scenario where it is confusing to first time contributors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At that position no, I went for symmetry. Indeed using noqa
is quite confusing and therefore I try to avoid it.
@WillAyd At this position I thought putting every method in an extra .. code-block:: would be the best option, however it changes the documentation quite signifikant?!
|
||
Any other module used in the examples must be explicitly imported, one per line (as | ||
recommended in `PEP-8 <https://www.python.org/dev/peps/pep-0008/#imports>`_) | ||
recommended in :pep:`8#imports`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this directive always work or does it require an external plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its integrated directly in sphinx
doc/source/contributing.rst
Outdated
@@ -744,15 +744,15 @@ Transitioning to ``pytest`` | |||
.. code-block:: python | |||
|
|||
class TestReallyCoolFeature(object): | |||
.... | |||
.... # noqa: E999 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WillAyd Would you prefer a pass
instead of the noqa
?
Signed-off-by: Fabian Haase <[email protected]>
Signed-off-by: Fabian Haase <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice work. I'd possibly use pass
instead of the ...
everywhere, but just a preference.
Looking forward to have all these fixes merged, and to start validating pep8 in docstrings.
Btw, if you have rendered the output of the pep
directive and you can add a screenshot of it, would be nice, I don't know how that is being rendered.
doesn't seem like the rendering is correct, is it? I guess what's expected is that the text shown is Sorry if I'm misunderstanding. |
I'd rather use the
|
thanks for the clarification, if that's the case all good. @WillAyd can you take a look and merge if you're happy? |
Before merging I'd like to change two more things:
I'm just waiting for any more suggestions to not trigger ci-builds. [skip ci] seems to not work with circle ci and azure pipeline. |
I wouldn't worry that much about the CI, and I'd leave the PR in a state that you're happy and it can be merged. |
Okay can merge if wanted |
@WillAyd can you take another look, and merge on green if you're happy. Thanks @FHaase for the work on this, really nice PR. If you want to create two issues for the errors you're ignoring, that would be nice. I'm sure you'll be better than me at explaining what are the problems. You can mention this PR, and mention me too if you want. |
Signed-off-by: Fabian Haase <[email protected]>
403cc95
to
816f26e
Compare
@datapythonista note this will slightly conflict with your revision of ci deps (need to add the new package) |
no problem, I can update the other two PRs, their CI is still waiting, so it's a good time |
@FHaase can you fix the conflicts please? Sorry this wasn't merged before. |
@datapythonista No Problem. Currently fixing issues within the docs getting covered by an updated flake8-rst. Is it possible to add a PR that builds on an unmerged PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Thanks @FHaase, nice work. It's great to have all those issues fixed, and validation in the rst files. |
git diff upstream/master -u -- "*.py" | flake8 --diff
Integrated flake8-rst into
code_check.sh
in order to check code in .. code-blocks:: python directives