Repository navigation
Conversation
A classmethod (or staticmethod) wrapping another descriptor such as functools.singledispatchmethod has a non-callable __func__, which made wire() crash with "TypeError: ... is not a callable object" while inspecting its signature. There is nothing to inject into such members, so leave them untouched. Fixes ets-labs#950
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #950
wire()crashes when a wired module contains a class with aclassmethod(orstaticmethod) that wraps another descriptor, e.g.functools.singledispatchmethod:_patch_methodtakesmethod.__func__from theclassmethod/staticmethodand passes it toinspect.signature, but here__func__is the (non-callable)singledispatchmethoddescriptor. There is nothing to inject into such a member, so_patch_methodnow returns early when__func__is not callable, leaving the attribute untouched.Tests
Added
tests/unit/wiring/test_classmethod_wrapping_descriptor_py36.py.pytest tests/unit/wiring/test_classmethod_wrapping_descriptor_py36.pyfails with theTypeErrorabove (Python 3.11 and 3.13).pyteston 3.13: 1388 passed, 2 skipped.flake8 src/dependency_injector/is clean.