You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calling inspect.signature with an AsyncMock instance raises an exception #96127
def_signature_from_function(cls, func, skip_bound_arg=True,
globals=None, locals=None, eval_str=False):
"""Private helper: constructs Signature for the given python function."""is_duck_function=Falseifnotisfunction(func):
if_signature_is_functionlike(func):
is_duck_function=Trueelse:
# If it's not a pure Python function, and not a duck type# of pure function:raiseTypeError('{!r} is not a Python function'.format(func))
s=getattr(func, "__text_signature__", None)
ifs:
return_signature_fromstr(cls, func, s, skip_bound_arg)
Parameter=cls._parameter_cls# Parameter information.func_code=func.__code__pos_count=func_code.co_argcountarg_names=func_code.co_varnamesposonly_count=func_code.co_posonlyargcount>positional=arg_names[:pos_count]
ETypeError: 'Mock'objectisnotsubscriptable
Activity
graingert commentedon Aug 23, 2022
Related? #94924
tirkarthi commentedon Aug 23, 2022
This could be due to commit 4261b6b
pythongh-96127: Fix `inspect.signature` call on mocks
sobolevn commentedon Aug 27, 2022
@graingert yes, your link was very useful. Please, take a look at my proposed soultion :)
cjw296 commentedon Jan 3, 2023
@sobolevn - where is your proposed solution?
AlexWaygood commentedon Jan 3, 2023
inspect.signaturecall on mocks #96335pythongh-96127: Fix `inspect.signature` call on mocks
gh-96127: Fix `inspect.signature` call on mocks (#96335)
hauntsaninja commentedon Jan 20, 2023
Looks like this has been fixed, thanks all!
mdczaplicki commentedon Feb 7, 2023
I'm on 3.11.1 and this is happening.
tirkarthi commentedon Feb 7, 2023
This commit is present on main branch and 3.12 latest alpha. I guess this is not backported.
mdczaplicki commentedon Feb 7, 2023
Workaround:
arhadthedev commentedon Feb 7, 2023
@sobolevn should the PR be backported to 3.11?
4 remaining items
pythongh-96127: Fix `inspect.signature` call on mocks (python#96335)
pythongh-96127: Fix `inspect.signature` call on mocks (python#96335)
arhadthedev commentedon Feb 8, 2023
@sobolevn ping?
[3.11] gh-96127: Fix `inspect.signature` call on mocks (#96335) (#101646
arhadthedev commentedon Feb 8, 2023
@mdczaplicki @tirkarthi The backporting is done. The fix will be available in 3.11.3
and 3.10.11this April.arhadthedev commentedon Feb 8, 2023
Fixed by gh-96335.
AlexWaygood commentedon Feb 8, 2023
@arhadthedev where is the 3.10 backport?
arhadthedev commentedon Feb 8, 2023
I confused it with my other issue that was backported to both versions. Thank you for pointing out, edited.
pythongh-96127: Fix `inspect.signature` call on mocks (python#96335)
bedevere-bot commentedon Aug 29, 2023
GH-108652 is a backport of this pull request to the 3.10 branch.