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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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



cdef extern from "../src/headers/portable.h":
Expand Down Expand Up @@ -214,15 +215,15 @@ cdef inline object _parse_delimited_date(str date_string, bint dayfirst):
format='MM/DD/YYYY',
dayfirst='True',
),
stacklevel=4,
stacklevel=find_stack_level(),
)
elif not dayfirst and swapped_day_and_month:
warnings.warn(
PARSING_WARNING_MSG.format(
format='DD/MM/YYYY',
dayfirst='False (the default)',
),
stacklevel=4,
stacklevel=find_stack_level(),
)
# In Python <= 3.6.0 there is no range checking for invalid dates
# in C api, thus we call faster C version for 3.6.1 or newer
Expand Down