You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeErrors between an enum member's value attribute and the enum itself are silently suppressed
when inside a function due to resolution as Any
Minimal example:
fromenumimportEnumclassMyEnum(Enum):
up='up'down='down'defzero(x: MyEnum):
return0deffun1(x: MyEnum):
returnzero(x.value)
myfun(MyEnum.up) # okmyfun(MyEnum.up.value) # error (expect: MyEnum, found Literal)fun1(MyEnum.up) # should error as the previous line due on fun1's call to zero
Test Plan
Added an example test in crates/ty_python_semantic/resources/mdtest/enums.md under the Function Syntax heading
The percentage of diagnostics emitted that were expected errors decreased from 85.94% to 85.92%. The percentage of expected errors that received a diagnostic decreased from 78.17% to 78.13%.
Changes were detected when running on open source projects
parso (https://github.com/davidhalter/parso)
- parso/python/tokenize.py:252:54: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive- Found 166 diagnostics+ Found 165 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`
discord.py (https://github.com/Rapptz/discord.py)
- discord/channel.py:962:35: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive- discord/components.py:474:39: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive+ discord/components.py:488:40: error[invalid-assignment] Invalid assignment to key "channel_types" with declared type `list[Literal[0, 1, 2, 3, 4, ... omitted 8 literals]]` on TypedDict `SelectMenu`: value of type `list[Unknown | int]`- Found 537 diagnostics+ Found 536 diagnostics
archinstall (https://github.com/archlinux/archinstall)
+ archinstall/lib/models/device.py:356:17: error[unsupported-operator] Operator `/` is not supported between objects of type `int` and `int | Literal["sectors"]`- Found 66 diagnostics+ Found 67 diagnostics
prefect (https://github.com/PrefectHQ/prefect)
+ src/integrations/prefect-databricks/prefect_databricks/rest.py:124:23: error[invalid-assignment] Object of type `Literal["get", "post", "put", "delete", "patch"]` is not assignable to `HTTPMethod`+ src/integrations/prefect-databricks/prefect_databricks/rest.py:135:42: error[invalid-argument-type] Argument to function `getattr` is incorrect: Expected `str`, found `HTTPMethod`- src/integrations/prefect-docker/tests/test_containers.py:26:31: error[invalid-await] `object` is not awaitable- src/integrations/prefect-docker/tests/test_containers.py:41:26: error[invalid-await] `object` is not awaitable- src/integrations/prefect-docker/tests/test_containers.py:54:31: error[invalid-await] `object` is not awaitable- src/integrations/prefect-docker/tests/test_containers.py:67:31: error[invalid-await] `object` is not awaitable- src/integrations/prefect-docker/tests/test_containers.py:80:31: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-docker/tests/test_containers.py:27:47: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `str | bool | dict[Unknown | str, Unknown | int] | None`+ src/integrations/prefect-docker/tests/test_containers.py:27:47: error[invalid-argument-type] Argument is incorrect: Expected `str | list[str] | None`, found `str | bool | dict[Unknown | str, Unknown | int] | None`+ src/integrations/prefect-docker/tests/test_containers.py:27:47: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `str | bool | dict[Unknown | str, Unknown | int] | None`+ src/integrations/prefect-docker/tests/test_containers.py:27:47: error[invalid-argument-type] Argument is incorrect: Expected `bool | None`, found `str | bool | dict[Unknown | str, Unknown | int] | None`+ src/integrations/prefect-docker/tests/test_containers.py:27:47: error[invalid-argument-type] Argument is incorrect: Expected `str | list[str] | None`, found `str | bool | dict[Unknown | str, Unknown | int] | None`+ src/integrations/prefect-docker/tests/test_containers.py:27:47: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, str] | list[str] | None`, found `str | bool | dict[Unknown | str, Unknown | int] | None`+ src/integrations/prefect-docker/tests/test_containers.py:27:47: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str | bool | dict[Unknown | str, Unknown | int] | None`+ src/integrations/prefect-docker/tests/test_containers.py:42:47: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str`+ src/integrations/prefect-docker/tests/test_containers.py:55:47: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str`+ src/integrations/prefect-docker/tests/test_containers.py:68:47: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str`+ src/integrations/prefect-docker/tests/test_containers.py:81:47: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str`- src/integrations/prefect-docker/tests/test_images.py:16:23: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-docker/tests/test_images.py:16:44: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:16:44: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:16:44: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:16:44: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:16:44: error[invalid-argument-type] Argument is incorrect: Expected `DockerHost | None`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:16:44: error[invalid-argument-type] Argument is incorrect: Expected `DockerRegistryCredentials | None`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:16:44: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str | bool`- src/integrations/prefect-docker/tests/test_images.py:28:27: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-docker/tests/test_images.py:29:47: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `str`+ src/integrations/prefect-docker/tests/test_images.py:29:47: error[invalid-argument-type] Argument is incorrect: Expected `DockerRegistryCredentials | None`, found `str`+ src/integrations/prefect-docker/tests/test_images.py:29:47: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str`+ src/integrations/prefect-docker/tests/test_images.py:31:16: error[unresolved-attribute] Attribute `id` is not defined on `list[Unknown]` in union `Unknown | list[Unknown]`- src/integrations/prefect-docker/tests/test_images.py:48:27: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-docker/tests/test_images.py:51:17: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `str`- src/integrations/prefect-docker/tests/test_images.py:63:28: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-docker/tests/test_images.py:51:17: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str`+ src/integrations/prefect-docker/tests/test_images.py:53:16: error[unresolved-attribute] Attribute `id` is not defined on `list[Unknown]` in union `Unknown | list[Unknown]`+ src/integrations/prefect-docker/tests/test_images.py:64:47: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:64:47: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:64:47: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:64:47: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:64:47: error[invalid-argument-type] Argument is incorrect: Expected `DockerRegistryCredentials | None`, found `str | bool`+ src/integrations/prefect-docker/tests/test_images.py:64:47: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str | bool`- src/integrations/prefect-kubernetes/prefect_kubernetes/jobs.py:425:33: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-kubernetes/prefect_kubernetes/jobs.py:428:17: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `str`- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:16:15: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:24:15: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:33:15: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:46:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:98:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:144:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:190:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:236:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:274:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_custom_objects.py:332:11: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:20:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `None`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:29:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `None`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:38:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `None`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:57:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:103:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:149:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:195:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:240:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:286:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_custom_objects.py:344:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`- src/integrations/prefect-kubernetes/tests/test_deployments.py:16:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_deployments.py:34:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_deployments.py:68:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_deployments.py:88:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_deployments.py:110:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_deployments.py:137:11: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-kubernetes/tests/test_deployments.py:18:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_deployments.py:38:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_deployments.py:70:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_deployments.py:92:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_deployments.py:113:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_deployments.py:141:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`- src/integrations/prefect-kubernetes/tests/test_jobs.py:34:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_jobs.py:50:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_jobs.py:66:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_jobs.py:84:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_jobs.py:104:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_jobs.py:127:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_jobs.py:156:11: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-kubernetes/tests/test_jobs.py:36:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_jobs.py:52:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_jobs.py:68:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_jobs.py:87:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_jobs.py:107:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_jobs.py:131:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_jobs.py:159:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`- src/integrations/prefect-kubernetes/tests/test_pods.py:27:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_pods.py:42:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_pods.py:76:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_pods.py:92:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_pods.py:112:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_pods.py:133:11: error[invalid-await] `object` is not awaitable- src/integrations/prefect-kubernetes/tests/test_pods.py:163:11: error[invalid-await] `object` is not awaitable+ src/integrations/prefect-kubernetes/tests/test_pods.py:29:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_pods.py:46:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_pods.py:78:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_pods.py:96:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_pods.py:115:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_pods.py:137:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`+ src/integrations/prefect-kubernetes/tests/test_pods.py:167:9: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Any]`, found `Literal["test"]`- src/prefect/cache_policies.py:311:25: error[unresolved-attribute] Attribute `__code__` is not defined on `((...) -> Any) & ((*args: object, **kwargs: object) -> object)` in union `Unknown | (((...) -> Any) & ((*args: object, **kwargs: object) -> object))`+ src/prefect/cache_policies.py:311:25: error[unresolved-attribute] Attribute `__code__` is not defined on `(...) -> Any` in union `Unknown | ((...) -> Any)`+ src/prefect/task_engine.py:1642:28: error[invalid-await] `Unknown | R@AsyncTaskRunEngine | Coroutine[Any, Any, R@AsyncTaskRunEngine]` is not awaitable- src/prefect/tasks.py:185:9: error[unresolved-attribute] Attribute `__code__` is not defined on `((...) -> Any) & ((*args: object, **kwargs: object) -> object)` in union `Unknown | (((...) -> Any) & ((*args: object, **kwargs: object) -> object))`+ src/prefect/tasks.py:185:9: error[unresolved-attribute] Attribute `__code__` is not defined on `(...) -> Any` in union `Unknown | ((...) -> Any)`- src/prefect/tasks.py:795:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> str) | TaskRunNameCallbackWithParameters | str | None`, found `((() -> str) & ~<class 'NotSet'>) | TaskRunNameCallbackWithParameters | str | ... omitted 4 union elements`+ src/prefect/tasks.py:795:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `(() -> str) | TaskRunNameCallbackWithParameters | str | None`, found `(() -> str) | TaskRunNameCallbackWithParameters | str | ... omitted 3 union elements`- 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 & Top[(...) -> object]) | ((() -> str) & ((*args: object, **kwargs: object) -> object)) | (TaskRunNameCallbackWithParameters & ((*args: object, **kwargs: object) -> 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 & Top[(...) -> object]) | (() -> str) | TaskRunNameCallbackWithParameters`+ src/prefect/utilities/_engine.py:66:48: error[unknown-argument] Argument `parameters` does not match any known parameter- src/prefect/utilities/_engine.py:85:12: error[invalid-return-type] Return type does not match returned value: expected `str`, found `object`+ src/prefect/utilities/_engine.py:69:29: error[missing-argument] No argument provided for required parameter `parameters` of bound method `__call__`- Found 5784 diagnostics+ Found 5810 diagnostics
django-stubs (https://github.com/typeddjango/django-stubs)
+ tests/assert_type/db/models/test_enums.py:309:1: error[type-assertion-failure] Type `list[Unknown | tuple[int | float, str] | tuple[bytes, str]]` does not match asserted type `list[Any]`- Found 524 diagnostics+ Found 525 diagnostics
streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/elements/lib/built_in_chart_utils.py:194:9: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | str | bool`- Found 12 diagnostics+ Found 13 diagnostics
jax (https://github.com/google/jax)
+ jax/_src/pallas/mosaic/lowering.py:467:12: warning[redundant-cast] Value is already of type `Literal["parallel", "core_parallel", "subcore_parallel", "arbitrary"]`- Found 2449 diagnostics+ Found 2450 diagnostics
rotki (https://github.com/rotki/rotki)
- rotkehlchen/tests/db/test_db.py:1598:59: error[invalid-argument-type] Argument is incorrect: Expected `ApiKey`, found `str`+ rotkehlchen/tests/db/test_db.py:1598:59: error[invalid-argument-type] Argument is incorrect: Expected `ApiKey`, found `LiteralString`
In this case the conformance suite "regressions" reported by our script are both actually good news :-)
They're marked as "optional errors" in the upstream conformance suite because the spec does not mandate that type checkers have to infer precise Literal types on those lines — it's permitted for the assertions to fail. But if the assertions pass (and the optional errors are therefore not emitted), that's even better!
rizzip
changed the title
Fix type checking for multi-member enums within in a function block
[ty] Fix type checking for multi-member enums within in a function block
Mar 2, 2026
@AlexWaygood Thanks for checking on that, I had moved this back to draft so I could look into it. Everything seems fine to me, so I'll mark it as ready again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TypeErrors between an enum member'svalueattribute and the enum itself are silently suppressedwhen inside a function due to resolution as
AnyMinimal example:
Test Plan
crates/ty_python_semantic/resources/mdtest/enums.mdunder the Function Syntax heading