Skip to content

Fix stacklevel dayfirst warning #47908

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

Conversation

MarcoGorelli
Copy link
Member

@@ -130,7 +130,8 @@ def _assert_caught_expected_warning(
saw_warning = True

if check_stacklevel and issubclass(
actual_warning.category, (FutureWarning, DeprecationWarning)
actual_warning.category,
(FutureWarning, DeprecationWarning, UserWarning),
Copy link
Member Author

Choose a reason for hiding this comment

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

the test which checked the warning passes on main because stacklevel is only checked for FutureWarning and DeprecationWarning

@@ -63,6 +63,7 @@ from pandas._libs.tslibs.util cimport (
get_c_string_buf_and_size,
is_array,
)
from pandas.util._exceptions import find_stack_level
Copy link
Member Author

Choose a reason for hiding this comment

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

@jbrockmendel any suggestions on how to do this without importing from outisde _libs (as you'd previously requested on a different PR)?

Copy link
Contributor

Choose a reason for hiding this comment

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

you could import it when u need this (eg near usage)

or move the implementation to _libs itself

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a case where the rule-of-thumb preventing non-_libs imports is OK to break

@MarcoGorelli MarcoGorelli marked this pull request as draft July 31, 2022 13:47
@MarcoGorelli MarcoGorelli force-pushed the fix-stacklevel-dayfirst-warning branch from f135ba3 to 4cf3d9b Compare August 1, 2022 20:40
@MarcoGorelli MarcoGorelli marked this pull request as ready for review August 1, 2022 20:43
@MarcoGorelli
Copy link
Member Author

OK thanks, I've stuck with the original import then

I've made a separate issue about catching this incorrect stacklevel in tests, will address that separately if that's OK #47919

@MarcoGorelli
Copy link
Member Author

closing as I'm taking this forwards in #47998

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: stacklevel from dayfirst warning incorrect
3 participants