-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
DOC: Use a standard header for all rst files #24086
Conversation
Hello @saurav2608! Thanks for submitting the PR.
|
Codecov Report
@@ Coverage Diff @@
## master #24086 +/- ##
=======================================
Coverage 42.51% 42.51%
=======================================
Files 161 161
Lines 51691 51691
=======================================
Hits 21975 21975
Misses 29716 29716
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24086 +/- ##
=======================================
Coverage 92.21% 92.21%
=======================================
Files 162 162
Lines 51723 51723
=======================================
Hits 47694 47694
Misses 4029 4029
Continue to review full report at Codecov.
|
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 quite good, if you can just revert the removal of datetime.
, and check the failures.
@FHaase do you want to take a look here?
doc/source/cookbook.rst
Outdated
@@ -1333,20 +1314,20 @@ The :ref:`Timedeltas <timedeltas.timedeltas>` docs. | |||
|
|||
s.max() - s | |||
|
|||
s - datetime.datetime(2011, 1, 1, 3, 5) |
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.
can you revert those, the import should be import datetime
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.
Done
doc/source/conf.py
Outdated
import functools | ||
import glob | ||
import itertools | ||
import os |
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.
All those shouldn't be here, should be visibly imported in the places where they are used.
Can you check if we the currently validated flake8-rst
files (the ones not ignored in setup.cfg
), removing them raises an error?
That would apply to all the imports except import pandas as pd
and import numpy as np
.
Don't fix the errors in this PR if there are more than couple, but if you can show how many failures are without the imports, that would be great.
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.
these are also done.
@saurav2608 will you have time to add the numpy and pandas imports to setup.cfg, remove the others from the header, and add the needed ones to where they are used? |
Once your suggestions are implemented I'm fine with that. @saurav2608 adding this to [flake8-rst]
bootstrap =
import numpy as np
import pandas as pd
... |
I will definitely complete this. I am traveling for work, but will get this done by tomorrow. |
@datapythonista I assume you want to merge this before anything else touches the .rst's themselves? |
I don't think we have anything else modifying the |
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.
@saurav2608 Thanks for working on this!
doc/source/conf.py
Outdated
import glob | ||
import itertools | ||
import os | ||
|
||
import numpy as np | ||
from pandas import * |
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.
This from pandas import *
should also not be here. If it was needed for the whatsnew files (where the common imports were used now?), I would still keep that separate until we fix the examples in the whatsnew files to not need this.
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.
This
from pandas import *
should also not be here. If it was needed for the whatsnew files (where the common imports were used now?), I would still keep that separate until we fix the examples in the whatsnew files to not need this.
Okay - I have added from pandas import *
to all whatsnew files. We have to revisit all the whatnew files.
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 have added from pandas import *
to all the whatsnew file. We have to review all of them later to see where files actually need the import (my guess is all of them).
@saurav2608 did you push your changes? I still can see all the imports in |
No I have not pushed it yes. I am making the changes now. |
ecba524
to
3cc9f67
Compare
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 great, just couple of questions, not sure if I'm missing something
doc/source/comparison_with_sas.rst
Outdated
import pandas as pd | ||
import numpy as np | ||
import pandas as pd # noqa: F811 | ||
import numpy as np # 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.
why don't we use the header here? you can add the F811
to the --bootstrap
parameter value if needed
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.
This is a tutorial of sorts and the tutorial walks thru the process of importing pandas and numpy visibly (not with a :supress: ). I think without the visible import of pandas the tutorial will not make sense.
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.
Makes sense. But can you still include the header in those files? Besides the imports, there is other stuff. And we will potentially add more, and expect to be applied to 100% of rst files. Thanks!
doc/source/contributing.rst
Outdated
import pandas as pd | ||
from pandas.util import testing as tm | ||
import numpy as np # noqa: F811 | ||
import pandas as pd # 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.
same
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.
This similar to the issue above. The tutorial presents a complete block of code to be copied and saved as a .py file. Without the explicit import, anyone following the tutorial will not be able to replicate the results. It might make sense to include this block as a non executable block.
doc/source/install.rst
Outdated
@@ -207,7 +207,7 @@ installed), make sure you have `pytest | |||
|
|||
:: | |||
|
|||
>>> import pandas as pd | |||
>>> import pandas as pd # 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.
same
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.
On this I agree with you. I can remove the explicit import.
what I don't understand is why the CC: @FHaase |
There is another behavior I am unable to understand. This build fails on linting error on the file comparison_with_sql.rst. |
@saurav2608 general note: when updating the PR, can you add new commits instead of amending or squashing with the previous one? That makes it easier to review only the new changes. |
@saurav2608, if you want you can remove the This way we can merge this, avoid conflicts, and we can fix the |
@datapythonista, I have removed the #noqa and added the files to the ignore list. I have also added header to all the rst file. |
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 great, thanks a lot for working on this
do you mind creating yourself the follow up issues for:
- Removing the
from pandas import *
in the whatsnew files - Fix the errors with
flake8-rst
that report errors in theimport pandas as pd
... - Remove the
randn = numpy.random.randn
and replace therandn
bynp.random.randn
Thanks!
Sure, will open the issues. |
@datapythonista looks ok. are you sure you wan tthe |
I think for now makes sense to have the |
@datapythonista , @jreback : Can you please merge this? I will create follow-up issues for the revised code. |
@saurav2608 pls merge master. @datapythonista ok by me. |
@saurav2608 merged the conflict myself, merging on green |
Thanks @saurav2608 for taking care of this, good improvement |
@saurav2608 I already fixed the errors when importing |
@@ -1081,6 +1069,8 @@ Option 1: pass rows explicitly to skip rows | |||
|
|||
.. ipython:: python | |||
|
|||
from pandas.compat import StringIO |
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.
Side note: in the public docs I think we should use the standard python from io import StringIO
(as I don't think we should recommend people normal users to use pandas.compat
)
git diff upstream/master -u -- "*.py" | flake8 --diff