fix: Handle mypy 2.0 related failures by alexander-alderman-webb · Pull Request #6218 · getsentry/sentry-python
Description
Non-integration failures:
sentry_sdk/_compat.py:57: error: Incompatible return value type (got "Literal[b'', ''] | Any | bool", expected "bool") [return-value]
sentry_sdk/serializer.py:341: error: Argument 1 to "enumerate" has incompatible type "object"; expected "Iterable[Never]" [arg-type]
sentry_sdk/serializer.py:343: error: Argument 1 to "len" has incompatible type "object"; expected "Sized" [arg-type]
sentry_sdk/crons/api.py:21: error: Name "check_in_id" already defined on line 15 [no-redef]
sentry_sdk/crons/api.py:26: error: Incompatible types (expression has type "str | None", TypedDict item "check_in_id" has type "str") [typeddict-item]
sentry_sdk/tracing.py:968: error: Name "scope" already defined on line 943 [no-redef]
sentry_sdk/scope.py:521: error: Need type annotation for "incoming_trace_information" [var-annotated]
sentry_sdk/scope.py:1068: error: Name "crumb" already defined on line 1047 [no-redef]
sentry_sdk/scope.py:1069: error: Item "None" of "dict[str, Any] | None" has no attribute "update" [union-attr]
sentry_sdk/scope.py:1073: error: Name "hint" already defined on line 1048 [no-redef]
sentry_sdk/client.py:867: error: Name "hint" already defined on line 854 [no-redef]
sentry_sdk/client.py:869: error: Argument 2 to "_should_capture" of "_Client" has incompatible type "dict[str, Any] | None"; expected "dict[str, Any]" [arg-type]
sentry_sdk/client.py:877: error: Argument 2 to "_prepare_event" of "_Client" has incompatible type "dict[str, Any] | None"; expected "dict[str, Any]" [arg-type]
sentry_sdk/client.py:893: error: Argument 2 to "_should_sample_error" of "_Client" has incompatible type "dict[str, Any] | None"; expected "dict[str, Any]" [arg-type]
sentry_sdk/client.py:897: error: Item "None" of "dict[str, Any] | None" has no attribute "get" [union-attr]
sentry_sdk/client.py:951: error: Unused "type: ignore" comment [unused-ignore]
sentry_sdk/client.py:963: error: Unused "type: ignore" comment [unused-ignore]
sentry_sdk/client.py:965: error: Unused "type: ignore" comment [unused-ignore]
sentry_sdk/hub.py:149: error: Unused "type: ignore" comment [unused-ignore]
openai-agents:
sentry_sdk/integrations/openai_agents/__init__.py:103: error: Item "None" of "Any | None" has no attribute "get_all_tools" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:109: error: Item "None" of "Any | None" has no attribute "get_all_tools" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:114: error: Item "None" of "Any | None" has no attribute "get_model" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:118: error: Item "None" of "Any | None" has no attribute "get_model" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:122: error: Item "None" of "Any | None" has no attribute "run_single_turn" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:126: error: Item "None" of "Any | None" has no attribute "run_single_turn" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:130: error: Item "None" of "Any | None" has no attribute "run_single_turn_streamed" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:135: error: Item "None" of "Any | None" has no attribute "run_single_turn_streamed" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:140: error: Item "None" of "Any | None" has no attribute "execute_handoffs" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:154: error: Item "None" of "Any | None" has no attribute "execute_final_output" [union-attr]
sentry_sdk/integrations/openai_agents/__init__.py:156: error: Item "None" of "Any | None" has no attribute "execute_final_output" [union-attr]
mcp:
sentry_sdk/integrations/mcp.py:499: error: Item "None" of "Any | None" has no attribute "scheme" [union-attr]
sentry_sdk/integrations/mcp.py:642: error: Item "None" of "Any | None" has no attribute "_get_prompt_mcp" [union-attr]
sentry_sdk/integrations/mcp.py:656: error: Item "None" of "Any | None" has no attribute "_get_prompt_mcp" [union-attr]
sentry_sdk/integrations/mcp.py:659: error: Item "None" of "Any | None" has no attribute "_read_resource_mcp" [union-attr]
sentry_sdk/integrations/mcp.py:673: error: Item "None" of "Any | None" has no attribute "_read_resource_mcp" [union-attr]
dramatiq:
sentry_sdk/integrations/opentelemetry/integration.py:55: error: "None" not callable [misc]
opentelemetry:
sentry_sdk/integrations/dramatiq.py:61: error: Need type annotation for "args" [var-annotated]
sentry_sdk/integrations/dramatiq.py:73: error: Unused "type: ignore" comment [unused-ignore]
cloud_resource_context:
sentry_sdk/integrations/cloud_resource_context.py:193: error: Value of type "None" is not indexable [index]
sentry_sdk/integrations/cloud_resource_context.py:198: error: Value of type "None" is not indexable [index]
sentry_sdk/integrations/cloud_resource_context.py:206: error: Value of type "None" is not indexable [index]
sentry_sdk/integrations/cloud_resource_context.py:213: error: Value of type "None" is not indexable [index]
grpc:
sentry_sdk/integrations/grpc/__init__.py:155: error: Name "interceptors" already defined on line 151 [no-redef]
sentry_sdk/integrations/grpc/__init__.py:166: error: Argument 1 to "tuple" has incompatible type "Sequence[Any] | None"; expected "Iterable[Any]" [arg-type]
sanic:
sentry_sdk/integrations/sanic.py:76: error: Incompatible types in assignment (expression has type "tuple[int, ...] | None", variable has type "None") [assignment]
starlette:
sentry_sdk/integrations/starlette.py:478: error: "Any | Callable[..., Any]" not callable [operator]
wsgi:
sentry_sdk/integrations/_wsgi_common.py:113: error: Exception type must be derived from BaseException (or be a tuple of exception classes) [misc]
sentry_sdk/integrations/_wsgi_common.py:178: error: Exception type must be derived from BaseException (or be a tuple of exception classes) [misc]
gnu_backtrace:
sentry_sdk/integrations/gnu_backtrace.py:72: error: Item "str" of "str | Pattern[str]" has no attribute "match" [union-attr]
django:
sentry_sdk/integrations/django/asgi.py:47: error: Unused "type: ignore" comment [unused-ignore]
sentry_sdk/integrations/django/__init__.py:144: error: Incompatible types in assignment (expression has type "bool", variable has type "None") [assignment]
sentry_sdk/integrations/django/__init__.py:146: error: Incompatible types in assignment (expression has type "bool", variable has type "None") [assignment]
sentry_sdk/integrations/django/__init__.py:149: error: Incompatible types in assignment (expression has type "bool", variable has type "None") [assignment]
Issues
Reminders
- Please add tests to validate your changes, and lint your code using
tox -e linters. - Add GH Issue ID & Linear ID (if applicable)
- PR title should use conventional commit style (
feat:,fix:,ref:,meta:) - For external contributors: CONTRIBUTING.md, Sentry SDK development docs, Discord community