Skip to content

Commit 7d6abf1

Browse files
committed
Emit FutureWarning whenever necessary
1 parent 594c22c commit 7d6abf1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/util/_decorators.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,22 @@ def deprecate_nonkeyword_arguments(
238238
def decorate(func):
239239
@wraps(func)
240240
def wrapper(*args, **kwargs):
241+
if isinstance(allowed_args, int) and len(args) > allowed_args:
242+
msg = (
243+
"After version %s all arguments of %s "
244+
"except for the first %i will be keyword-only"
245+
) % (version, func.__name__, allowed_args)
246+
elif isinstance(allowed_args, (list, tuple)) and len(args) > len(
247+
allowed_args
248+
):
249+
msg = (
250+
"After version %s all arguments of %s "
251+
"except for (%s) will be keyword-only"
252+
) % (version, func.__name__, ", ".join(allowed_args))
253+
else:
254+
msg = None
255+
if msg:
256+
warnings.warn(msg, FutureWarning, stacklevel=stacklevel)
241257
return func(*args, **kwargs)
242258

243259
return wrapper

0 commit comments

Comments
 (0)