Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 14db7d4

Browse files
author
David Robertson
committed
Improve comments in opentracing
I tried to workaround the ignores but found it too much trouble. I think the corresponding issue is python/mypy#12909. The mypy repo has a PR claiming to fix this (python/mypy#14677) which might mean this gets resolved soon?
1 parent 029cfaf commit 14db7d4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

synapse/logging/opentracing.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,10 +894,14 @@ def _wrapping_logic(func: Callable[P, R], *args: P.args, **kwargs: P.kwargs) ->
894894
"""
895895

896896
if inspect.iscoroutinefunction(func):
897-
897+
# In this branch, R = Awaitable[RInner], for some other type RInner
898898
@wraps(func)
899-
async def _wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
899+
async def _wrapper(
900+
*args: P.args, **kwargs: P.kwargs
901+
) -> Any: # Return type is RInner
900902
with wrapping_logic(func, *args, **kwargs):
903+
# type-ignore: func() returns R, but mypy doesn't know that R is
904+
# Awaitable here.
901905
return await func(*args, **kwargs) # type: ignore[misc]
902906

903907
else:
@@ -965,6 +969,7 @@ def _decorator(func: Callable[P, R]) -> Callable[P, R]:
965969
return func
966970

967971
# type-ignore: mypy seems to be confused by the ParamSpecs here.
972+
# I think the problem is https://github.com/python/mypy/issues/12909
968973
return _custom_sync_async_decorator(
969974
func, _wrapping_logic # type: ignore[arg-type]
970975
)
@@ -1014,6 +1019,7 @@ def _wrapping_logic(
10141019
yield
10151020

10161021
# type-ignore: mypy seems to be confused by the ParamSpecs here.
1022+
# I think the problem is https://github.com/python/mypy/issues/12909
10171023
return _custom_sync_async_decorator(func, _wrapping_logic) # type: ignore[arg-type]
10181024

10191025

0 commit comments

Comments
 (0)