-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Core} Python 3.11: Remove uses of deprecated inspect.getargspec #24111
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: dev
Are you sure you want to change the base?
Conversation
inspect.getargspec has been deprecated since 3.0 in favor of its replacement inspect.getfullargspec.
|
Thank you for your contribution mdboom! We will review the pull request and get back to you soon. |
|
remove deprecated dependencies on test |
|
Speaking to @iritkatriel in another forum, it sounds like the most future-proof option is to use |
Sorry, is this a request of me? I'm not sure I understand. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
| def _auth_callback_compat(self, server, resource, scope, scheme): | ||
| return self._user_callback(server, resource, scope) \ | ||
| if len(inspect.getargspec(self._user_callback).args) == 3 \ | ||
| if len(inspect.signature(self._user_callback).parameters) == 3 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not equivalent to the original code if self._user_callback contains *args and **kwargs, since signature's result includes *args (kind: VAR_POSITIONAL) and **kwargs (kind: VAR_KEYWORD) in parameters, but getargspec's result has dedicated varargs, keywords elements for them:
import inspect
def testfunc(a=1, b=2, *args, **kwargs):
pass
print(len(inspect.getfullargspec(testfunc).args))
print(inspect.getfullargspec(testfunc).args)
print(len(inspect.signature(testfunc).parameters))
print(inspect.signature(testfunc).parameters)Output:
2
['a', 'b']
4
OrderedDict([('a', <Parameter "a=1">), ('b', <Parameter "b=2">), ('args', <Parameter "*args">), ('kwargs', <Parameter "**kwargs">)])
inspect.getargspec has been deprecated since 3.0 in favor of its replacement inspect.getfullargspec.
This does change "vendored" code, and I couldn't find where that may require special treatment, if at all.
There is one other use of
inspect.getargspecthat is retained for backward compatibility with Python 2 that I didn't touch, but in reality that clause could also probably be removed since Python 2 is no longer supported.Related command
All
azcommands.Description
Another step on the road to Python 3.11 compatibility. (See also #24109)
Testing Guide
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.