Skip to content

DOC: flake8 flagging template strings in docstrings as syntax errors #51377

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
1 task done
kkangs0226 opened this issue Feb 14, 2023 · 4 comments
Closed
1 task done
Labels
CI Continuous Integration Code Style Code style, linting, code_checks Docs

Comments

@kkangs0226
Copy link
Contributor

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.apply_index.html
https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.background_gradient.html

Documentation problem

Template strings that are in the first line of the doctest i.e. line starting with >>>, are flagged as syntax errors.

A guess is that perhaps flake8 identifies the doctests chunks & runs the syntax checking before the docstrings are rendered, and there is perhaps a bug (or perhaps there are other reasons) where the string interpolation is flagged as a syntax error for the first line.

Detailed testing & more information about this error can be found here #51356 (comment)

Suggested fix for documentation

Would need to discuss how to fix the template problem in doctests.

@kkangs0226 kkangs0226 added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 14, 2023
@datapythonista datapythonista added CI Continuous Integration Code Style Code style, linting, code_checks and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 14, 2023
@jayam30
Copy link

jayam30 commented Feb 16, 2023

Hey I want to start my contribution with this, could I be assigned this

@MarcoGorelli
Copy link
Member

@jayam30 please stop leaving the same comment on all issues - please consider this a warning

@wcgonzal
Copy link
Contributor

Take if nobody is currently working on this.

@MarcoGorelli
Copy link
Member

thanks for reporting

to be honest I don't think there's much we can do here, the templates are used when creating the docstrings - flake8 errors should be fixed using validate_docstrings with the EX03 code, not by running flake8. Running flake8 directly has been useful for fixing issues (thanks @kkangs0226 !), but it's not what we run in CI, so I don't think there's much that needs fixing here

closing then, but thanks for your report and contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Code Style Code style, linting, code_checks Docs
Projects
None yet
Development

No branches or pull requests

5 participants