[issue41231] Type annotations lost when using wraps by default

David Caro report at bugs.python.org
Tue Jul 7 18:24:01 EDT 2020


David Caro <david at dcaro.es> added the comment:

Hi Terry,

That would not work in this case, as I'd want to override all annotations with the wrapper function ones if there's any, instead of merging them.

The specific use case, is a type checker (part of TestSlide testing framework), to verify that if there's any type annotations, the parameters mocked and passed to it are the expected types.

For example, the contextmanager decorator returns an actual ContextManager, wrapping whatever the wrapped function returned, so if the wrapped function annotations prevail, then there's no way if verifying that the returned type is correct.

Thanks for the ChainMap pointer though, I'll use it for sure somewhere else.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41231>
_______________________________________


More information about the Python-bugs-list mailing list