Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-96127: Fixinspect.signature call on mocks#96335

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
cjw296 merged 1 commit intopython:mainfromsobolevn:issue-96127
Jan 7, 2023

Conversation

@sobolevn
Copy link
Member

@sobolevnsobolevn commentedAug 27, 2022
edited by AlexWaygood
Loading

Before:

>>>import inspect>>>from unittest.mockimport AsyncMock>>> inspect.signature(AsyncMock())Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/home/karthikeyan/stuff/python/cpython/Lib/inspect.py", line 3272, in signature    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/home/karthikeyan/stuff/python/cpython/Lib/inspect.py", line 3020, in from_callable    return _signature_from_callable(obj, sigcls=cls,           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/home/karthikeyan/stuff/python/cpython/Lib/inspect.py", line 2507, in _signature_from_callable    return _signature_from_function(sigcls, obj,           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/home/karthikeyan/stuff/python/cpython/Lib/inspect.py", line 2351, in _signature_from_function    positional = arg_names[:pos_count]                 ~~~~~~~~~^^^^^^^^^^^^TypeError: 'Mock' object is not subscriptable>>>

After:

>>>from inspectimport signature>>>from unittest.mockimport AsyncMock>>> >>> mock= AsyncMock()>>> signature(mock)<Signature (*args, **kwargs)>

Related#94050

@sobolevn
Copy link
MemberAuthor

Re-triggering CI.

@graingert
Copy link
Contributor

I have a similar PR somewhere about this, but I'm on mobile so it's tricky to find

@graingert
Copy link
Contributor

#94962 is this related?

@sobolevn
Copy link
MemberAuthor

sobolevn commentedSep 12, 2022
edited by AlexWaygood
Loading

They are not related as far as I can tell :)

Your PR does not fix this exact problem:

gh pr checkout 94962
Python 3.12.0a0 (heads/main-dirty:a36235d5c7, Sep 11 2022, 12:23:24) [Clang 11.0.0 (clang-1100.0.33.16)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>import inspect>>>from unittest.mockimport AsyncMock>>> inspect.signature(AsyncMock())Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/Users/sobolev/Desktop/cpython/Lib/inspect.py", line 3272, in signature    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/sobolev/Desktop/cpython/Lib/inspect.py", line 3020, in from_callable    return _signature_from_callable(obj, sigcls=cls,           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/sobolev/Desktop/cpython/Lib/inspect.py", line 2507, in _signature_from_callable    return _signature_from_function(sigcls, obj,           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/sobolev/Desktop/cpython/Lib/inspect.py", line 2351, in _signature_from_function    positional = arg_names[:pos_count]                 ~~~~~~~~~^^^^^^^^^^^^TypeError: 'Mock' object is not subscriptable

@cjw296
Copy link
Contributor

@sobolevn - could you rebase and resolve the conflicts? I think this is then good to land after another quick eyeball from a reviewer...

@sobolevn
Copy link
MemberAuthor

Sure!

  1. I've checked that this exception still happens onmain with all the new changes (it does)
  2. I've rebased my changes on top ofmain
  3. Force pushed! 🎉

I hope we can land this now!

zmievsa reacted with hooray emoji

@zmievsa
Copy link
Contributor

@sobolevn this fix saved me big time. Thank you for your amazing work!

sobolevn reacted with heart emoji

@sobolevnsobolevn added the needs backport to 3.11only security fixes labelFeb 7, 2023
@miss-islington
Copy link
Contributor

Thanks@sobolevn for the PR, and@cjw296 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry@sobolevn and@cjw296, I had trouble checking out the3.11 backport branch.
Please retry by removing and re-adding the "needs backport to 3.11" label.
Alternatively, you can backport usingcherry_picker on the command line.
cherry_picker 9e7d7266ecdcccc02385fe4ccb094f3444102e26 3.11

@AlexWaygoodAlexWaygood added needs backport to 3.11only security fixes and removed needs backport to 3.11only security fixes labelsFeb 7, 2023
@miss-islington
Copy link
Contributor

Thanks@sobolevn for the PR, and@cjw296 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry,@sobolevn and@cjw296, I could not cleanly backport this to3.11 due to a conflict.
Please backport usingcherry_picker on command line.
cherry_picker 9e7d7266ecdcccc02385fe4ccb094f3444102e26 3.11

arhadthedev pushed a commit to arhadthedev/cpython that referenced this pull requestFeb 7, 2023
arhadthedev pushed a commit to arhadthedev/cpython that referenced this pull requestFeb 7, 2023
@bedevere-bot
Copy link

GH-101646 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelFeb 7, 2023
@bedevere-bot
Copy link

GH-101647 is a backport of this pull request to the3.10 branch.

ambv pushed a commit that referenced this pull requestFeb 8, 2023
)(cherry picked from commit9e7d726)Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
thechrisu pushed a commit to thechrisu/cpython that referenced this pull requestAug 29, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@graingertgraingertgraingert left review comments

@cjw296cjw296cjw296 approved these changes

Assignees

@cjw296cjw296

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@sobolevn@graingert@cjw296@zmievsa@miss-islington@bedevere-bot@AlexWaygood

[8]ページ先頭

©2009-2025 Movatter.jp