-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-108901: Deprecate inspect.getargs
, slate it for removal in 3.15
#112279
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
18ae539
fd81c14
6087111
4eea14c
d8cd4f2
56dbc0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -1363,7 +1363,17 @@ def getargs(co): | |||
Three things are returned: (args, varargs, varkw), where | ||||
'args' is the list of argument names. Keyword-only arguments are | ||||
appended. 'varargs' and 'varkw' are the names of the * and ** | ||||
arguments or None.""" | ||||
arguments or None. | ||||
|
||||
Deprecated. Use ``inspect.signature(types.FunctionType(co, {}))`` instead. | ||||
""" | ||||
import warnings | ||||
warnings._deprecated( | ||||
"getargs", | ||||
"{name!r} is deprecated and slated for removal in Python {remove}, " | ||||
"use `inspect.signature(types.FunctionType(co, {{}}))` instead", | ||||
remove=(3, 15), | ||||
) | ||||
if not iscode(co): | ||||
raise TypeError('{!r} is not a code object'.format(co)) | ||||
|
||||
|
@@ -1489,7 +1499,10 @@ def getargvalues(frame): | |||
'args' is a list of the argument names. | ||||
'varargs' and 'varkw' are the names of the * and ** arguments or None. | ||||
'locals' is the locals dictionary of the given frame.""" | ||||
args, varargs, varkw = getargs(frame.f_code) | ||||
import warnings | ||||
with warnings.catch_warnings(): | ||||
warnings.simplefilter('ignore', category=DeprecationWarning) | ||||
args, varargs, varkw = getargs(frame.f_code) | ||||
Comment on lines
+1508
to
+1511
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should follow our own advice and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. Right now Line 1384 in fef6fb8
pos_or_kw_args together with kw_only_args , but ignores pos_only_args .
I think that we can just keep it as-is and then remove all of them together in 3.15 (because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I see. Maybe we should do the (I'm fine suppressing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I can open a PR about |
||||
return ArgInfo(args, varargs, varkw, frame.f_locals) | ||||
|
||||
def formatannotation(annotation, base_module=None): | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Deprecate undocumented ``inspect.getargs`` function. Instead use | ||
``inspect.signature(types.FunctionType(co, {}))``. |
Uh oh!
There was an error while loading. Please reload this page.