Skip to content

DOC: Fix flake8 issues in doc/source/enhancingperf.rst #24176

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

Closed
datapythonista opened this issue Dec 9, 2018 · 11 comments · Fixed by #24772
Closed

DOC: Fix flake8 issues in doc/source/enhancingperf.rst #24176

datapythonista opened this issue Dec 9, 2018 · 11 comments · Fixed by #24772

Comments

@datapythonista
Copy link
Member

We didn't start validating the format of PEP8 and other code standards in the documentation examples until recently. We still have some files with errors, that we need to skip, and that we should fix, so we can start validating them.

The first step of this issue would be edit setup.cfg in the pandas home, and in the flake8-rst section, remove from the exclude list the file doc/source/enhancingperf.rst

After that, running the next command will report the errors in the file (note that syntax error usually prevent to validate other errors, and the list of errors to fix can become much longer when the syntax error is fixed (please make sure that you are using flake8-rst version 0.7.0 or higher):

$ flake8-rst doc/source/enhancingperf.rst 
doc/source/enhancingperf.rst:76:13: E999 SyntaxError: invalid syntax
doc/source/enhancingperf.rst:189:91: E501 line too long (97 > 79 characters)
doc/source/enhancingperf.rst:190:91: E501 line too long (90 > 79 characters)
doc/source/enhancingperf.rst:270:91: E501 line too long (123 > 79 characters)
doc/source/enhancingperf.rst:378:30: E226 missing whitespace around arithmetic operator
doc/source/enhancingperf.rst:385:100: E501 line too long (84 > 79 characters)
doc/source/enhancingperf.rst:550:13: E111 indentation is not a multiple of four
doc/source/enhancingperf.rst:552:13: E111 indentation is not a multiple of four
doc/source/enhancingperf.rst:570:7: E111 indentation is not a multiple of four
doc/source/enhancingperf.rst:572:4: E111 indentation is not a multiple of four

Once all the errors are addressed, please open a pull request with the fixes in the file, and removing the file from setup.cfg. If you need to do something that feels wrong to fix an error, please ask in a comment to this issue. Please avoid other unrelated changes, which can be addressed in a separate pull request.

@addisonlynch
Copy link
Contributor

I can take this issue.

@addisonlynch
Copy link
Contributor

@datapythonista, do you have any recommendations for:

   %prun -l 4 df.apply(lambda x: integrate_f(x['a'], x['b'], x['N']), axis=1)

Adding the noqa makes the line too long

@datapythonista
Copy link
Member Author

Not sure what's the issue here, does this make sense:

%prun -l 4 df.apply(lambda x: integrate_f(x['a'],
                                          x['b'],
                                          x['N']),
                    axis=1)

@addisonlynch
Copy link
Contributor

That's what I tried originally, but still getting E999 for the %prun -l 4.

@datapythonista
Copy link
Member Author

is this failing too?

%prun -l 4 df.apply(lambda x: integrate_f(x['a'],
                                          x['b'],
                                          x['N']),
                    axis=1)  # noqa E999

@FHaase I guess those should work in ipython directives, is this something that can be fixed in flake8-rst?

@addisonlynch
Copy link
Contributor

Yes, the above example fails as well.

@datapythonista
Copy link
Member Author

I guess you also tried:

%prun -l 4 df.apply(lambda x: integrate_f(x['a'],  # noqa E999
                                          x['b'],
                                          x['N']),
                    axis=1)

Is this the one you mentioned it was too long?

For now may be you can add the noqa E999 E501 (E501 is for line too long) if that fixes it, and we'll try to find a better solution later.

Otherwise, feel free to open a PR to fix the rest, and may be you can create an issue for this one, and add the link to the issue to the exclude of the file

@FHaase
Copy link
Contributor

FHaase commented Dec 11, 2018

The issue with flake8-rst in connection with this line is as follows:
The ipython directive allows for python-console specific code, which usually doesn't appear in normal *.py files, resulting in E999 issues.

flake8-rst takes care of it by removing %.* + indentation in following lines. So for example for %timeit it works well. In this case the -l 4 keeps being in the line resulting in E999 issue. I currently don't know how to fix this in flake8-rst internal.

The solution would be to ignore the complete block from checking. Not ideal, but as issues within the syntax of the checked code result in ignoring all AST-related checks for that block (even when using # noqa) I think it's the better compromise.

So my suggestion is to add the custom roles of flake8-rst and then add :flake8-group: Ignore.
The issue with E999 is not unique to this line/file. Basically every file in documentation with # noqa: E999 currently skips a portion of tests.

@datapythonista
Copy link
Member Author

@addisonlynch I think you can for now have that in a .. code-block:: without python after it, and I think that should make it not being validated.

Can you open a pull request, so we can see if the rest is correct, and also discuss more in practice this case?

@addisonlynch
Copy link
Contributor

@datapythonista sounds good, I'll try to get this closed out.

@datapythonista
Copy link
Member Author

@addisonlynch are you still working on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants