File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,22 @@ def deprecate_nonkeyword_arguments(
238
238
def decorate (func ):
239
239
@wraps (func )
240
240
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 )
241
257
return func (* args , ** kwargs )
242
258
243
259
return wrapper
You can’t perform that action at this time.
0 commit comments