Skip to content

Fix mypy #4019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/grpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _wrap_channel_async(func: Callable[P, AsyncChannel]) -> Callable[P, AsyncCha
"Wrapper for asynchronous secure and insecure channel."

@wraps(func)
def patched_channel(
def patched_channel( # type: ignore
*args: P.args,
interceptors: Optional[Sequence[grpc.aio.ClientInterceptor]] = None,
**kwargs: P.kwargs,
Expand All @@ -100,7 +100,7 @@ def _wrap_sync_server(func: Callable[P, Server]) -> Callable[P, Server]:
"""Wrapper for synchronous server."""

@wraps(func)
def patched_server(
def patched_server( # type: ignore
*args: P.args,
interceptors: Optional[Sequence[grpc.ServerInterceptor]] = None,
**kwargs: P.kwargs,
Expand All @@ -121,7 +121,7 @@ def _wrap_async_server(func: Callable[P, AsyncServer]) -> Callable[P, AsyncServe
"""Wrapper for asynchronous server."""

@wraps(func)
def patched_aio_server(
def patched_aio_server( # type: ignore
*args: P.args,
interceptors: Optional[Sequence[grpc.ServerInterceptor]] = None,
**kwargs: P.kwargs,
Expand Down
12 changes: 8 additions & 4 deletions sentry_sdk/integrations/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ def setup_once():


def _get_span_description(host, port):
# type: (Union[bytes, str, None], Union[str, int, None]) -> str
# type: (Union[bytes, str, None], Union[bytes, str, int, None]) -> str

try:
host = host.decode() # type: ignore
except (UnicodeDecodeError, AttributeError):
pass

description = "%s:%s" % (host, port) # type: ignore
try:
port = port.decode() # type: ignore
except (UnicodeDecodeError, AttributeError):
pass

description = "%s:%s" % (host, port) # type: ignore
return description


Expand Down Expand Up @@ -74,7 +78,7 @@ def _patch_getaddrinfo():
real_getaddrinfo = socket.getaddrinfo

def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
# type: (Union[bytes, str, None], Union[str, int, None], int, int, int, int) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]
# type: (Union[bytes, str, None], Union[bytes, str, int, None], int, int, int, int) -> List[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int], Tuple[int, bytes]]]]
integration = sentry_sdk.get_client().get_integration(SocketIntegration)
if integration is None:
return real_getaddrinfo(host, port, family, type, proto, flags)
Expand All @@ -89,4 +93,4 @@ def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):

return real_getaddrinfo(host, port, family, type, proto, flags)

socket.getaddrinfo = getaddrinfo # type: ignore
socket.getaddrinfo = getaddrinfo
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def sentry_execute_request_handler(self, *args, **kwargs):
else:

@coroutine # type: ignore
def sentry_execute_request_handler(self, *args, **kwargs):
def sentry_execute_request_handler(self, *args, **kwargs): # type: ignore
# type: (RequestHandler, *Any, **Any) -> Any
with _handle_request_impl(self):
result = yield from old_execute(self, *args, **kwargs)
Expand Down
Loading