Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unit tests failing with python 3.11.4 #509

Closed
@parthea

Description

@parthea

Several unit tests have started failing with TypeError: __annotations__ must be set to a dict object when using python 3.11.4. See build log here.

Sample stack trace

    @pytest.mark.asyncio
    async def test_cancel_operation():
        mocked_channel, method, fake_call = _mock_grpc_objects(empty_pb2.Empty())
>       client = operations_v1.OperationsAsyncClient(mocked_channel)

tests/asyncio/operations_v1/test_operations_async_client.py:104: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
google/api_core/operations_v1/operations_async_client.py:62: in __init__
    self._get_operation = gapic_v1.method_async.wrap_method(
google/api_core/gapic_v1/method_async.py:42: in wrap_method
    func = grpc_helpers_async.wrap_errors(func)
google/api_core/grpc_helpers_async.py:201: in wrap_errors
    return _wrap_unary_errors(callable_)
google/api_core/grpc_helpers_async.py:154: in _wrap_unary_errors
    @functools.wraps(callable_)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

wrapper = <function _wrap_unary_errors.<locals>.error_remapped_callable at 0x7fc3e4440ae0>
wrapped = <Mock spec='UnaryUnaryMultiCallable' id='140479329622096'>
assigned = ('__module__', '__name__', '__qualname__', '__doc__', '__annotations__')
updated = ('__dict__',)

    def update_wrapper(wrapper,
                       wrapped,
                       assigned = WRAPPER_ASSIGNMENTS,
                       updated = WRAPPER_UPDATES):
        """Update a wrapper function to look like the wrapped function
    
           wrapper is the function to be updated
           wrapped is the original function
           assigned is a tuple naming the attributes assigned directly
           from the wrapped function to the wrapper function (defaults to
           functools.WRAPPER_ASSIGNMENTS)
           updated is a tuple naming the attributes of the wrapper that
           are updated with the corresponding attribute from the wrapped
           function (defaults to functools.WRAPPER_UPDATES)
        """
        for attr in assigned:
            try:
                value = getattr(wrapped, attr)
            except AttributeError:
                pass
            else:
>               setattr(wrapper, attr, value)
E               TypeError: __annotations__ must be set to a dict object

I tried the workaround in python/cpython#105933 (comment) but it didn't help. I'm still investigating.

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.status: investigatingThe issue is under investigation, which is determined to be non-trivial.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions