Skip to content

[ty] Fix implementation of Top[Callable[..., object]]#22145

Merged
charliermarsh merged 12 commits intomainfrom
charlie/x
Dec 24, 2025
Merged

[ty] Fix implementation of Top[Callable[..., object]]#22145
charliermarsh merged 12 commits intomainfrom
charlie/x

Conversation

@charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Dec 22, 2025

Summary

Add a proper representation for the Callable top type, and use it to get callable() narrowing right.

Closes astral-sh/ty#1426.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 22, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 22, 2025

mypy_primer results

Changes were detected when running on open source projects
mypy_primer (https://github.com/hauntsaninja/mypy_primer)
- mypy_primer/git_utils.py:66:56: error[invalid-argument-type] Argument to function `get_revision_for_revision_or_date` is incorrect: Expected `str`, found `@Todo | (str & ~(() -> object)) | (((Path, /) -> Awaitable[str]) & ~(() -> object))`
- Found 4 diagnostics
+ Found 3 diagnostics

spack (https://github.com/spack/spack)
- lib/spack/spack/llnl/util/filesystem.py:330:21: warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `(str & ~(() -> object)) | (((Match[Unknown], /) -> str) & ~(() -> object))`
- lib/spack/spack/vendor/jinja2/runtime.py:734:38: error[invalid-assignment] Object of type `(Unknown & ~(() -> object)) | bool | (((str | None, /) -> bool) & ~(() -> object))` is not assignable to `bool | None`
- lib/spack/spack/vendor/jinja2/runtime.py:814:40: error[invalid-argument-type] Argument to bound method `_invoke` is incorrect: Expected `bool`, found `@Todo | bool | None`
- Found 4295 diagnostics
+ Found 4292 diagnostics

pip (https://github.com/pypa/pip)
- src/pip/_vendor/resolvelib/structs.py:203:37: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `() -> Iterable[Unknown]`, found `(Iterable[CT@build_iter_view] & (() -> object)) | (() -> Iterable[CT@build_iter_view])`
+ src/pip/_vendor/resolvelib/structs.py:203:37: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `() -> Iterable[Unknown]`, found `(Iterable[CT@build_iter_view] & Top[(...) -> object]) | (() -> Iterable[CT@build_iter_view])`
- src/pip/_vendor/rich/_log_render.py:62:59: error[invalid-argument-type] Argument to bound method `strftime` is incorrect: Expected `str`, found `(str & ~(() -> object)) | (((datetime, /) -> Text) & ~(() -> object)) | (Unknown & ~(() -> object))`
- src/pip/_vendor/rich/text.py:624:51: error[invalid-argument-type] Argument is incorrect: Expected `str | Style`, found `(@Todo & ~None) | (((str, /) -> str | Style | None) & ~AlwaysFalsy & ~(() -> object)) | (str & ~AlwaysFalsy & ~(() -> object)) | (Style & ~AlwaysFalsy & ~(() -> object))`
- Found 612 diagnostics
+ Found 610 diagnostics

websockets (https://github.com/aaugustin/websockets)
- src/websockets/legacy/server.py:634:37: error[invalid-argument-type] Argument to bound method `update` is incorrect: Expected `Mapping[str, str] | Iterable[tuple[str, str]] | SupportsKeysAndGetItem`, found `(Mapping[str, str] & ~(() -> object)) | (Iterable[tuple[str, str]] & ~(() -> object)) | (SupportsKeysAndGetItem & ~(() -> object)) | (((str, Headers, /) -> Mapping[str, str] | Iterable[tuple[str, str]] | SupportsKeysAndGetItem) & ~(() -> object)) | (@Todo & ~None)`
- Found 44 diagnostics
+ Found 43 diagnostics

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/utils.py:506:45: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- src/werkzeug/utils.py:501:12: error[unsupported-operator] Operator `>` is not supported between objects of type `(int & ~(() -> object)) | (((str | None, /) -> int | None) & ~(() -> object)) | (@Todo & ~None)` and `Literal[0]`
- src/werkzeug/utils.py:505:9: error[invalid-assignment] Object of type `(int & ~(() -> object)) | (((str | None, /) -> int | None) & ~(() -> object)) | (@Todo & ~None)` is not assignable to attribute `max_age` of type `int | None`
- src/werkzeug/wsgi.py:244:25: error[invalid-assignment] Object of type `list[Unknown | (() -> None) | (Iterable[() -> None] & (() -> object))]` is not assignable to `None | (() -> None) | Iterable[() -> None]`
+ src/werkzeug/wsgi.py:244:25: error[invalid-assignment] Object of type `list[Unknown | (() -> None) | (Iterable[() -> None] & Top[(...) -> object])]` is not assignable to `None | (() -> None) | Iterable[() -> None]`
- Found 387 diagnostics
+ Found 386 diagnostics

beartype (https://github.com/beartype/beartype)
- beartype/_check/metadata/metadecor.py:555:34: error[unresolved-attribute] Object of type `((...) -> Unknown) & (() -> object)` has no attribute `__name__`
+ beartype/_check/metadata/metadecor.py:555:34: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
- beartype/_util/func/utilfuncscope.py:261:29: error[unresolved-attribute] Object of type `((...) -> Unknown) & (() -> object)` has no attribute `__name__`
+ beartype/_util/func/utilfuncscope.py:261:29: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
- beartype/_util/func/utilfuncscope.py:320:16: error[unresolved-attribute] Object of type `((...) -> Unknown) & (() -> object)` has no attribute `__qualname__`
+ beartype/_util/func/utilfuncscope.py:320:16: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__qualname__`
- beartype/_util/func/utilfuncscope.py:334:16: error[unresolved-attribute] Object of type `((...) -> Unknown) & (() -> object)` has no attribute `__qualname__`
+ beartype/_util/func/utilfuncscope.py:334:16: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__qualname__`
- beartype/_util/func/utilfunctest.py:914:16: error[unresolved-attribute] Object of type `((...) -> Unknown) & ~(() -> object)` has no attribute `__qualname__`
- beartype/typing/_typingcache.py:87:34: error[unresolved-attribute] Object of type `((...) -> Unknown) & (() -> object)` has no attribute `__name__`
+ beartype/typing/_typingcache.py:87:34: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
- Found 495 diagnostics
+ Found 494 diagnostics

jinja (https://github.com/pallets/jinja)
- src/jinja2/runtime.py:690:38: error[invalid-assignment] Object of type `(Unknown & ~(() -> object)) | bool | (((str | None, /) -> bool) & ~(() -> object))` is not assignable to `bool | None`
- src/jinja2/runtime.py:770:40: error[invalid-argument-type] Argument to bound method `_invoke` is incorrect: Expected `bool`, found `@Todo | bool | None`
- Found 182 diagnostics
+ Found 180 diagnostics

scrapy (https://github.com/scrapy/scrapy)
- scrapy/core/spidermw.py:138:50: error[invalid-argument-type] Argument to bound method `_check_mw_method_spider_arg` is incorrect: Expected `(...) -> Unknown`, found `object`
- tests/test_utils_console.py:27:12: error[unresolved-attribute] Object of type `((...) -> None) & (() -> object)` has no attribute `__name__`
+ tests/test_utils_console.py:27:12: error[unresolved-attribute] Object of type `(...) -> None` has no attribute `__name__`
- tests/test_utils_console.py:34:12: error[unresolved-attribute] Object of type `((...) -> None) & (() -> object)` has no attribute `__name__`
+ tests/test_utils_console.py:34:12: error[unresolved-attribute] Object of type `(...) -> None` has no attribute `__name__`
- Found 1792 diagnostics
+ Found 1791 diagnostics

kopf (https://github.com/nolar/kopf)
+ kopf/_core/intents/registries.py:471:16: error[missing-argument] No arguments provided for required parameters 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
+ kopf/_core/intents/registries.py:509:42: error[missing-argument] No arguments provided for required parameters 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
+ kopf/_core/intents/registries.py:539:36: error[missing-argument] No arguments provided for required parameters 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
+ kopf/_core/intents/registries.py:545:36: error[missing-argument] No arguments provided for required parameters 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
- Found 263 diagnostics
+ Found 267 diagnostics

pytest (https://github.com/pytest-dev/pytest)
- src/_pytest/fixtures.py:557:43: error[invalid-argument-type] Argument to bound method `_check_scope` is incorrect: Expected `Scope`, found `Scope | (((str, Config, /) -> Literal["session", "package", "module", "class", "function"]) & ~(() -> object) & ~str)`
- src/_pytest/fixtures.py:1003:17: error[invalid-argument-type] Argument to bound method `from_user` is incorrect: Expected `Literal["session", "package", "module", "class", "function"]`, found `Literal["session", "package", "module", "class", "function"] | (((str, Config, /) -> Literal["session", "package", "module", "class", "function"]) & str & ~(() -> object))`
- src/_pytest/fixtures.py:1025:16: warning[possibly-missing-attribute] Attribute `value` may be missing on object of type `Scope | (((str, Config, /) -> Literal["session", "package", "module", "class", "function"]) & ~(() -> object) & ~str)`
- src/_pytest/fixtures.py:1381:9: error[invalid-argument-type] Argument is incorrect: Expected `tuple[object, ...] | ((Any, /) -> object) | None`, found `None | (Sequence[object] & (() -> object)) | (((Any, /) -> object) & (() -> object)) | Unknown`
- src/_pytest/fixtures.py:1381:70: error[invalid-argument-type] Argument to class `tuple` is incorrect: Expected `Iterable[object]`, found `(Sequence[object] & ~(() -> object)) | (((Any, /) -> object) & ~(() -> object))`
- src/_pytest/fixtures.py:1724:24: error[invalid-return-type] Return type does not match returned value: expected `Scope`, found `Scope | (((str, Config, /) -> Literal["session", "package", "module", "class", "function"]) & ~(() -> object) & ~str)`
- src/_pytest/python.py:1435:39: error[invalid-argument-type] Argument to bound method `_validate_ids` is incorrect: Expected `Iterable[object]`, found `(Iterable[object] & ~(() -> object)) | (((Any, /) -> object) & ~(() -> object))`
- src/_pytest/python.py:1439:13: error[invalid-argument-type] Argument is incorrect: Expected `((Any, /) -> object) | None`, found `None | (Iterable[object] & (() -> object)) | (((Any, /) -> object) & (() -> object))`
- src/_pytest/python.py:1534:20: error[invalid-argument-type] Argument to function `min` is incorrect: Argument type `Scope | (((str, Config, /) -> str) & ~(() -> object) & ~str) | Unknown` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
- Found 436 diagnostics
+ Found 427 diagnostics

starlette (https://github.com/encode/starlette)
+ starlette/_exception_handler.py:59:42: error[invalid-argument-type] Argument is incorrect: Expected `WebSocket`, found `Request | WebSocket`
+ starlette/middleware/errors.py:176:51: error[invalid-argument-type] Argument is incorrect: Expected `WebSocket`, found `Request`
+ starlette/middleware/errors.py:181:23: error[call-non-callable] Object of type `None` is not callable
- starlette/routing.py:67:51: error[invalid-assignment] Object of type `(((Request, /) -> Awaitable[Response] | Response) & (() -> Awaitable[object])) | partial[Unknown]` is not assignable to `(Request, /) -> Awaitable[Response]`
- Found 215 diagnostics
+ Found 217 diagnostics

ignite (https://github.com/pytorch/ignite)
- ignite/handlers/base_logger.py:52:29: error[not-iterable] Object of type `(list[str] & ~(() -> object)) | (((str, Unknown, /) -> bool) & ~(() -> object))` may not be iterable
- ignite/handlers/clearml_logger.py:502:46: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((Unknown, /) -> int | float | Unknown) & (() -> object))`
+ ignite/handlers/clearml_logger.py:502:46: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((Unknown, /) -> int | float | Unknown)`
- ignite/handlers/clearml_logger.py:691:44: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((Unknown, /) -> int | float | Unknown) & (() -> object))`
+ ignite/handlers/clearml_logger.py:691:44: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((Unknown, /) -> int | float | Unknown)`
- ignite/handlers/neptune_logger.py:505:42: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((Unknown, /) -> int | float | Unknown) & (() -> object))`
+ ignite/handlers/neptune_logger.py:505:42: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((Unknown, /) -> int | float | Unknown)`
- ignite/handlers/neptune_logger.py:609:40: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((Unknown, /) -> int | float | Unknown) & (() -> object))`
+ ignite/handlers/neptune_logger.py:609:40: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((Unknown, /) -> int | float | Unknown)`
- ignite/handlers/tensorboard_logger.py:477:40: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((Unknown, /) -> int | float | Unknown) & (() -> object))`
+ ignite/handlers/tensorboard_logger.py:477:40: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((Unknown, /) -> int | float | Unknown)`
- ignite/handlers/tensorboard_logger.py:641:38: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((Unknown, /) -> int | float | Unknown) & (() -> object))`
+ ignite/handlers/tensorboard_logger.py:641:38: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((Unknown, /) -> int | float | Unknown)`
- ignite/handlers/visdom_logger.py:491:40: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((Unknown, /) -> int | float | Unknown) & (() -> object))`
+ ignite/handlers/visdom_logger.py:491:40: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((Unknown, /) -> int | float | Unknown)`
- ignite/handlers/visdom_logger.py:542:38: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((Unknown, /) -> int | float | Unknown) & (() -> object))`
+ ignite/handlers/visdom_logger.py:542:38: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((Unknown, /) -> int | float | Unknown)`
- Found 2054 diagnostics
+ Found 2053 diagnostics

rich (https://github.com/Textualize/rich)
- rich/_log_render.py:62:59: error[invalid-argument-type] Argument to bound method `strftime` is incorrect: Expected `str`, found `(str & ~(() -> object)) | (((datetime, /) -> Text) & ~(() -> object)) | (Unknown & ~(() -> object))`
- rich/text.py:624:51: error[invalid-argument-type] Argument is incorrect: Expected `str | Style`, found `(@Todo & ~None) | (((str, /) -> str | Style | None) & ~AlwaysFalsy & ~(() -> object)) | (str & ~AlwaysFalsy & ~(() -> object)) | (Style & ~AlwaysFalsy & ~(() -> object))`
- Found 348 diagnostics
+ Found 346 diagnostics

dulwich (https://github.com/dulwich/dulwich)
- dulwich/pack.py:3512:13: warning[possibly-missing-attribute] Attribute `write` may be missing on object of type `(((bytes, /) -> None) & ~(() -> object)) | (((bytes | bytearray | memoryview[int], /) -> int) & ~(() -> object)) | (IO[bytes] & ~(() -> object))`
- dulwich/worktree.py:598:33: warning[possibly-missing-attribute] Attribute `encode` may be missing on object of type `(@Todo & ~None & ~bytes) | (str & ~(() -> object)) | (((Any, Commit, /) -> bytes) & ~(() -> object) & ~bytes)`
- dulwich/worktree.py:643:29: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal[b"commit: "]` and `bytes | (@Todo & ~None & ~str) | (((Any, Commit, /) -> bytes) & ~(() -> object) & ~str)`
- dulwich/worktree.py:661:29: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal[b"commit: "]` and `bytes | (@Todo & ~None & ~str) | (((Any, Commit, /) -> bytes) & ~(() -> object) & ~str)`
- Found 231 diagnostics
+ Found 227 diagnostics

schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/hooks.py:302:16: error[unresolved-attribute] Object of type `(str & (() -> object)) | (((...) -> Unknown) & (() -> object))` has no attribute `__name__`
+ src/schemathesis/hooks.py:302:16: error[unresolved-attribute] Object of type `(str & Top[(...) -> object]) | ((...) -> Unknown)` has no attribute `__name__`

tornado (https://github.com/tornadoweb/tornado)
- tornado/escape.py:336:30: warning[possibly-missing-attribute] Attribute `strip` may be missing on object of type `(str & ~AlwaysFalsy & ~(() -> object)) | (((str, /) -> str) & ~AlwaysFalsy & ~(() -> object))`
- tornado/gen.py:255:62: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `None | Awaitable[Unknown] | list[Awaitable[Unknown]] | dict[Any, Awaitable[Unknown]] | Future[Unknown]`, found `_T@next | _VT@next | _T@next`
+ tornado/gen.py:255:62: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `None | Awaitable[Unknown] | list[Awaitable[Unknown]] | dict[Any, Awaitable[Unknown]] | Future[Unknown]`, found `_T@next | _T@next | _VT@next`
- Found 328 diagnostics
+ Found 327 diagnostics

optuna (https://github.com/optuna/optuna)
+ tests/test_deprecated.py:56:12: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
+ tests/test_deprecated.py:72:12: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
+ tests/test_deprecated.py:192:12: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
+ tests/test_experimental.py:55:12: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
+ tests/test_experimental.py:68:12: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
+ tests/test_experimental.py:81:12: error[unresolved-attribute] Object of type `(...) -> Unknown` has no attribute `__name__`
- Found 554 diagnostics
+ Found 560 diagnostics

vision (https://github.com/pytorch/vision)
- test/datasets_utils.py:835:52: error[invalid-argument-type] Argument to function `create_image_file` is incorrect: Expected `Sequence[int] | int`, found `@Todo | (Sequence[int] & ~(() -> object)) | (int & ~(() -> object)) | (((int, /) -> Sequence[int] | int) & ~(() -> object))`
- torchvision/transforms/v2/_utils.py:149:16: error[invalid-return-type] Return type does not match returned value: expected `(Any, /) -> Any`, found `(str & (() -> object)) | (((Any, /) -> Any) & (() -> object))`
- Found 1414 diagnostics
+ Found 1412 diagnostics

antidote (https://github.com/Finistere/antidote)
- src/antidote/core/_injection.py:298:9: error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[(), object] & ~Top[classmethod[Unknown, (), object]]` has no attribute `__qualname__`
+ src/antidote/core/_injection.py:298:9: error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[Top[(...)], object] & ~Top[classmethod[Unknown, Top[(...)], object]]` has no attribute `__qualname__`
- src/antidote/core/_injection.py:298:30: error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[(), object] & ~Top[classmethod[Unknown, (), object]]` has no attribute `__name__`
+ src/antidote/core/_injection.py:298:30: error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[Top[(...)], object] & ~Top[classmethod[Unknown, Top[(...)], object]]` has no attribute `__name__`
- src/antidote/core/_injection.py:302:17: error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[(), object] & ~Top[classmethod[Unknown, (), object]] & ~MethodType` has no attribute `__qualname__`
+ src/antidote/core/_injection.py:302:17: error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[Top[(...)], object] & ~Top[classmethod[Unknown, Top[(...)], object]] & ~MethodType` has no attribute `__qualname__`
- src/antidote/core/_injection.py:302:42: error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[(), object] & ~Top[classmethod[Unknown, (), object]] & ~MethodType` has no attribute `__name__`
+ src/antidote/core/_injection.py:302:42: error[unresolved-attribute] Object of type `((...) -> object) & ~staticmethod[Top[(...)], object] & ~Top[classmethod[Unknown, Top[(...)], object]] & ~MethodType` has no attribute `__name__`

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/dependencies/data.py:347:12: error[invalid-return-type] Return type does not match returned value: expected `_T@cached_inject`, found `Coroutine[Any, Any, _T@cached_inject | Coroutine[Any, Any, _T@cached_inject]] | _T@cached_inject`
+ tanjun/dependencies/data.py:347:12: error[invalid-return-type] Return type does not match returned value: expected `_T@cached_inject`, found `_T@cached_inject | Coroutine[Any, Any, _T@cached_inject | Coroutine[Any, Any, _T@cached_inject]]`

freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/strategy/informative_decorator.py:150:21: warning[possibly-missing-attribute] Attribute `format` may be missing on object of type `(str & ~AlwaysFalsy & ~(() -> object)) | (((Any, /) -> str) & ~AlwaysFalsy & ~(() -> object))`
- Found 688 diagnostics
+ Found 687 diagnostics

discord.py (https://github.com/Rapptz/discord.py)
- discord/app_commands/commands.py:2477:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__discord_app_commands_checks__` on type `(((...) -> Coroutine[Any, Any, Unknown]) & ~Top[Command[Unknown, (), Unknown]] & ~ContextMenu & ~<Protocol with members '__discord_app_commands_checks__'>) | (((Interaction[Any], Member, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~ContextMenu & ~<Protocol with members '__discord_app_commands_checks__'>) | (((Interaction[Any], User, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~ContextMenu & ~<Protocol with members '__discord_app_commands_checks__'>) | (((Interaction[Any], Message, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~ContextMenu & ~<Protocol with members '__discord_app_commands_checks__'>)`
+ discord/app_commands/commands.py:2477:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__discord_app_commands_checks__` on type `(((...) -> Coroutine[Any, Any, Unknown]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~ContextMenu & ~<Protocol with members '__discord_app_commands_checks__'>) | (((Interaction[Any], Member, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~ContextMenu & ~<Protocol with members '__discord_app_commands_checks__'>) | (((Interaction[Any], User, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~ContextMenu & ~<Protocol with members '__discord_app_commands_checks__'>) | (((Interaction[Any], Message, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~ContextMenu & ~<Protocol with members '__discord_app_commands_checks__'>)`
- discord/app_commands/commands.py:2479:13: error[unresolved-attribute] Object of type `(((...) -> Coroutine[Any, Any, Unknown]) & ~Top[Command[Unknown, (), Unknown]] & ~ContextMenu) | (((Interaction[Any], Member, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~ContextMenu) | (((Interaction[Any], User, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~ContextMenu) | (((Interaction[Any], Message, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~ContextMenu)` has no attribute `__discord_app_commands_checks__`
+ discord/app_commands/commands.py:2479:13: error[unresolved-attribute] Object of type `(((...) -> Coroutine[Any, Any, Unknown]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~ContextMenu) | (((Interaction[Any], Member, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~ContextMenu) | (((Interaction[Any], User, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~ContextMenu) | (((Interaction[Any], Message, /) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~ContextMenu)` has no attribute `__discord_app_commands_checks__`
- discord/app_commands/errors.py:453:95: error[unresolved-attribute] Object of type `(() -> Coroutine[object, Never, object]) | ((...) -> Coroutine[Any, Any, Unknown])` has no attribute `__qualname__`
+ discord/app_commands/errors.py:453:95: error[unresolved-attribute] Object of type `Top[(...) -> Coroutine[object, Never, object]]` has no attribute `__qualname__`
- discord/ext/commands/core.py:1942:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__commands_checks__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~<Protocol with members '__commands_checks__'>`
+ discord/ext/commands/core.py:1942:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__commands_checks__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~<Protocol with members '__commands_checks__'>`
- discord/ext/commands/core.py:1944:13: error[unresolved-attribute] Object of type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]` has no attribute `__commands_checks__`
+ discord/ext/commands/core.py:1944:13: error[unresolved-attribute] Object of type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]` has no attribute `__commands_checks__`
- discord/ext/commands/core.py:2365:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__commands_checks__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~<Protocol with members '__commands_checks__'>`
+ discord/ext/commands/core.py:2365:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__commands_checks__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~<Protocol with members '__commands_checks__'>`
- discord/ext/commands/core.py:2367:13: error[unresolved-attribute] Object of type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]` has no attribute `__commands_checks__`
+ discord/ext/commands/core.py:2367:13: error[unresolved-attribute] Object of type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]` has no attribute `__commands_checks__`
- discord/ext/commands/core.py:2368:13: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `__discord_app_commands_guild_only__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]`
+ discord/ext/commands/core.py:2368:13: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `__discord_app_commands_guild_only__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]`
- discord/ext/commands/core.py:2440:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__commands_checks__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]] & ~<Protocol with members '__commands_checks__'>`
+ discord/ext/commands/core.py:2440:17: error[invalid-assignment] Object of type `list[Unknown]` is not assignable to attribute `__commands_checks__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]] & ~<Protocol with members '__commands_checks__'>`
- discord/ext/commands/core.py:2442:13: error[unresolved-attribute] Object of type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]` has no attribute `__commands_checks__`
+ discord/ext/commands/core.py:2442:13: error[unresolved-attribute] Object of type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]` has no attribute `__commands_checks__`
- discord/ext/commands/core.py:2443:13: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `__discord_app_commands_is_nsfw__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]`
+ discord/ext/commands/core.py:2443:13: error[invalid-assignment] Object of type `Literal[True]` is not assignable to attribute `__discord_app_commands_is_nsfw__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]`
- discord/ext/commands/core.py:2499:13: error[invalid-assignment] Object of type `CooldownMapping[Context[Any]]` is not assignable to attribute `__commands_cooldown__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]`
+ discord/ext/commands/core.py:2499:13: error[invalid-assignment] Object of type `CooldownMapping[Context[Any]]` is not assignable to attribute `__commands_cooldown__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]`
- discord/ext/commands/core.py:2547:13: error[invalid-assignment] Object of type `DynamicCooldownMapping[Context[Any]]` is not assignable to attribute `__commands_cooldown__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]`
+ discord/ext/commands/core.py:2547:13: error[invalid-assignment] Object of type `DynamicCooldownMapping[Context[Any]]` is not assignable to attribute `__commands_cooldown__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]`
- discord/ext/commands/core.py:2582:13: error[invalid-assignment] Object of type `MaxConcurrency` is not assignable to attribute `__commands_max_concurrency__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]`
+ discord/ext/commands/core.py:2582:13: error[invalid-assignment] Object of type `MaxConcurrency` is not assignable to attribute `__commands_max_concurrency__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]`
- discord/ext/commands/core.py:2634:13: error[invalid-assignment] Object of type `((CogT@before_invoke, ContextT@before_invoke, /) -> Coroutine[Any, Any, Any]) | ((ContextT@before_invoke, /) -> Coroutine[Any, Any, Any])` is not assignable to attribute `__before_invoke__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]`
+ discord/ext/commands/core.py:2634:13: error[invalid-assignment] Object of type `((CogT@before_invoke, ContextT@before_invoke, /) -> Coroutine[Any, Any, Any]) | ((ContextT@before_invoke, /) -> Coroutine[Any, Any, Any])` is not assignable to attribute `__before_invoke__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]`
- discord/ext/commands/core.py:2657:13: error[invalid-assignment] Object of type `((CogT@after_invoke, ContextT@after_invoke, /) -> Coroutine[Any, Any, Any]) | ((ContextT@after_invoke, /) -> Coroutine[Any, Any, Any])` is not assignable to attribute `__after_invoke__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, (), Unknown]]`
+ discord/ext/commands/core.py:2657:13: error[invalid-assignment] Object of type `((CogT@after_invoke, ContextT@after_invoke, /) -> Coroutine[Any, Any, Any]) | ((ContextT@after_invoke, /) -> Coroutine[Any, Any, Any])` is not assignable to attribute `__after_invoke__` on type `((...) -> Coroutine[Any, Any, Any]) & ~Top[Command[Unknown, Top[(...)], Unknown]]`

manticore (https://github.com/trailofbits/manticore)
- manticore/platforms/wasm.py:262:68: error[invalid-argument-type] Argument is incorrect: Expected `FunctionType`, found `(ProtoFuncInst & (() -> object) & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy) | (TableInst & (() -> object) & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy) | (MemInst & (() -> object) & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy) | (GlobalInst & (() -> object) & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy) | (((...) -> Unknown) & (() -> object) & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy)`
+ manticore/platforms/wasm.py:262:68: error[invalid-argument-type] Argument is incorrect: Expected `FunctionType`, found `(ProtoFuncInst & Top[(...) -> object] & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy) | (TableInst & Top[(...) -> object] & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy) | (MemInst & Top[(...) -> object] & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy) | (GlobalInst & Top[(...) -> object] & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy) | (((...) -> Unknown) & ~FuncAddr & ~TableAddr & ~MemAddr & ~GlobalAddr & ~AlwaysFalsy)`

meson (https://github.com/mesonbuild/meson)
- mesonbuild/compilers/compilers.py:1336:9: error[unsupported-operator] Operator `+=` is not supported between objects of type `CompilerArgs` and `(CompilerArgs & ~(() -> object)) | (list[str] & ~(() -> object)) | (((CompileCheckMode, /) -> list[str]) & ~(() -> object)) | (@Todo & ~None) | list[Unknown]`
- mesonbuild/compilers/d.py:565:29: error[invalid-argument-type] Argument to bound method `extend` is incorrect: Expected `Iterable[str]`, found `(list[str] & ~AlwaysFalsy & ~(() -> object)) | (((CompileCheckMode, /) -> list[str]) & Top[list[Unknown]] & ~AlwaysFalsy & ~(() -> object)) | (@Todo & Top[list[Unknown]])`
- mesonbuild/compilers/vala.py:195:9: error[unsupported-operator] Operator `+=` is not supported between objects of type `CompilerArgs` and `(CompilerArgs & ~(() -> object)) | (list[str] & ~(() -> object)) | (((CompileCheckMode, /) -> list[str]) & ~(() -> object)) | (@Todo & ~None) | list[Unknown]`
- Found 1949 diagnostics
+ Found 1946 diagnostics

setuptools (https://github.com/pypa/setuptools)
+ setuptools/_vendor/jaraco/collections/__init__.py:42:29: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- setuptools/_vendor/typing_extensions.py:2855:17: error[invalid-assignment] Object of type `Unknown | str` is not assignable to attribute `__deprecated__` on type `_T@__call__ & (() -> object) & ~type`
+ setuptools/_vendor/typing_extensions.py:2855:17: error[invalid-assignment] Object of type `Unknown | str` is not assignable to attribute `__deprecated__` on type `_T@__call__ & Top[(...) -> object] & ~type`
- setuptools/config/_apply_pyprojecttoml.py:84:31: error[invalid-argument-type] Argument to function `_set_config` is incorrect: Expected `str`, found `(((Distribution, Any, str | PathLike[str] | None, /) -> None) & ~(() -> object)) | (str & ~(() -> object))`
- setuptools/config/_apply_pyprojecttoml.py:124:31: error[invalid-argument-type] Argument to function `_set_config` is incorrect: Expected `str`, found `(Unknown & ~(() -> object)) | (partial[None] & ~(() -> object))`
- setuptools/config/expand.py:334:34: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Buffer]`, found `(@Todo & <Protocol with members '__iter__'> & ~str) | (((...) -> Unknown) & <Protocol with members '__iter__'> & ~(() -> object) & ~str) | (Iterable[str | int] & ~(() -> object) & ~str)`
+ setuptools/config/expand.py:334:34: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Buffer]`, found `(Unknown & <Protocol with members '__iter__'> & ~str) | (Iterable[str | int] & ~Top[(...) -> object] & ~str)`
- Found 1272 diagnostics
+ Found 1271 diagnostics

archinstall (https://github.com/archlinux/archinstall)
- archinstall/lib/output.py:36:20: error[invalid-argument-type] Argument to function `hasattr` is incorrect: Expected `str`, found `(str & ~AlwaysFalsy & ~(() -> object)) | (((...) -> Unknown) & ~AlwaysFalsy & ~(() -> object))`
- archinstall/lib/output.py:36:61: error[invalid-argument-type] Argument to function `getattr` is incorrect: Expected `str`, found `(str & ~AlwaysFalsy & ~(() -> object)) | (((...) -> Unknown) & ~AlwaysFalsy & ~(() -> object))`
- archinstall/lib/output.py:37:23: error[invalid-argument-type] Argument to function `getattr` is incorrect: Expected `str`, found `(str & ~AlwaysFalsy & ~(() -> object)) | (((...) -> Unknown) & ~AlwaysFalsy & ~(() -> object))`
- Found 46 diagnostics
+ Found 43 diagnostics

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/funcs.py:55:20: error[invalid-assignment] Object of type `() -> object` is not assignable to `(...) -> T@partial_with_wrapper`
+ src/hydra_zen/funcs.py:55:20: error[invalid-assignment] Object of type `Top[(...) -> object]` is not assignable to `(...) -> T@partial_with_wrapper`
- src/hydra_zen/structured_configs/_implementations.py:2253:47: error[invalid-argument-type] Argument to function `get_target_path` is incorrect: Expected `HasTarget`, found `(() -> object) & type`
+ src/hydra_zen/structured_configs/_implementations.py:2253:47: error[invalid-argument-type] Argument to function `get_target_path` is incorrect: Expected `HasTarget`, found `type`

strawberry (https://github.com/strawberry-graphql/strawberry)
+ strawberry/cli/utils/__init__.py:23:29: error[call-top-callable] Object of type `Top[(...) -> object]` is not safe to call; its signature is not known
+ strawberry/types/field.py:143:38: error[call-top-callable] Object of type `Top[(...) -> object]` is not safe to call; its signature is not known
- strawberry/types/fields/resolver.py:392:20: error[invalid-return-type] Return type does not match returned value: expected `(...) -> T@StrawberryResolver`, found `(() -> object) | ((...) -> Unknown) | ((...) -> Unknown)`
+ strawberry/types/fields/resolver.py:392:20: error[invalid-return-type] Return type does not match returned value: expected `(...) -> T@StrawberryResolver`, found `Top[(...) -> object]`
- Found 384 diagnostics
+ Found 386 diagnostics

xarray (https://github.com/pydata/xarray)
- xarray/core/common.py:518:16: error[invalid-return-type] Return type does not match returned value: expected `dict[Hashable, T@_calc_assign_results]`, found `dict[Any, @Todo | (T@_calc_assign_results & ~(() -> object)) | (((C@_calc_assign_results, /) -> T@_calc_assign_results) & ~(() -> object))]`
- xarray/core/dataarray.py:3251:48: error[invalid-argument-type] Argument to bound method `drop_vars` is incorrect: Expected `Iterable[Hashable] | ((Dataset, /) -> Iterable[Hashable])`, found `@Todo | (Iterable[Hashable] & ~(() -> object)) | (((Self@drop_vars, /) -> Unknown | Iterable[Hashable]) & ~(() -> object))`
- xarray/core/dataarray.py:5277:35: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1
+ xarray/core/dataarray.py:5277:25: error[call-top-callable] Object of type `Top[(...) -> object]` is not safe to call; its signature is not known
- xarray/core/dataset.py:1527:35: error[invalid-argument-type] Argument to function `getattr` is incorrect: Expected `str`, found `(str & ~(() -> object)) | (((Variable, Variable, /) -> bool) & ~(() -> object))`
- xarray/core/dataset.py:1530:48: error[invalid-argument-type] Argument to function `dict_equiv` is incorrect: Expected `(Variable, Variable, /) -> bool`, found `(str & (() -> object)) | (((Variable, Variable, /) -> bool) & (() -> object)) | (def compat(x: Variable, y: Variable) -> bool)`
+ xarray/core/dataset.py:1530:48: error[invalid-argument-type] Argument to function `dict_equiv` is incorrect: Expected `(Variable, Variable, /) -> bool`, found `(str & Top[(...) -> object]) | ((Variable, Variable, /) -> bool)`
- xarray/core/dataset.py:8110:35: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1
+ xarray/core/dataset.py:8110:25: error[call-top-callable] Object of type `Top[(...) -> object]` is not safe to call; its signature is not known
- Found 1786 diagnostics
+ Found 1783 diagnostics

altair (https://github.com/vega/altair)
- altair/utils/plugin_registry.py:110:44: error[invalid-parameter-default] Default value of type `def callable(obj: object, /) -> TypeIs[() -> object]` is not assignable to annotated parameter type `(object, /) -> TypeIs[object]`
+ altair/utils/plugin_registry.py:110:44: error[invalid-parameter-default] Default value of type `def callable(obj: object, /) -> TypeIs[Top[(...) -> object]]` is not assignable to annotated parameter type `(object, /) -> TypeIs[object]`

bokeh (https://github.com/bokeh/bokeh)
- src/bokeh/core/property/bases.py:187:24: error[invalid-return-type] Return type does not match returned value: expected `T@Property`, found `(() -> T@Property) | (T@Property & (() -> object))`
+ src/bokeh/core/property/bases.py:187:24: error[invalid-return-type] Return type does not match returned value: expected `T@Property`, found `(() -> T@Property) | (T@Property & Top[(...) -> object])`
- src/bokeh/io/notebook.py:568:30: error[invalid-argument-type] Argument to function `_origin_url` is incorrect: Expected `str`, found `(str & ~(() -> object)) | (((int | None, /) -> str) & ~(() -> object))`
- src/bokeh/io/notebook.py:580:27: error[invalid-argument-type] Argument to function `_server_url` is incorrect: Expected `str`, found `(str & ~(() -> object)) | (((int | None, /) -> str) & ~(() -> object))`
- src/bokeh/server/tornado.py:286:56: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Document, /) -> None`, found `(Mapping[str, Application | ((Document, /) -> None)] & (() -> object)) | (Application & (() -> object)) | (((Document, /) -> None) & (() -> object))`
+ src/bokeh/server/tornado.py:286:56: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Document, /) -> None`, found `(Mapping[str, Application | ((Document, /) -> None)] & Top[(...) -> object]) | (Application & Top[(...) -> object]) | ((Document, /) -> None)`
- src/bokeh/server/tornado.py:291:28: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- src/bokeh/server/tornado.py:295:71: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Document, /) -> None`, found `(Unknown & (() -> object)) | (Application & (() -> object))`
+ src/bokeh/server/tornado.py:295:71: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Document, /) -> None`, found `(Unknown & Top[(...) -> object]) | (Application & Top[(...) -> object])`
- src/bokeh/server/tornado.py:295:71: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Document, /) -> None`, found `(Unknown & (() -> object)) | (Application & (() -> object))`
+ src/bokeh/server/tornado.py:295:71: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(Document, /) -> None`, found `(Unknown & Top[(...) -> object]) | (Application & Top[(...) -> object])`
- Found 896 diagnostics
+ Found 893 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:94:28: error[invalid-assignment] Object of type `T@resolve_block_document_references | dict[str, Any]` is not assignable to `dict[str, Any]`
+ src/integrations/prefect-dbt/prefect_dbt/core/settings.py:94:28: error[invalid-assignment] Object of type `T@resolve_block_document_references | int | dict[str, Any] | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:99:28: error[invalid-assignment] Object of type `T@resolve_variables | dict[str, Any]` is not assignable to `dict[str, Any]`
+ src/integrations/prefect-dbt/prefect_dbt/core/settings.py:99:28: error[invalid-assignment] Object of type `int | T@resolve_variables | float | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_core.py:86:21: error[invalid-assignment] Object of type `T@resolve_block_document_references | dict[str, Any]` is not assignable to `dict[str, Any]`
+ src/prefect/cli/deploy/_core.py:86:21: error[invalid-assignment] Object of type `T@resolve_block_document_references | int | dict[str, Any] | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_core.py:87:21: error[invalid-assignment] Object of type `T@resolve_variables` is not assignable to `dict[str, Any]`
+ src/prefect/cli/deploy/_core.py:87:21: error[invalid-assignment] Object of type `int | T@resolve_variables | float | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/deployments/steps/core.py:137:38: error[invalid-argument-type] Argument is incorrect: Expected `T@resolve_variables`, found `T@resolve_block_document_references | dict[str, Any]`
+ src/prefect/deployments/steps/core.py:137:38: error[invalid-argument-type] Argument is incorrect: Expected `T@resolve_variables`, found `T@resolve_block_document_references | int | dict[str, Any] | ... omitted 4 union elements`
- src/prefect/task_engine.py:438:13: error[invalid-assignment] Object of type `Unknown | None | (((Task[(...), Any], TaskRun, State[Any], /) -> Awaitable[bool] | bool) & (() -> object))` is not assignable to `((Task[P@SyncTaskRunEngine, Coroutine[Any, Any, R@SyncTaskRunEngine]], TaskRun, State[R@SyncTaskRunEngine], /) -> bool) | None`
+ src/prefect/task_engine.py:438:13: error[invalid-assignment] Object of type `Unknown | None | ((Task[(...), Any], TaskRun, State[Any], /) -> Awaitable[bool] | bool)` is not assignable to `((Task[P@SyncTaskRunEngine, Coroutine[Any, Any, R@SyncTaskRunEngine]], TaskRun, State[R@SyncTaskRunEngine], /) -> bool) | None`
- src/prefect/task_engine.py:1026:13: error[invalid-assignment] Object of type `Unknown | None | (((Task[(...), Any], TaskRun, State[Any], /) -> Awaitable[bool] | bool) & (() -> object))` is not assignable to `((Task[P@AsyncTaskRunEngine, Coroutine[Any, Any, R@AsyncTaskRunEngine]], TaskRun, State[R@AsyncTaskRunEngine], /) -> bool) | None`
+ src/prefect/task_engine.py:1026:13: error[invalid-assignment] Object of type `Unknown | None | ((Task[(...), Any], TaskRun, State[Any], /) -> Awaitable[bool] | bool)` is not assignable to `((Task[P@AsyncTaskRunEngine, Coroutine[Any, Any, R@AsyncTaskRunEngine]], TaskRun, State[R@AsyncTaskRunEngine], /) -> bool) | None`
- src/prefect/utilities/_engine.py:64:13: error[invalid-argument-type] Argument to bound method `is_callback_with_parameters` is incorrect: Expected `(...) -> str`, found `(Unknown & (() -> object)) | (() -> str) | (TaskRunNameCallbackWithParameters & (() -> object)) | (str & (() -> object))`
+ src/prefect/utilities/_engine.py:64:13: error[invalid-argument-type] Argument to bound method `is_callback_with_parameters` is incorrect: Expected `(...) -> str`, found `(Unknown & Top[(...) -> object]) | (() -> str) | TaskRunNameCallbackWithParameters | (str & Top[(...) -> object])`
+ src/prefect/utilities/_engine.py:69:29: error[missing-argument] No argument provided for required parameter `parameters` of bound method `__call__`
- src/prefect/utilities/_engine.py:93:13: error[unresolved-attribute] Object of type `() -> object` has no attribute `__name__`
+ src/prefect/utilities/_engine.py:93:13: error[unresolved-attribute] Object of type `Top[(...) -> object]` has no attribute `__name__`
- src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `T@resolve_block_document_references | dict[str, Any]` on object of type `dict[str, Any]`
+ src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `T@resolve_block_document_references | int | dict[str, Any] | ... omitted 4 union elements` on object of type `dict[str, Any]`
- src/prefect/utilities/templating.py:323:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_block_document_references | dict[str, Any]`, found `list[T@resolve_block_document_references | dict[str, Any] | Unknown]`
+ src/prefect/utilities/templating.py:323:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_block_document_references | dict[str, Any]`, found `list[T@resolve_block_document_references | int | dict[str, Any] | ... omitted 5 union elements]`
- src/prefect/utilities/templating.py:437:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, T@resolve_variables | Unknown]`
+ src/prefect/utilities/templating.py:437:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, int | T@resolve_variables | float | ... omitted 5 union elements]`
- src/prefect/utilities/templating.py:442:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `list[T@resolve_variables | Unknown]`
+ src/prefect/utilities/templating.py:442:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `list[int | T@resolve_variables | float | ... omitted 5 union elements]`
- src/prefect/workers/base.py:228:13: error[invalid-argument-type] Argument is incorrect: Expected `T@resolve_variables`, found `T@resolve_block_document_references | dict[str, Any]`
+ src/prefect/workers/base.py:228:13: error[invalid-argument-type] Argument is incorrect: Expected `T@resolve_variables`, found `T@resolve_block_document_references | int | dict[str, Any] | ... omitted 4 union elements`
- src/prefect/workers/base.py:230:20: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `T@resolve_variables`
+ src/prefect/workers/base.py:230:20: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `int | T@resolve_variables | float | ... omitted 4 union elements`
- Found 5542 diagnostics
+ Found 5543 diagnostics

ibis (https://github.com/ibis-project/ibis)
- ibis/backends/tests/conftest.py:21:35: error[invalid-type-form] Variable of type `def callable(obj: object, /) -> TypeIs[() -> object]

... (truncated 78 lines) ...

No memory usage changes detected ✅

@AlexWaygood
Copy link
Member

AlexWaygood commented Dec 22, 2025

Top[Callable[..., object]] is a different type to Callable[..., object], unfortunately! The former is an (unsimplifiable) fully static type, the latter is a gradual type

@AlexWaygood
Copy link
Member

It's the same as the difference between Top[list[Any]] (also unsimplifiable) and list[Any]

@AlexWaygood
Copy link
Member

AlexWaygood commented Dec 22, 2025

We implement Top[list[Any]] using this field on the Specialization struct:

/// The materialization kind of the specialization. For example, given an invariant
/// generic type `A`, `Top[A[Any]]` is a supertype of all materializations of `A[Any]`,
/// and is represented here with `Some(MaterializationKind::Top)`. Similarly,
/// `Bottom[A[Any]]` is a subtype of all materializations of `A[Any]`, and is represented
/// with `Some(MaterializationKind::Bottom)`.
/// The `materialization_kind` field may be non-`None` only if the specialization contains
/// dynamic types in invariant positions.
pub(crate) materialization_kind: Option<MaterializationKind>,
. I think fixing the linked issue requires adding a similar field to CallableType and/or Parameters.

@charliermarsh
Copy link
Member Author

🫡

@AlexWaygood AlexWaygood changed the title Use gradual form (...) for parameters in Callable bottom type [ty] Use gradual form (...) for parameters in Callable bottom type Dec 23, 2025
@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Dec 23, 2025
@AlexWaygood AlexWaygood reopened this Dec 23, 2025
@AlexWaygood AlexWaygood changed the title [ty] Use gradual form (...) for parameters in Callable bottom type [ty] Use gradual form (...) for parameters in Callable top materialization Dec 23, 2025
@AlexWaygood
Copy link
Member

AlexWaygood commented Dec 23, 2025

Nice, this looks like it's on the right track now!

+ beartype/_check/metadata/metadecor.py:555:34: error[unresolved-attribute] Object of type `((...) -> Unknown) & (Top[(...) -> object])` has no attribute `__name__`

Diagnostics like this indicate that some of the subtyping rules aren't quite right yet. All Callable types should be considered subtypes of Top[(...) -> object]; it is a fully static supertype of all Callable types. If we understood this subtype relationship correctly, then the intersection ((...) -> Unknown) & (Top[(...) -> object]) would naturally simplify down to (...) -> Unknown.

Similarly, (...) -> int, (str, /) -> int and (bytes, bytes) -> bool should all be understood as subtypes of Top[(...) -> int], but (...) -> object should not, etc.

@AlexWaygood
Copy link
Member

AlexWaygood commented Dec 23, 2025

The primer report is starting to look a lot better!

There's another change that we need to make... which might make the ecosystem blow up, but I do think it's the "correct" thing to do:

def f(x: object):
    if callable(x):
        x()  # this should be an error...
             # we know that `x` is callable, but we do not know
             # *how* it is callable (is it okay to call it with *zero arguments*?).
             # `Top[Callable[..., object]]` is much stricter than `Callable[..., object]`
             # for things like this

Top[Callable[..., object]] is really a very strange type. Objects that have this type are callable... but any attempt to actually call one of these objects should lead to a type-checker error. Top[Callable[..., object]] represents the "infinite union" of all possible Callable types, so for any attempt to call an object with this type should cause the type checker to go "no, it could be a Callable object with a different signature to the one you're assuming".

This is similar to the way we apply much stricter rules to Top[list[Any]] than we do to list[Any]: Top[list[Any]] represents the fully static "infinite union" of all possible list types, whereas list[Any] is a very permissive gradual type.

from ty_extensions import Top
from typing import Any

def f(x: list[Any], y: Top[list[Any]]):
    x.append("foo")  # fine
    y.append("foo")  # error: expected `Never`, found `Literal["foo"]

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 23, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 2 36 14
unresolved-attribute 6 3 19
invalid-assignment 0 6 21
invalid-return-type 0 4 13
possibly-missing-attribute 0 7 8
unsupported-operator 0 7 0
call-top-callable 5 0 0
missing-argument 5 0 0
not-iterable 0 3 1
unused-ignore-comment 3 1 0
call-non-callable 1 1 0
too-many-positional-arguments 0 2 0
type-assertion-failure 2 0 0
invalid-parameter-default 0 0 1
invalid-type-form 0 0 1
no-matching-overload 0 1 0
Total 24 71 78

Full report with detailed diff (timing results)

@AlexWaygood
Copy link
Member

I wouldn't worry about the spack panic in ecosystem-analyzer — we've seen it on some other PRs; it's one of our nondeterminism issues right now

@carljm
Copy link
Contributor

carljm commented Dec 24, 2025

Lots of false positives going away in the ecosystem report! 🎉

I see a few new diagnostics with message "Object of type Top[(...) -> object] is not callable". These are cases where someone tries to call the top callable type. If we are being strict, this call can never succeed (since you are trying to call the union of all possible callables -- no arguments could possibly satisfy them all). But we should probably emit a custom diagnostic for this, because it's odd to do if callable(x): x() and have ty tell you that x "is not callable".

Other type checkers unsoundly use (...) -> object instead of the top callable, so they allow any call. We could easily use a different rule code for "trying to call the top callable", so people who want that forgiving behavior can opt into it?

@charliermarsh
Copy link
Member Author

(I think that diagnostic is what Alex asked for here: #22145 (comment). No issue from me with using a custom diagnostic for it!)

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Awesome!

I think it'd be good to have some tests showing the behavior of the bottom callable, too? It's always callable with any arguments.

The ways it could be created in real code are a bit complex. You'd need a gradual-form callable type in contravariant position of some type -- e.g. as an argument to another Callable -- and then you'd need to do something that would top-materialize the outer type, like return it wrapped in TypeIs. I'm not sure we need to represent this in a test; I'd just use ty_extensions.Bottom to create the type "manually".

/// The callable type is a top materialization (e.g., `Top[Callable[..., object]]`), which
/// represents an unknown callable signature. While such types *are* callable (they pass
/// `callable()`), any specific call should fail because we don't know the actual signature.
UnknownCallableSignature(Type<'db>),
Copy link
Contributor

Choose a reason for hiding this comment

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

Although the term "unknown" is correct here, it's confusing given our frequent usage of Unknown as a dynamic type. This isn't user-facing, it's in code: maybe CalledTopCallable?

@AlexWaygood AlexWaygood changed the title [ty] Use gradual form (...) for parameters in Callable top materialization [ty] Fix implementation of Top[Callable[..., object]] Dec 24, 2025
@AlexWaygood
Copy link
Member

The ecosystem report's looking good again!

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

This looks great -- thank you!! 😃

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Let's go!

charliermarsh and others added 3 commits December 24, 2025 12:41
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@charliermarsh
Copy link
Member Author

Thank you @AlexWaygood!

@charliermarsh charliermarsh merged commit 2de4464 into main Dec 24, 2025
46 checks passed
@charliermarsh charliermarsh deleted the charlie/x branch December 24, 2025 17:49
charliermarsh pushed a commit that referenced this pull request Dec 24, 2025
…ute on a `Callable` type (#22182)

## Summary

Other type checkers allow you to access all `FunctionType` attributes on
any object with a `Callable` type. ty does not, because this is
demonstrably unsound, but this is often a source of confusion for users.
And there were lots of diagnostics in the ecosystem report for
#22145 that were complaining that
"Object of type `(...) -> Unknown` has no attribute `__name__`", for
example.

The discrepancy between what ty does here and what other type checkers
do is discussed a bit in astral-sh/ty#1495.
You can see that there have been lots of issues closed as duplicates of
that issue; we should probably also add an FAQ entry for it.

Anyway, this PR adds a subdiagnostic to help users out when they hit
this diagnostic. Unfortunately something I did meant that rustfmt
increased the indentation of the whole of this huge closure, so this PR
is best reviewed with the "No whitespace" option selected for viewing
the diff.

## Test Plan

Snapshot added
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.

Incorrect top materialization of Callable types

5 participants