pytask icon indicating copy to clipboard operation
pytask copied to clipboard

DOC: Code examples in documentation on "Capture warnings" produces errors locally

Open timmens opened this issue 1 year ago • 1 comments

Location of the documentation

https://pytask-dev.readthedocs.io/en/v0.4.7/how_to_guides/capture_warnings.html

Documentation problem

The documentation states:

...

@pytask.mark.filterwarnings("ignore:.*:SettingWithCopyWarning")

...

which results in the following output AttributeError: module 'builtins' has no attribute 'SettingWithCopyWarning', when running pytask on the corresponding task file (pytask == 0.4.7 and pandas==2.2.1).

Suggested fix for documentation

To make the example code run, the decorator argument should be changed to:

...

@pytask.mark.filterwarnings("ignore:.*:pandas.errors.SettingWithCopyWarning")

...

Additionally, it could be nice to have one or two sentences on how to deal with custom warnings, or warnings that are imported from other packages, and how to ignore them in the pyproject.toml.

timmens avatar Mar 25 '24 13:03 timmens

Thanks a lot, @timmens! Yes, this should be corrected.

tobiasraabe avatar Mar 25 '24 13:03 tobiasraabe