-
-
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/STYLE: Fix "F821 undefined name 'pd'" errors #22900
Comments
I think option 1 would just be a lot of churn and add a lot of repetition to the code samples, so I'm -1 with that. Option 4 seems like the most logical on initial glance - do you see a downside to that outside of the added |
we always ‘import pandas as pd’ option 1 seems pretty verbose as well |
As long as we're running the examples, option 3 should be fine, right? The example So my vote is for option 3. |
@datapythonista how do i check if this is fixed? |
This is not yet fixed. What we'd like is to have this passing:
This would prevent errors in the examples in our docstrings. But if you execute that, you'll see we've got plenty of:
I guess we could start by adding
|
Looks like a lot of the syntax errors are from multi-line statements missing either parens or backslashes |
I created a "good first issue" issue for the errors other than the import. When those are fixed, we can see if we really want to skip F821, or maybe we can add a validation to the CI to make sure only
|
It'd be great to start linting the doctests (validate the docstring examples for pep8 issues).
To start with
core/generic.py
,core/series.py
andcore/frame.py
, I created the next issues to address the current errors: #22892, #22893, #22894, #22895, #22896, #22897 and #22898.After those are fixed, the only error that will remain in these files is
F821 undefined name 'pd'
. I checked for simple ways to avoid it, but I don't think we can prepend code for flake8 (like what we do in sphinx). So, the solutions I see are:import pandas as pd
(or even betterimport pandas
) to every exampleF821
from the doctest linting (this will also ignore errors likedf + 1
where df is not defined, as it's also anF821
error).grep -v
those exact errors, and change the exit code offlake8
based on that, so the linting passes when the output is clean after filtering these errorsI know this has been discussed before, and I'm not sure if anyone else besides me is in favor of option 1. But I think it's worth considering it again in the context of linting doctests. Option 1 has the advantage that the examples are self-contained (they can be copy-pasted, or in the future we can even add a button to open them in binder, or something similar).
The text was updated successfully, but these errors were encountered: