diff --git a/synapse/logging/opentracing.py b/synapse/logging/opentracing.py
index be910128aa..5c3045e197 100644
--- a/synapse/logging/opentracing.py
+++ b/synapse/logging/opentracing.py
@@ -910,10 +910,10 @@ def _custom_sync_async_decorator(
async def _wrapper(
*args: P.args, **kwargs: P.kwargs
) -> Any: # Return type is RInner
- with wrapping_logic(func, *args, **kwargs):
- # type-ignore: func() returns R, but mypy doesn't know that R is
- # Awaitable here.
- return await func(*args, **kwargs) # type: ignore[misc]
+ # type-ignore: func() returns R, but mypy doesn't know that R is
+ # Awaitable here.
+ with wrapping_logic(func, *args, **kwargs): # type: ignore[arg-type]
+ return await func(*args, **kwargs)
else:
# The other case here handles sync functions including those decorated with
@@ -980,8 +980,7 @@ def trace_with_opname(
See the module's doc string for usage examples.
"""
- # type-ignore: mypy bug, see https://github.com/python/mypy/issues/12909
- @contextlib.contextmanager # type: ignore[arg-type]
+ @contextlib.contextmanager
def _wrapping_logic(
func: Callable[P, R], *args: P.args, **kwargs: P.kwargs
) -> Generator[None, None, None]:
@@ -1024,8 +1023,7 @@ def tag_args(func: Callable[P, R]) -> Callable[P, R]:
if not opentracing:
return func
- # type-ignore: mypy bug, see https://github.com/python/mypy/issues/12909
- @contextlib.contextmanager # type: ignore[arg-type]
+ @contextlib.contextmanager
def _wrapping_logic(
func: Callable[P, R], *args: P.args, **kwargs: P.kwargs
) -> Generator[None, None, None]:
|