Skip to content
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

REF: Remove dynamic docstrings from option methods #57710

Merged
merged 10 commits into from
Mar 6, 2024

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke commented Mar 2, 2024

xref #57578 (comment)

These methods have complex docstrings in an attempt to display all option within the docstring. This makes these docstrings hard to automatically validate and renders the internal implementation in Sphinx. I think it's reasonable to link to the docs where all the options are listed instead.

Additionally did some cleanups removing silent from some of these methods by instead catching warnings where needed

@mroeschke mroeschke added the Refactor Internal refactoring of code label Mar 2, 2024
Comment on lines +668 to +671
with warnings.catch_warnings():
warnings.simplefilter("ignore", FutureWarning)
warnings.simplefilter("ignore", DeprecationWarning)
s += f"\n [default: {o.defval}] [currently: {get_option(k)}]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to be aware of is the impact of python/cpython#73858. Once this block is entered, the cache of previously seen warnings is cleared so that users will see any already encountered warning again. If encountered in a for loop this can cause a warning to get printed thousands of times e.g. #57054.

I believe this will only be run on import, so I think this is likely to have almost no impact - in the odd case you import pandas in e.g. a for loop the warning would be seen at most twice because of import caching.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just the docstring validation failing.

pandas/io/formats/info.py Show resolved Hide resolved
@mroeschke
Copy link
Member Author

/preview

Copy link
Contributor

github-actions bot commented Mar 6, 2024

Website preview of this PR available at: https://pandas.pydata.org/preview/pandas-dev/pandas/57710/

@mroeschke mroeschke added this to the 3.0 milestone Mar 6, 2024
@mroeschke mroeschke merged commit a0784d2 into pandas-dev:main Mar 6, 2024
47 checks passed
@mroeschke mroeschke deleted the ref/option_methods branch March 6, 2024 22:00
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* REF: Remove dynamic docstrings from option methods

* Fix arguments

* Reuse

* Fix drop duplicate section, numpydoc valudation

* Fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants