Skip to content

Comments

[ty] improve reachability analysis for with statement#23136

Draft
mtshiba wants to merge 4 commits intoastral-sh:mainfrom
mtshiba:with-can-suppress-exception
Draft

[ty] improve reachability analysis for with statement#23136
mtshiba wants to merge 4 commits intoastral-sh:mainfrom
mtshiba:with-can-suppress-exception

Conversation

@mtshiba
Copy link
Collaborator

@mtshiba mtshiba commented Feb 7, 2026

Summary

This PR closes astral-sh/ty#152.

Test Plan

mdtest updated

@mtshiba mtshiba added ty Multi-file analysis & type inference ecosystem-analyzer labels Feb 7, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 7, 2026

Typing conformance results regressed ❌

The percentage of diagnostics emitted that were expected errors decreased from 82.27% to 82.10%. The percentage of expected errors that received a diagnostic held steady at 72.99%.

Summary

Metric Old New Diff Outcome
True Positives 789 789 +0
False Positives 170 172 +2 ⏫ (❌)
False Negatives 292 292 +0
Total Diagnostics 959 961 +2
Precision 82.27% 82.10% -0.17% ⏬ (❌)
Recall 72.99% 72.99% +0.00%

False positives removed

Details
Location Name Message
exceptions_context_managers.py:50:5 type-assertion-failure Type int | str does not match asserted type str
exceptions_context_managers.py:57:5 type-assertion-failure Type int | str does not match asserted type str

False positives added

Details
Location Name Message
exceptions_context_managers.py:64:5 type-assertion-failure Type str does not match asserted type int | str
exceptions_context_managers.py:71:5 type-assertion-failure Type str does not match asserted type int | str
exceptions_context_managers.py:78:5 type-assertion-failure Type str does not match asserted type int | str
exceptions_context_managers.py:85:5 type-assertion-failure Type str does not match asserted type int | str

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 7, 2026

mypy_primer results

Changes were detected when running on open source projects
more-itertools (https://github.com/more-itertools/more-itertools)
+ more_itertools/more.py:3840:23: warning[possibly-unresolved-reference] Name `reservoir` used when possibly not defined
+ more_itertools/more.py:3849:13: warning[possibly-unresolved-reference] Name `reservoir` used when possibly not defined
+ more_itertools/more.py:3851:13: warning[possibly-unresolved-reference] Name `reservoir` used when possibly not defined
+ more_itertools/more.py:3852:12: warning[possibly-unresolved-reference] Name `reservoir` used when possibly not defined
- Found 37 diagnostics
+ Found 41 diagnostics

anyio (https://github.com/agronholm/anyio)
+ src/anyio/_backends/_asyncio.py:1527:9: warning[possibly-unresolved-reference] Name `client_sock` used when possibly not defined
+ src/anyio/_backends/_asyncio.py:1529:29: warning[possibly-unresolved-reference] Name `client_sock` used when possibly not defined
+ src/anyio/_backends/_asyncio.py:2445:10: error[invalid-return-type] Function can implicitly return `None`, which is not assignable to return type `T_Retval@run_sync_in_worker_thread`
+ src/anyio/from_thread.py:274:35: warning[possibly-unresolved-reference] Name `retval` used when possibly not defined
+ src/anyio/to_process.py:49:6: error[invalid-return-type] Function can implicitly return `None`, which is not assignable to return type `T_Retval@run_sync`
- Found 89 diagnostics
+ Found 94 diagnostics

spack (https://github.com/spack/spack)
+ lib/spack/spack/cmd/unit_test.py:229:16: warning[possibly-missing-attribute] Attribute `main` may be missing on object of type `Unknown | None`
+ lib/spack/spack/cmd/unit_test.py:262:16: warning[possibly-missing-attribute] Attribute `main` may be missing on object of type `Unknown | None`
+ lib/spack/spack/util/package_hash.py:380:12: error[no-matching-overload] No overload of function `parse` matches arguments
- Found 4344 diagnostics
+ Found 4347 diagnostics

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/test.py:1117:44: warning[possibly-missing-attribute] Attribute `environ` may be missing on object of type `None | @Todo | Request`
+ src/werkzeug/test.py:1150:36: warning[possibly-missing-attribute] Attribute `input_stream` may be missing on object of type `None | @Todo | Request`
- Found 394 diagnostics
+ Found 396 diagnostics

starlette (https://github.com/encode/starlette)
+ starlette/middleware/base.py:130:24: warning[possibly-unresolved-reference] Name `message` used when possibly not defined
- Found 191 diagnostics
+ Found 192 diagnostics

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/_code/source.py:195:50: error[invalid-argument-type] Argument to function `get_statement_startend2` is incorrect: Expected `AST`, found `AST | None`
+ src/_pytest/_code/source.py:228:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[AST, int, int]`, found `tuple[AST | None, int, int]`
+ src/_pytest/pytester.py:1467:26: warning[possibly-unresolved-reference] Name `ret` used when possibly not defined
- testing/python/raises.py:364:54: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- testing/python/raises_group.py:176:71: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- testing/python/raises_group.py:290:69: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- testing/python/raises_group.py:301:69: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ testing/test_recwarn.py:326:46: warning[possibly-unresolved-reference] Name `warninfo` used when possibly not defined

dulwich (https://github.com/dulwich/dulwich)
+ dulwich/mbox.py:302:9: error[invalid-argument-type] Argument to function `mailinfo` is incorrect: Expected `Message[str, str] | BinaryIO | TextIO`, found `str | bytes | BinaryIO | TextIO`
- Found 218 diagnostics
+ Found 219 diagnostics

pybind11 (https://github.com/pybind/pybind11)
+ tests/test_local_bindings.py:37:31: warning[possibly-unresolved-reference] Name `rc_before` used when possibly not defined
- Found 216 diagnostics
+ Found 217 diagnostics

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/auths.py:148:16: warning[possibly-missing-attribute] Attribute `data` may be missing on object of type `CacheEntry[Auth@CachingAuthProvider] | None`
- Found 317 diagnostics
+ Found 318 diagnostics

optuna (https://github.com/optuna/optuna)
+ optuna/storages/_rdb/storage.py:297:44: error[invalid-argument-type] Argument to bound method `get_study_id_from_name` is incorrect: Expected `str`, found `str | None`
- Found 569 diagnostics
+ Found 570 diagnostics

urllib3 (https://github.com/urllib3/urllib3)
+ test/test_connectionpool.py:491:29: warning[possibly-missing-attribute] Attribute `qsize` may be missing on object of type `LifoQueue[Any] | None`
- Found 285 diagnostics
+ Found 286 diagnostics

pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_core_metadata.py:87:54: error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | ((dict[str, int | float | str | ... omitted 3 union elements], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
+ pydantic/_internal/_core_metadata.py:87:54: error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | ((dict[str, Divergent], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
- pydantic/fields.py:949:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:949:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:989:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:989:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1032:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1032:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1072:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1072:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1115:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1115:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1154:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1154:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1194:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
+ pydantic/fields.py:1194:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
- pydantic/fields.py:1573:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`, found `Top[dict[Unknown, Unknown]] | (((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`
+ pydantic/fields.py:1573:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`, found `Top[dict[Unknown, Unknown]] | (((dict[str, Divergent], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`

Expression (https://github.com/cognitedata/Expression)
+ tests/test_compose.py:21:16: error[invalid-assignment] Object of type `(Never, /) -> Never` is not assignable to `(int, /) -> int`
- Found 204 diagnostics
+ Found 205 diagnostics

artigraph (https://github.com/artigraph/artigraph)
+ src/arti/graphs/__init__.py:245:13: error[invalid-argument-type] Argument to function `read` is incorrect: Expected `tuple[StoragePartitionSnapshot, ...]`, found `tuple[StoragePartitionSnapshot, ...] | None | Unknown`
- Found 146 diagnostics
+ Found 147 diagnostics

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/_server_cursor.py:145:34: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `list[Row@ServerCursor] | None | Unknown`
+ psycopg/psycopg/_server_cursor.py:148:15: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ psycopg/psycopg/_server_cursor.py:148:15: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ psycopg/psycopg/_server_cursor_async.py:143:34: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `list[Row@AsyncServerCursor] | None | Unknown`
+ psycopg/psycopg/_server_cursor_async.py:146:15: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ psycopg/psycopg/_server_cursor_async.py:146:15: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/pool/test_pool.py:133:46: warning[possibly-unresolved-reference] Name `pid` used when possibly not defined
+ tests/pool/test_pool_async.py:133:46: warning[possibly-unresolved-reference] Name `pid` used when possibly not defined
+ tests/test_cursor_common.py:824:5: warning[possibly-unresolved-reference] Name `gen` used when possibly not defined
+ tests/test_cursor_common_async.py:832:11: warning[possibly-unresolved-reference] Name `gen` used when possibly not defined
+ tests/test_pipeline.py:70:12: warning[possibly-unresolved-reference] Name `closed` used when possibly not defined
+ tests/test_pipeline.py:479:16: warning[possibly-unresolved-reference] Name `inner` used when possibly not defined
+ tests/test_pipeline_async.py:67:12: warning[possibly-unresolved-reference] Name `closed` used when possibly not defined
+ tests/test_pipeline_async.py:478:22: warning[possibly-unresolved-reference] Name `inner` used when possibly not defined
+ tests/test_waiting.py:372:24: warning[possibly-unresolved-reference] Name `t0` used when possibly not defined
+ tests/test_waiting_async.py:380:24: warning[possibly-unresolved-reference] Name `t0` used when possibly not defined
- Found 654 diagnostics
+ Found 670 diagnostics

sphinx (https://github.com/sphinx-doc/sphinx)
- sphinx/builders/latex/__init__.py:340:90: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ sphinx/builders/latex/__init__.py:335:45: warning[possibly-unresolved-reference] Name `doctree` used when possibly not defined
+ sphinx/builders/latex/__init__.py:339:17: warning[possibly-unresolved-reference] Name `doctree` used when possibly not defined
+ sphinx/builders/latex/__init__.py:341:17: warning[possibly-unresolved-reference] Name `doctree` used when possibly not defined
+ sphinx/builders/singlehtml.py:177:61: warning[possibly-unresolved-reference] Name `doctree` used when possibly not defined
+ sphinx/builders/singlehtml.py:178:50: warning[possibly-unresolved-reference] Name `doctree` used when possibly not defined
- sphinx/builders/texinfo.py:125:85: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ sphinx/builders/texinfo.py:112:42: warning[possibly-unresolved-reference] Name `doctree` used when possibly not defined
+ sphinx/builders/texinfo.py:124:17: warning[possibly-unresolved-reference] Name `doctree` used when possibly not defined
+ sphinx/builders/texinfo.py:126:17: warning[possibly-unresolved-reference] Name `doctree` used when possibly not defined
- sphinx/util/display.py:91:63: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 344 diagnostics
+ Found 349 diagnostics

mkdocs (https://github.com/mkdocs/mkdocs)
+ mkdocs/structure/files.py:440:23: warning[possibly-missing-attribute] Attribute `encode` may be missing on object of type `str | None`
+ mkdocs/structure/files.py:464:23: warning[possibly-missing-attribute] Attribute `decode` may be missing on object of type `bytes | None`
- Found 223 diagnostics
+ Found 225 diagnostics

trio (https://github.com/python-trio/trio)
+ src/trio/_core/_tests/test_cancelled.py:76:12: warning[possibly-unresolved-reference] Name `excinfo` used when possibly not defined
+ src/trio/_core/_tests/test_cancelled.py:77:12: warning[possibly-unresolved-reference] Name `excinfo` used when possibly not defined
+ src/trio/_core/_tests/test_cancelled.py:78:12: warning[possibly-unresolved-reference] Name `excinfo` used when possibly not defined
+ src/trio/_core/_tests/test_run.py:651:12: warning[possibly-unresolved-reference] Name `scope3` used when possibly not defined
+ src/trio/_core/_tests/test_run.py:652:16: warning[possibly-unresolved-reference] Name `scope3` used when possibly not defined
+ src/trio/_core/_tests/test_run.py:653:12: warning[possibly-unresolved-reference] Name `scope2` used when possibly not defined
+ src/trio/_core/_tests/test_run.py:654:12: warning[possibly-unresolved-reference] Name `scope2` used when possibly not defined
+ src/trio/_core/_tests/test_run.py:691:16: warning[possibly-unresolved-reference] Name `inner` used when possibly not defined
+ src/trio/_core/_tests/test_run.py:2844:16: warning[possibly-unresolved-reference] Name `scope` used when possibly not defined
+ src/trio/_tests/test_file_io.py:254:12: warning[possibly-unresolved-reference] Name `f` used when possibly not defined
+ src/trio/_tests/test_highlevel_open_tcp_stream.py:693:5: error[unresolved-reference] Name `scenario` used when not defined
+ src/trio/_tests/test_subprocess.py:520:20: warning[possibly-unresolved-reference] Name `proc` used when possibly not defined
+ src/trio/_tests/test_subprocess.py:522:20: warning[possibly-unresolved-reference] Name `proc` used when possibly not defined
+ src/trio/_tests/test_subprocess.py:707:12: warning[possibly-unresolved-reference] Name `proc` used when possibly not defined
- src/trio/_tests/test_testing_raisesgroup.py:161:71: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/trio/_tests/test_testing_raisesgroup.py:271:69: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/trio/_tests/test_testing_raisesgroup.py:282:69: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 470 diagnostics
+ Found 481 diagnostics

pyodide (https://github.com/pyodide/pyodide)
+ pyodide-build/pyodide_build/pypabuild.py:192:38: error[invalid-argument-type] Argument to function `install_reqs` is incorrect: Expected `set[str]`, found `None | Unknown`
- Found 940 diagnostics
+ Found 941 diagnostics

apprise (https://github.com/caronc/apprise)
+ apprise/plugins/pushover.py:353:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Unknown | str | dict[Unknown | int, Unknown | str] | int | tuple[str, str]` and `Literal[30]`
+ apprise/plugins/pushover.py:358:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Unknown | str | dict[Unknown | int, Unknown | str] | int | tuple[str, str]` and `Literal[0]`
+ apprise/plugins/pushover.py:358:35: error[unsupported-operator] Operator `>` is not supported between objects of type `Unknown | str | dict[Unknown | int, Unknown | str] | int | tuple[str, str]` and `Literal[10800]`
+ apprise/plugins/slack.py:960:23: error[not-subscriptable] Cannot subscript object of type `bool` with no `__getitem__` method
- apprise/plugins/vapid/__init__.py:251:17: error[unsupported-operator] Operator `<` is not supported between objects of type `int` and `Unknown | str | tuple[Unknown | str, Unknown | str, Unknown | str, Unknown | str, Unknown | str] | int`
+ apprise/plugins/vapid/__init__.py:251:17: error[unsupported-operator] Operator `<` is not supported between two objects of type `Unknown | str | tuple[Unknown | str, Unknown | str, Unknown | str, Unknown | str, Unknown | str] | int`
- apprise/plugins/vapid/__init__.py:252:20: error[unsupported-operator] Operator `>` is not supported between objects of type `int` and `Unknown | str | tuple[Unknown | str, Unknown | str, Unknown | str, Unknown | str, Unknown | str] | int`
+ apprise/plugins/vapid/__init__.py:252:20: error[unsupported-operator] Operator `>` is not supported between two objects of type `Unknown | str | tuple[Unknown | str, Unknown | str, Unknown | str, Unknown | str, Unknown | str] | int`
- apprise/plugins/vonage.py:176:13: error[unsupported-operator] Operator `<` is not supported between objects of type `int` and `Unknown | str | int`
+ apprise/plugins/vonage.py:176:13: error[unsupported-operator] Operator `<` is not supported between two objects of type `Unknown | str | int`
- apprise/plugins/vonage.py:177:16: error[unsupported-operator] Operator `>` is not supported between objects of type `int` and `Unknown | str | int`
+ apprise/plugins/vonage.py:177:16: error[unsupported-operator] Operator `>` is not supported between two objects of type `Unknown | str | int`
- Found 3155 diagnostics
+ Found 3159 diagnostics

cloud-init (https://github.com/canonical/cloud-init)
+ tests/unittests/test_gpg.py:194:32: warning[possibly-unresolved-reference] Name `gpg_context` used when possibly not defined
+ tests/unittests/test_gpg.py:198:38: warning[possibly-unresolved-reference] Name `gpg_context` used when possibly not defined
+ tests/unittests/test_gpg.py:208:38: warning[possibly-unresolved-reference] Name `gpg_context` used when possibly not defined
- Found 1149 diagnostics
+ Found 1152 diagnostics

setuptools (https://github.com/pypa/setuptools)
- setuptools/_distutils/command/install.py:719:42: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Never]`, found `map[str]`
+ setuptools/_vendor/more_itertools/more.py:3861:23: warning[possibly-unresolved-reference] Name `reservoir` used when possibly not defined
+ setuptools/_vendor/more_itertools/more.py:3870:13: warning[possibly-unresolved-reference] Name `reservoir` used when possibly not defined
+ setuptools/_vendor/more_itertools/more.py:3872:13: warning[possibly-unresolved-reference] Name `reservoir` used when possibly not defined
+ setuptools/_vendor/more_itertools/more.py:3873:12: warning[possibly-unresolved-reference] Name `reservoir` used when possibly not defined
+ setuptools/_vendor/wheel/_commands/tags.py:118:13: error[no-matching-overload] No overload of function `dirname` matches arguments
+ setuptools/_vendor/wheel/_commands/tags.py:120:41: error[no-matching-overload] No overload of function `dirname` matches arguments
- Found 1167 diagnostics
+ Found 1172 diagnostics

strawberry (https://github.com/strawberry-graphql/strawberry)
+ strawberry/schema/schema.py:750:29: error[invalid-argument-type] Argument to function `execute` is incorrect: Expected `DocumentNode`, found `DocumentNode | None`
+ strawberry/schema/schema.py:796:18: warning[possibly-missing-attribute] Attribute `data` may be missing on object of type `ExecutionResult | Unknown | None`
+ strawberry/schema/schema.py:797:20: warning[possibly-missing-attribute] Attribute `errors` may be missing on object of type `ExecutionResult | Unknown | None`
- Found 344 diagnostics
+ Found 347 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
+ src/integrations/prefect-docker/prefect_docker/deployments/steps.py:325:12: error[invalid-return-type] Return type does not match returned value: expected `BuildDockerImageResult`, found `dict[Unknown | str, Unknown | str | None | (list[str] & ~AlwaysFalsy) | list[Unknown]]`
+ src/integrations/prefect-docker/prefect_docker/deployments/steps.py:327:16: error[invalid-argument-type] Invalid argument to key "tag" with declared type `str` on TypedDict `BuildDockerImageResult`: value of type `str | None`
+ src/integrations/prefect-docker/prefect_docker/deployments/steps.py:329:21: error[invalid-argument-type] Invalid argument to key "image_id" with declared type `str` on TypedDict `BuildDockerImageResult`: value of type `None | (Unknown & str)`
- src/prefect/input/run_input.py:672:20: error[invalid-return-type] Return type does not match returned value: expected `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]`, found `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler] | Coroutine[Any, Any, T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]]`
+ src/prefect/input/run_input.py:672:20: error[invalid-return-type] Return type does not match returned value: expected `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]`, found `Unknown | Coroutine[Any, Any, Unknown]`
+ src/prefect/server/events/actions.py:1447:16: error[invalid-return-type] Return type does not match returned value: expected `WorkPool`, found `WorkPool | None`
- Found 5490 diagnostics
+ Found 5494 diagnostics

xarray (https://github.com/pydata/xarray)
+ xarray/util/print_versions.py:35:47: error[invalid-argument-type] Argument to bound method `strip` is incorrect: Expected `Buffer | None`, found `Literal["\""]`
- Found 1718 diagnostics
+ Found 1719 diagnostics

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/cwlprov/ro.py:667:45: error[unsupported-operator] Operator `/` is not supported between objects of type `PurePosixPath` and `None | PurePosixPath | str`
+ cwltool/docker.py:54:12: error[invalid-return-type] Return type does not match returned value: expected `list[str]`, found `list[str] | None`
+ cwltool/load_tool.py:420:18: error[no-matching-overload] No overload of function `sub` matches arguments
- Found 511 diagnostics
+ Found 514 diagnostics

ibis (https://github.com/ibis-project/ibis)
+ ibis/common/temporal.py:196:25: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Decimal | int | float | str | tuple[int, Sequence[int], int]`, found `(Real & ~timedelta) | (Unknown & ~timedelta)`
+ ibis/expr/visualize.py:32:33: error[unresolved-attribute] Module `ibis.expr.operations` has no member `Join`
+ ibis/expr/visualize.py:33:63: error[unresolved-attribute] Module `ibis.expr.operations` has no member `genname`
+ ibis/expr/visualize.py:35:65: error[unresolved-attribute] Module `ibis.expr.operations` has no member `genname`
+ ibis/expr/visualize.py:53:31: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | Attribute`
+ ibis/expr/visualize.py:53:45: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | Attribute`
- Found 4827 diagnostics
+ Found 4833 diagnostics

pandas (https://github.com/pandas-dev/pandas)
+ pandas/plotting/_matplotlib/boxplot.py:470:9: warning[possibly-missing-attribute] Attribute `grid` may be missing on object of type `Unknown | None`
- Found 4437 diagnostics
+ Found 4438 diagnostics

zulip (https://github.com/zulip/zulip)
+ tools/lib/template_parser.py:366:13: warning[possibly-missing-attribute] Attribute `split` may be missing on object of type `str | None`
+ tools/lib/template_parser.py:369:27: error[invalid-argument-type] Argument to function `tokenize` is incorrect: Expected `str`, found `str | None`
+ zerver/lib/narrow_helpers.py:63:12: error[invalid-return-type] Return type does not match returned value: expected `list[str]`, found `list[str] | None`
- Found 3597 diagnostics
+ Found 3600 diagnostics

materialize (https://github.com/MaterializeInc/materialize)
+ misc/python/materialize/cli/mz_workload_anonymize.py:251:13: error[no-matching-overload] No overload of bound method `join` matches arguments
+ misc/python/materialize/mzbuild.py:266:8: error[unsupported-operator] Operator `in` is not supported between objects of type `str` and `set[str] | None`
+ misc/python/materialize/mzbuild.py:322:13: warning[possibly-missing-attribute] Attribute `add` may be missing on object of type `set[str] | None`
+ misc/python/materialize/mzbuild.py:341:8: error[unsupported-operator] Operator `in` is not supported between objects of type `str` and `set[str] | None`
+ misc/python/materialize/mzbuild.py:381:13: warning[possibly-missing-attribute] Attribute `add` may be missing on object of type `set[str] | None`
- Found 534 diagnostics
+ Found 539 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/tests/test_quaternion.py:75:10: error[not-subscriptable] Cannot subscript object of type `T2'return@call_highest_priority` with no `__getitem__` method
+ sympy/algebras/tests/test_quaternion.py:75:10: error[not-subscriptable] Cannot subscript object of type `T1'return@call_highest_priority` with no `__getitem__` method
- sympy/functions/combinatorial/factorials.py:967:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:967:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
- sympy/functions/combinatorial/factorials.py:968:29: warning[possibly-missing-attribute] Attribute `is_nonnegative` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:968:47: warning[possibly-missing-attribute] Attribute `is_integer` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:969:12: warning[possibly-missing-attribute] Attribute `is_zero` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:972:13: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:972:13: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic` and `Literal[1]`
- sympy/functions/combinatorial/factorials.py:975:12: warning[possibly-missing-attribute] Attribute `is_integer` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:976:16: warning[possibly-missing-attribute] Attribute `is_negative` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:978:18: warning[possibly-missing-attribute] Attribute `is_number` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:984:14: warning[possibly-missing-attribute] Attribute `is_number` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:986:26: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:986:26: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic` and `Literal[1]`
- sympy/functions/combinatorial/factorials.py:986:40: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:986:40: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic` and `Literal[1]`
- sympy/functions/combinatorial/factorials.py:986:53: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:986:53: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
- sympy/geometry/point.py:1295:25: warning[possibly-missing-attribute] Attribute `tolist` may be missing on object of type `MatrixBase | Expr`
+ sympy/geometry/point.py:1295:25: warning[possibly-missing-attribute] Attribute `tolist` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/geometry/polygon.py:1500:12: warning[possibly-missing-attribute] Attribute `is_Number` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/geometry/polygon.py:1501:20: error[invalid-argument-type] Argument to function `as_int` is incorrect: Expected `SupportsIndex`, found `Basic | int | float | complex | Any`
+ sympy/geometry/polygon.py:1501:20: error[invalid-argument-type] Argument to function `as_int` is incorrect: Expected `SupportsIndex`, found `Basic`
- sympy/geometry/polygon.py:1502:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[3]`
+ sympy/geometry/polygon.py:1502:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Basic` and `Literal[3]`
- sympy/geometry/polygon.py:1509:40: warning[possibly-missing-attribute] Attribute `is_number` may be missing on object of type `Basic | int | float | complex | Any`
- sympy/integrals/tests/test_heurisch.py:390:26: error[not-subscriptable] Cannot subscript object of type `Expr` with no `__getitem__` method
+ sympy/integrals/tests/test_heurisch.py:389:17: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
- sympy/matrices/decompositions.py:1321:16: warning[possibly-missing-attribute] Attribute `diagonalize` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/decompositions.py:1321:16: warning[possibly-missing-attribute] Attribute `diagonalize` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
+ sympy/matrices/decompositions.py:1334:13: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MatrixBase`
- sympy/matrices/decompositions.py:1336:16: warning[possibly-missing-attribute] Attribute `diagonalize` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/decompositions.py:1336:16: warning[possibly-missing-attribute] Attribute `diagonalize` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
+ sympy/matrices/decompositions.py:1348:13: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MatrixBase`
- sympy/matrices/decompositions.py:1350:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[Tmat@_singular_value_decomposition, Tmat@_singular_value_decomposition, Tmat@_singular_value_decomposition]`, found `tuple[MatrixBase | Expr | Unknown, MatrixBase, MatrixBase | Expr | Unknown]`
+ sympy/matrices/decompositions.py:1350:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[Tmat@_singular_value_decomposition, Tmat@_singular_value_decomposition, Tmat@_singular_value_decomposition]`, found `tuple[Unknown | MatrixBase, MatrixBase, MatrixBase | Unknown]`
+ sympy/matrices/eigen.py:328:22: error[invalid-argument-type] Argument to bound method `_as_type` is incorrect: Expected `MatrixBase`, found `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Unknown`
- sympy/matrices/expressions/tests/test_derivatives.py:551:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `MatrixBase | Expr`
+ sympy/matrices/expressions/tests/test_derivatives.py:551:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/expressions/tests/test_matadd.py:36:12: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr`
+ sympy/matrices/expressions/tests/test_matadd.py:36:12: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase` and `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/expressions/tests/test_matmul.py:158:68: warning[possibly-missing-attribute] Attribute `as_explicit` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/expressions/tests/test_matmul.py:158:68: warning[possibly-missing-attribute] Attribute `as_explicit` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
+ sympy/matrices/expressions/tests/test_matpow.py:123:46: error[unsupported-operator] Operator `**` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `Literal[2]`
- sympy/matrices/expressions/tests/test_permutation.py:27:12: warning[possibly-missing-attribute] Attribute `as_explicit` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/expressions/tests/test_permutation.py:27:12: warning[possibly-missing-attribute] Attribute `as_explicit` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/inverse.py:385:11: error[unsupported-operator] Operator `-` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr | Unknown`
+ sympy/matrices/inverse.py:384:11: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MatrixBase`
+ sympy/matrices/inverse.py:392:11: error[unsupported-operator] Unary operator `-` is not supported for object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/inverse.py:393:11: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr | Unknown`
+ sympy/matrices/inverse.py:393:19: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MatrixBase | Expr`
+ sympy/matrices/inverse.py:393:22: error[unsupported-operator] Unary operator `-` is not supported for object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/matrixbase.py:3046:5: error[invalid-argument-type] Argument is incorrect: Expected `(MatrixBase, MatrixBase | Expr, /) -> MatrixBase | Expr`, found `Overload[[Self](self, other: Self) -> Self, (self, other: MatrixBase) -> MatrixBase, (self, other: Expr) -> MatrixBase]`
+ sympy/matrices/matrixbase.py:3046:5: error[invalid-argument-type] Argument is incorrect: Expected `(T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr, T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr, /) -> T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`, found `Overload[[Self](self, other: Self) -> Self, (self, other: MatrixBase) -> MatrixBase, (self, other: Expr) -> MatrixBase]`
+ sympy/matrices/matrixbase.py:3944:39: error[not-subscriptable] Cannot subscript object of type `T2'return@call_highest_priority` with no `__getitem__` method
+ sympy/matrices/matrixbase.py:3944:39: error[not-subscriptable] Cannot subscript object of type `T1'return@call_highest_priority` with no `__getitem__` method
- sympy/matrices/matrixbase.py:4640:16: error[invalid-return-type] Return type does not match returned value: expected `Self@D`, found `MatrixBase | Expr`
+ sympy/matrices/matrixbase.py:4640:16: error[invalid-return-type] Return type does not match returned value: expected `Self@D`, found `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
+ sympy/matrices/matrixbase.py:4748:16: error[not-subscriptable] Cannot subscript object of type `T1'return@call_highest_priority` with no `__getitem__` method
+ sympy/matrices/matrixbase.py:4748:16: error[not-subscriptable] Cannot subscript object of type `T2'return@call_highest_priority` with no `__getitem__` method
- sympy/matrices/matrixbase.py:5078:16: error[invalid-return-type] Return type does not match returned value: expected `Self@log`, found `MatrixBase | @Todo | Expr`
+ sympy/matrices/matrixbase.py:5076:19: error[unsupported-operator] Operator `*` is not supported between objects of type `@Todo | T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `@Todo | Self@log`
+ sympy/matrices/solvers.py:637:27: error[invalid-argument-type] Argument to bound method `vstack` is incorrect: Argument type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Unknown` does not satisfy upper bound `MatrixBase` of type variable `Self`
+ sympy/matrices/solvers.py:637:27: error[invalid-argument-type] Argument to bound method `vstack` is incorrect: Expected `Tmat@_gauss_jordan_solve`, found `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Unknown`
- sympy/matrices/solvers.py:976:16: warning[possibly-missing-attribute] Attribute `solve` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/solvers.py:976:16: warning[possibly-missing-attribute] Attribute `solve` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/solvers.py:976:30: error[invalid-argument-type] Argument to bound method `solve` is incorrect: Argument type `MatrixBase | Expr` does not satisfy upper bound `MatrixBase` of type variable `Self`
+ sympy/matrices/solvers.py:976:30: error[invalid-argument-type] Argument to bound method `solve` is incorrect: Argument type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` does not satisfy upper bound `MatrixBase` of type variable `Self`
- sympy/matrices/solvers.py:976:30: error[invalid-argument-type] Argument to bound method `solve` is incorrect: Expected `MatrixBase`, found `MatrixBase | Expr`
+ sympy/matrices/solvers.py:976:30: error[invalid-argument-type] Argument to bound method `solve` is incorrect: Expected `MatrixBase`, found `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/sparse.py:417:16: warning[possibly-missing-attribute] Attribute `inv` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/sparse.py:417:16: warning[possibly-missing-attribute] Attribute `inv` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/tests/test_decompositions.py:23:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:23:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/tests/test_decompositions.py:32:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:32:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/tests/test_decompositions.py:42:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:42:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/tests/test_decompositions.py:51:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:51:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/tests/test_decompositions.py:57:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:57:12: warning[possibly-missing-attribute] Attribute `permute_rows` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:77:19: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:84:19: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:90:19: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:103:12: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:110:12: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:123:12: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
- sympy/matrices/tests/test_decompositions.py:131:12: error[no-matching-overload] No overload of function `simplify` matches arguments
+ sympy/matrices/tests/test_decompositions.py:131:21: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
- sympy/matrices/tests/test_decompositions.py:288:10: warning[possibly-missing-attribute] Attribute `applyfunc` may be missing on object of type `MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:288:10: warning[possibly-missing-attribute] Attribute `applyfunc` may be missing on object of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/tests/test_decompositions.py:393:16: error[no-matching-overload] No overload of function `simplify` matches arguments
- sympy/matrices/tests/test_decompositions.py:394:16: error[no-matching-overload] No overload of function `simplify` matches arguments
+ sympy/matrices/tests/test_decompositions.py:290:13: error[unsupported-operator] Operator `-` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:345:12: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:348:12: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:355:23: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:393:25: error[unsupported-operator] Operator `*` is not supported between objects of type `Unknown | T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `Unknown | MutableDenseMatrix`
+ sympy/matrices/tests/test_decompositions.py:394:25: error[unsupported-operator] Operator `*` is not supported between objects of type `Unknown | T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_decompositions.py:395:16: warning[possibly-missing-attribute] Attribute `H` may be missing on object of type `Unknown | MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:395:16: warning[possibly-missing-attribute] Attribute `H` may be missing on object of type `Unknown | T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/tests/test_decompositions.py:396:16: warning[possibly-missing-attribute] Attribute `H` may be missing on object of type `Unknown | MatrixBase | Expr`
+ sympy/matrices/tests/test_decompositions.py:396:16: warning[possibly-missing-attribute] Attribute `H` may be missing on object of type `Unknown | T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/tests/test_decompositions.py:439:13: error[no-matching-overload] No overload of function `simplify` matches arguments
+ sympy/matrices/tests/test_decompositions.py:439:22: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
- sympy/matrices/tests/test_decompositions.py:451:12: error[no-matching-overload] No overlo

... (truncated 409 lines) ...

No memory usage changes detected ✅

@mtshiba mtshiba force-pushed the with-can-suppress-exception branch from c37085e to 31378c6 Compare February 7, 2026 10:16
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 7, 2026

ecosystem-analyzer results

Failing projects:

Project Old Status New Status Old Return Code New Return Code
setuptools abnormal exit abnormal exit 2 2

Diagnostic changes:

Lint rule Added Removed Changed
not-subscriptable 106 1 0
unsupported-operator 92 1 14
possibly-unresolved-reference 101 0 0
possibly-missing-attribute 33 5 36
invalid-argument-type 29 1 7
no-matching-overload 3 20 0
invalid-return-type 9 1 2
unused-type-ignore-comment 0 11 0
unresolved-attribute 5 0 4
invalid-assignment 1 2 0
invalid-await 2 0 0
invalid-context-manager 2 0 0
not-iterable 0 0 2
Total 383 42 65

Full report with detailed diff (timing results)

@AlexWaygood
Copy link
Member

Rather than testing if the value returned by __exit__ is or isn't always truthy, it might be better to test it the value returned by __exit__ is or isn't assignable to AlwaysFalsy. This has the advantage that if the function is unannotated or annotated as returning Any, we will understand the function's return type as being assignable to AlwaysFalsy, so we will assume that the context manager does not suppress exceptions (which is lenient behaviour from us, consistent with the gradual guarantee). But if it's annotated as returning bool, bool | None, or Literal[True] | None, we will correctly infer that the context manager might suppress exceptions because these return types are not assignable to AlwaysFalsy. I believe that's what mypy/pyright also do.

context_manager_ty.class_member(db, "__exit__".into())
};
if let Place::Defined(exit) = exit_method.place
&& let Some(__exit__) = exit.ty.as_function_literal()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use try_upcast_to_callable() here rather than special-casing functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the async with case, __aexit__ is an asynchronous function, so the return type of the signature obtained with try_upcast_to_callable() is CoroutineType[..., ..., T].
Getting T from this is a bit tedious, and it's more straightforward to simply expect exit.ty to be a function literal type and take the raw signature.
Given that the specification regarding return types that suppress exceptions is very specific and conservative, it seems reasonable to treat only the case where exit.ty is a function literal as special.

@mtshiba
Copy link
Collaborator Author

mtshiba commented Feb 8, 2026

Rather than testing if the value returned by __exit__ is or isn't always truthy, it might be better to test it the value returned by __exit__ is or isn't assignable to AlwaysFalsy. This has the advantage that if the function is unannotated or annotated as returning Any, we will understand the function's return type as being assignable to AlwaysFalsy, so we will assume that the context manager does not suppress exceptions (which is lenient behaviour from us, consistent with the gradual guarantee). But if it's annotated as returning bool, bool | None, or Literal[True] | None, we will correctly infer that the context manager might suppress exceptions because these return types are not assignable to AlwaysFalsy. I believe that's what mypy/pyright also do.

Hmm, the spec says

If the return type of the __exit__ method is specifically bool or Literal[True], a type checker should assume that exceptions can be suppressed. For any other return type, a type checker should assume that exceptions are not suppressed. Examples include: Any, Literal[False], None, and bool | None.

This seems at odds with the logic you described (perhaps the spec is more ad hoc? But that's the spec...).

@AlexWaygood
Copy link
Member

Hmmmm I might be misremembering what mypy/pyright do here; sorry if so. I can check myself later. But what i described makes sense to me intuitively; a context manager that returns bool certainly could suppress an exception!

@mtshiba mtshiba force-pushed the with-can-suppress-exception branch from 7316511 to c3c29a7 Compare February 8, 2026 18:29
@mtshiba
Copy link
Collaborator Author

mtshiba commented Feb 8, 2026

I realized that the control flow of a with statement can be expressed using the same mechanism as a try statement (ref: https://peps.python.org/pep-0343/#specification-the-with-statement).
However, because the mechanism for try statements is incomplete, a straightforward implementation would result in false positive errors.

class ExceptionPropagator1:
    def __enter__(self) -> None: ...
    def __exit__(self, exc_type, exc_value, traceback) -> Literal[False]:
        return False

def propagate5(x: int | str) -> None:
    if isinstance(x, int):
        with ExceptionPropagator1():
            raise ValueError
    # TODO: should be `str`
    reveal_type(x)  # revealed: int | str
import sys

def propagate5_try(x: int | str) -> None:
    if isinstance(x, int):
        mgr = ExceptionPropagator1()
        exit = type(mgr).__exit__
        value = type(mgr).__enter__(mgr)
        exc = True
        try:
            try:
                raise ValueError
            except:
                exc = False
                if not exit(mgr, *sys.exc_info()):
                    raise
        finally:
            if exc:
                exit(mgr, None, None, None)
    # TODO: should be `str`
    reveal_type(x)  # revealed: int | str

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

context managers may silence exceptions

2 participants