Skip to content

DOC: Fix flake8 issues in doc/source/whatsnew/v0.24.0.rst #24200

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
saurav2608 opened this issue Dec 10, 2018 · 8 comments · Fixed by #24217
Closed

DOC: Fix flake8 issues in doc/source/whatsnew/v0.24.0.rst #24200

saurav2608 opened this issue Dec 10, 2018 · 8 comments · Fixed by #24217

Comments

@saurav2608
Copy link

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/whatsnew/v0.24.0.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/whatsnew/v0.24.0.rst 
source/whatsnew/v0.24.0.rst:281:26: E127 continuation line over-indented for visual indent
source/whatsnew/v0.24.0.rst:294:4: E999 IndentationError: unexpected indent
source/whatsnew/v0.24.0.rst:294:5: E303 too many blank lines (2)
source/whatsnew/v0.24.0.rst:294:5: E111 indentation is not a multiple of four
source/whatsnew/v0.24.0.rst:294:5: E113 unexpected indentation
source/whatsnew/v0.24.0.rst:444:92: E501 line too long (96 > 79 characters)
source/whatsnew/v0.24.0.rst:452:92: E501 line too long (80 > 79 characters)
source/whatsnew/v0.24.0.rst:561:84: E501 line too long (80 > 79 characters)
source/whatsnew/v0.24.0.rst:571:84: E501 line too long (84 > 79 characters)

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.
cc: @datapythonista

@datapythonista
Copy link
Member

Thanks a lot for creating all these @saurav2608

@saurav2608
Copy link
Author

@datapythonista , @FHaase ,
I am facing an issue with E999 in the file 'v0.24.0.rst'. After correcting for all the errors listed above. I am getting error E999 on flaking. I am getting the error on the line marked by noqa E999. I am not sure why this is coming up. I am using version 0.7.0 of flake8-rst.

.. code-block:: ipython

    In [1]: data = pd.DataFrame({
    ...:     "string_with_lf": ["a\nbc"],
    ...:     "string_with_crlf": ["a\r\nbc"]
    ...: })

    In [2]: # When passing file PATH to to_csv, line_terminator does not work,
    ...: # and csv is saved with '\r\n'.
    ...: # Also, this converts all '\n's in the data to '\r\n'.
    ...: data.to_csv("test.csv", index=False, line_terminator='\n')

    In [3]: with open("test.csv", mode='rb') as f:    # noqa E999
    ...:     print(f.read())
    b'string_with_lf,string_with_crlf\r\n"a\r\nbc","a\r\r\nbc"\r\n'

    In [4]: # When passing file OBJECT with newline option to to_csv,
    ...: # line_terminator works.
    ...: with open("test2.csv", mode='w', newline='\n') as f:
    ...:     data.to_csv(f, index=False, line_terminator='\n')

    In [5]: with open("test2.csv", mode='rb') as f:
    ...:     print(f.read())
    b'string_with_lf,string_with_crlf\n"a\nbc","a\r\nbc"\n'

@datapythonista
Copy link
Member

The line seems correct. I'm not sure if the lines reported are from the original file, or from a temporary file that is generated.

If @FHaase is unable to help, I think the best you can do is temporary remove parts of the file, until you can identify which is the actual code generating the error.

@FHaase
Copy link
Contributor

FHaase commented Dec 11, 2018

Have you tried aligning the '...:' with those above?
Like

    In [1]: data = pd.DataFrame({
       ...:     "string_with_lf": ["a\nbc"],
       ...:     "string_with_crlf": ["a\r\nbc"]
       ...: })

@thoo
Copy link
Contributor

thoo commented Dec 11, 2018

Or like this:


  .. code-block:: ipython

    In [1]: data = pd.DataFrame({"string_with_lf": ["a\nbc"],
       ...:                      "string_with_crlf": ["a\r\nbc"]})

    In [2]: data.to_csv("test.csv", index=False)

    In [3]: with open("test.csv", mode='rb') as f:
       ...:     print(f.read())
    Out[3]: b'string_with_lf,string_with_crlf\r\n"a\nbc","a\r\nbc"\r\n'

@thoo
Copy link
Contributor

thoo commented Dec 11, 2018

@saurav2608 I could also add this to my PR #24217. Let me know.

@saurav2608
Copy link
Author

@thoo : Thanks. If you have the fix please include in your PR. But the comments are required.

@thoo
Copy link
Contributor

thoo commented Dec 11, 2018

@saurav2608 Thanks. I will add this to my PR and will comment about it.

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