Skip to content

[ty] Suppress diagnostics in statically unreachable nested scopes#23849

Open
charliermarsh wants to merge 2 commits intomainfrom
charlie/unreachable
Open

[ty] Suppress diagnostics in statically unreachable nested scopes#23849
charliermarsh wants to merge 2 commits intomainfrom
charlie/unreachable

Conversation

@charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Mar 10, 2026

Summary

Stop emitting body diagnostics from nested scopes defined under statically unreachable branches such as if False and if not TYPE_CHECKING.

This fixes false positives like call-non-callable in unreachable functions, including the Python 3.14 deferred-annotation case. The empty-body rule was moved from function body inference to deferred function-definition validation to ensure that it keeps running (which seems to be intended) even for unreachable code.

Closes astral-sh/ty#2891.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 10, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 85.29%. The percentage of expected errors that received a diagnostic held steady at 78.13%. The number of fully passing files held steady at 64/132.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 10, 2026

mypy_primer results

Changes were detected when running on open source projects
mypy_primer (https://github.com/hauntsaninja/mypy_primer)
- mypy_primer/utils.py:32:16: error[invalid-assignment] Object of type `str` is not assignable to `Path`
- mypy_primer/utils.py:33:16: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `Path`
- mypy_primer/utils.py:37:16: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal["\""]` and `Path`
- Found 4 diagnostics
+ Found 1 diagnostic

anyio (https://github.com/agronholm/anyio)
- src/anyio/_core/_fileio.py:412:51: error[unknown-argument] Argument `case_sensitive` does not match any known parameter of bound method `match`
- src/anyio/_core/_fileio.py:501:44: error[unknown-argument] Argument `case_sensitive` does not match any known parameter of bound method `glob`
+ src/anyio/_core/_fileio.py:515:27: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/anyio/_core/_fileio.py:516:17: error[unknown-argument] Argument `case_sensitive` does not match any known parameter of bound method `glob`
- src/anyio/_core/_fileio.py:517:17: error[unknown-argument] Argument `recurse_symlinks` does not match any known parameter of bound method `glob`
- src/anyio/_core/_fileio.py:654:57: error[unknown-argument] Argument `walk_up` does not match any known parameter of bound method `relative_to`
- src/anyio/_core/_fileio.py:694:45: error[unknown-argument] Argument `case_sensitive` does not match any known parameter of bound method `rglob`
+ src/anyio/_core/_fileio.py:708:27: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/anyio/_core/_fileio.py:709:17: error[unknown-argument] Argument `case_sensitive` does not match any known parameter of bound method `rglob`
- src/anyio/_core/_fileio.py:710:17: error[unknown-argument] Argument `recurse_symlinks` does not match any known parameter of bound method `rglob`
- Found 92 diagnostics
+ Found 86 diagnostics

packaging (https://github.com/pypa/packaging)
- src/packaging/version.py:38:38: error[invalid-type-form] `[...]` is not a valid parameter list for `Callable`: Did you mean `Callable[..., object]`?
- Found 25 diagnostics
+ Found 24 diagnostics

async-utils (https://github.com/mikeshardmind/async-utils)
- src/async_utils/_graphs.py:38:36: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `int`
- src/async_utils/_graphs.py:39:62: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `bool`
- src/async_utils/_graphs.py:49:18: warning[unsupported-dynamic-base] Unsupported base for class created via `type()`: Has type `<special-form 'typing.Protocol'>`
- src/async_utils/corofunc_cache.py:50:58: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `CoroFunc[P@f__call__, R@f__call__]`
- src/async_utils/corofunc_cache.py:58:18: warning[unsupported-dynamic-base] Unsupported base for class created via `type()`: Has type `<special-form 'typing.Protocol'>`
- src/async_utils/task_cache.py:53:62: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `TaskFunc[P@f__call__, R@f__call__]`
- src/async_utils/task_cache.py:61:18: warning[unsupported-dynamic-base] Unsupported base for class created via `type()`: Has type `<special-form 'typing.Protocol'>`
- Found 8 diagnostics
+ Found 1 diagnostic

DateType (https://github.com/glyph/DateType)
+ src/datetype/__init__.py:524:16: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 14 diagnostics
+ Found 15 diagnostics

pip (https://github.com/pypa/pip)
- src/pip/_vendor/packaging/version.py:48:24: error[call-non-callable] Object of type `object` is not callable
- src/pip/_vendor/urllib3/packages/six.py:614:44: error[too-many-positional-arguments] Too many positional arguments to function `__new__`: expected 3, got 4
- src/pip/_vendor/urllib3/packages/six.py:617:45: error[too-many-positional-arguments] Too many positional arguments to function `__new__`: expected 3, got 4
- Found 700 diagnostics
+ Found 697 diagnostics

spack (https://github.com/spack/spack)
- lib/spack/spack/vendor/six.py:574:44: error[too-many-positional-arguments] Too many positional arguments to function `__new__`: expected 3, got 4
- lib/spack/spack/vendor/six.py:577:45: error[too-many-positional-arguments] Too many positional arguments to function `__new__`: expected 3, got 4
- Found 4449 diagnostics
+ Found 4447 diagnostics

beartype (https://github.com/beartype/beartype)
+ beartype/_util/error/utilerrwarn.py:88:80: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 511 diagnostics
+ Found 512 diagnostics

pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_config.py:156:41: error[invalid-key] TypedDict `ConfigDict` can only be subscripted with a string literal key, got key of type `str`
- pydantic/_internal/_config.py:159:44: error[invalid-key] TypedDict `ConfigDict` can only be subscripted with a string literal key, got key of type `str`
- pydantic/functional_serializers.py:457:36: error[call-non-callable] Object of type `GenericAlias` is not callable
- pydantic/functional_validators.py:781:20: error[invalid-return-type] Return type does not match returned value: expected `AnyType@__class_getitem__`, found `<special-form 'typing.Annotated[Unknown, <metadata>]'>`
- pydantic/functional_validators.py:824:36: error[call-non-callable] Object of type `GenericAlias` is not callable
- pydantic/json_schema.py:2843:20: error[invalid-return-type] Return type does not match returned value: expected `AnyType@__class_getitem__`, found `<special-form 'typing.Annotated[Unknown, <metadata>]'>`
- pydantic/main.py:1069:58: error[call-non-callable] Object of type `object` is not callable
- pydantic/main.py:1098:21: error[invalid-assignment] Cannot assign to a subscript on an object of type `None`
+ pydantic/main.py:1024:61: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ pydantic/main.py:1113:49: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ pydantic/main.py:1118:58: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ pydantic/networks.py:1185:38: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ pydantic/networks.py:1224:38: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ pydantic/networks.py:1265:38: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- pydantic/types.py:994:20: error[invalid-return-type] Return type does not match returned value: expected `AnyType@__class_getitem__`, found `<special-form 'typing.Annotated[Unknown, <metadata>]'>`
- pydantic/types.py:1510:20: error[invalid-return-type] Return type does not match returned value: expected `AnyType@__class_getitem__`, found `<special-form 'typing.Annotated[Unknown, <metadata>]'>`
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `DefinitionReferenceSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `DecimalSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `StringSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `BytesSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `TimeSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `TimedeltaSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `LiteralSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `MissingSentinelSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `EnumSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `IsInstanceSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `IsSubclassSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `CallableSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `ListSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `TupleSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `SetSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `FrozenSetSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `GeneratorSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `DictSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `AfterValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `BeforeValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `WrapValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `PlainValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `WithDefaultSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `NullableSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `FloatSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `TaggedUnionSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `ChainSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `LaxOrStrictSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `JsonOrPythonSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `TypedDictSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `ModelFieldsSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `ModelSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `DataclassArgsSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `DataclassSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `ArgumentsSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `ArgumentsV3Schema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `CallSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `CustomErrorSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `JsonSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `UrlSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `MultiHostUrlSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `DefinitionsSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `InvalidSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `UuidSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `ComplexSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `AnySchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `NoneSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `BoolSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `IntSchema`: Unknown key "now_op"
- pydantic/types.py:2210:24: error[invalid-key] Unknown key "now_op" for TypedDict `UnionSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `NullableSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `DecimalSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `StringSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `BytesSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `TimeSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `TimedeltaSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `LiteralSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `MissingSentinelSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `EnumSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `IsInstanceSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `IsSubclassSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `CallableSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `ListSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `TupleSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `SetSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `FrozenSetSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `GeneratorSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `DictSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `AfterValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `BeforeValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `WrapValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `PlainValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `WithDefaultSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `InvalidSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `FloatSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `TaggedUnionSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `ChainSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `LaxOrStrictSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `JsonOrPythonSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `TypedDictSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `ModelFieldsSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `ModelSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `DataclassArgsSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `DataclassSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `ArgumentsSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `ArgumentsV3Schema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `CallSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `CustomErrorSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `JsonSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `UrlSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `MultiHostUrlSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `DefinitionsSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `DefinitionReferenceSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `UuidSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `ComplexSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `IntSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `AnySchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `NoneSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `BoolSchema`: Unknown key "now_op"
- pydantic/types.py:2229:24: error[invalid-key] Unknown key "now_op" for TypedDict `UnionSchema`: Unknown key "now_op"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `CallSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `FloatSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DecimalSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `StringSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `BytesSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DateSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `TimedeltaSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `LiteralSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `MissingSentinelSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `EnumSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `IsInstanceSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `IsSubclassSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `CallableSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ListSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `TupleSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `SetSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `FrozenSetSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `GeneratorSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DictSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `AfterValidatorFunctionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `BeforeValidatorFunctionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `WrapValidatorFunctionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `PlainValidatorFunctionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `WithDefaultSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `IntSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `UnionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `TaggedUnionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ChainSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `LaxOrStrictSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `JsonOrPythonSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `TypedDictSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ModelFieldsSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ModelSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DataclassArgsSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DataclassSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ArgumentsSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ArgumentsV3Schema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `InvalidSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `CustomErrorSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `JsonSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `UrlSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `MultiHostUrlSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DefinitionsSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DefinitionReferenceSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `UuidSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ComplexSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `AnySchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `NoneSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `BoolSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2286:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `NullableSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `TupleSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `FloatSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DecimalSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `StringSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `BytesSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DateSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `TimedeltaSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `LiteralSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `MissingSentinelSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `EnumSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `IsInstanceSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `IsSubclassSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `CallableSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ListSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `InvalidSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `SetSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `FrozenSetSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `GeneratorSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DictSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `AfterValidatorFunctionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `BeforeValidatorFunctionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `WrapValidatorFunctionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `PlainValidatorFunctionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `WithDefaultSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `IntSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `UnionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `TaggedUnionSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ChainSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `LaxOrStrictSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `JsonOrPythonSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `TypedDictSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ModelFieldsSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ModelSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DataclassArgsSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DataclassSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ArgumentsSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ArgumentsV3Schema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `CallSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `CustomErrorSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `JsonSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `UrlSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `MultiHostUrlSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DefinitionsSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `DefinitionReferenceSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `UuidSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `ComplexSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `BoolSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `AnySchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `NoneSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2305:24: error[invalid-key] Unknown key "tz_constraint" for TypedDict `NullableSchema`: Unknown key "tz_constraint"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `JsonOrPythonSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `FloatSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `DecimalSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `StringSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `BytesSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `TimeSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `TimedeltaSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `LiteralSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `MissingSentinelSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `EnumSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `IsInstanceSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `IsSubclassSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `CallableSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `ListSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `TupleSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `SetSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `FrozenSetSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `GeneratorSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `DictSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `AfterValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `BeforeValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `WrapValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `PlainValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `WithDefaultSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `IntSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `UnionSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `TaggedUnionSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `ChainSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `LaxOrStrictSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `InvalidSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `TypedDictSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `ModelFieldsSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `ModelSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `DataclassArgsSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `DataclassSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `ArgumentsSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `ArgumentsV3Schema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `CallSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `CustomErrorSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `JsonSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `UrlSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `MultiHostUrlSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `DefinitionsSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `DefinitionReferenceSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `UuidSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `ComplexSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `BoolSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `AnySchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `NoneSchema`: Unknown key "now_op"
- pydantic/types.py:2324:24: error[invalid-key] Unknown key "now_op" for TypedDict `NullableSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `CallSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `IntSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `FloatSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `DecimalSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `StringSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `BytesSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `TimeSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `TimedeltaSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `LiteralSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `MissingSentinelSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `EnumSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `IsInstanceSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `IsSubclassSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `CallableSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `ListSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `TupleSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `SetSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `FrozenSetSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `GeneratorSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `DictSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `AfterValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `BeforeValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `WrapValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `PlainValidatorFunctionSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `BoolSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `NullableSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `UnionSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `TaggedUnionSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `ChainSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `LaxOrStrictSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `JsonOrPythonSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `TypedDictSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `ModelFieldsSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `ModelSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `DataclassArgsSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `DataclassSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `ArgumentsSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `ArgumentsV3Schema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `InvalidSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `CustomErrorSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `JsonSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `UrlSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `MultiHostUrlSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `DefinitionsSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `DefinitionReferenceSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `UuidSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `ComplexSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `AnySchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `NoneSchema`: Unknown key "now_op"
- pydantic/types.py:2343:24: error[invalid-key] Unknown key "now_op" for TypedDict `WithDefaultSchema`: Unknown key "now_op"
- Found 3194 diagnostics
+ Found 2890 diagnostics

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/connection.py:298:73: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ src/urllib3/connection.py:311:81: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ src/urllib3/connection.py:315:87: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 277 diagnostics
+ Found 280 diagnostics

psycopg (https://github.com/psycopg/psycopg)
- psycopg_pool/psycopg_pool/pool_async.py:140:13: warning[unused-awaitable] Object of type `CoroutineType[Any, Any, None]` is not awaited
- psycopg_pool/psycopg_pool/pool_async.py:140:22: error[not-iterable] Object of type `CoroutineType[Any, Any, list[Task[None]]]` is not iterable
- Found 666 diagnostics
+ Found 664 diagnostics

mypy (https://github.com/python/mypy)
- mypy/typeshed/stdlib/annotationlib.pyi:59:29: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member
- mypy/typeshed/stdlib/annotationlib.pyi:69:29: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member
- mypy/typeshed/stdlib/builtins.pyi:275:94: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `bool`
- mypy/typeshed/stdlib/builtins.pyi:283:13: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `bool`
- mypy/typeshed/stdlib/builtins.pyi:1484:84: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `bool`
- mypy/typeshed/stdlib/builtins.pyi:1487:103: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `bool`
- mypy/typeshed/stdlib/builtins.pyi:1498:13: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `bool`
- mypy/typeshed/stdlib/builtins.pyi:1510:13: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `bool`
- mypy/typeshed/stdlib/builtins.pyi:1523:13: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `bool`
- mypy/typeshed/stdlib/builtins.pyi:1537:13: error[invalid-parameter-default] Default value of type `Literal[False]` is not assignable to annotated parameter type `bool`
- mypy/typeshed/stdlib/builtins.pyi:2176:100: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2176:100: error[invalid-type-form] `...` is not allowed in this context in a type expression
- mypy/typeshed/stdlib/builtins.pyi:2179:79: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2179:79: error[invalid-type-form] `...` is not allowed in this context in a type expression
- mypy/typeshed/stdlib/builtins.pyi:2183:87: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2183:87: error[invalid-type-form] `...` is not allowed in this context in a type expression
- mypy/typeshed/stdlib/builtins.pyi:2191:79: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2191:79: error[invalid-type-form] `...` is not allowed in this context in a type expression
- mypy/typeshed/stdlib/builtins.pyi:2192:56: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2195:87: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2195:87: error[invalid-type-form] `...` is not allowed in this context in a type expression
- mypy/typeshed/stdlib/builtins.pyi:2196:64: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2200:67: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2212:88: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2212:88: error[invalid-type-form] `...` is not allowed in this context in a type expression
- mypy/typeshed/stdlib/builtins.pyi:2216:79: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2216:79: error[invalid-type-form] `...` is not allowed in this context in a type expression
- mypy/typeshed/stdlib/builtins.pyi:2224:79: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2224:79: error[invalid-type-form] `...` is not allowed in this context in a type expression
- mypy/typeshed/stdlib/builtins.pyi:2225:56: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/builtins.pyi:2229:59: error[invalid-type-arguments] Too many type arguments to class `tuple`: expected 1, got 2
- mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi:67:43: error[invalid-type-form] The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...`
- mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi:68:53: error[invalid-type-form] The first argument to `Callable` must be either a list of types, ParamSpec, Concatenate, or `...`
- Found 1761 diagnostics
+ Found 1728 diagnostics

discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/converter.py:1235:89: error[unresolved-attribute] Attribute `name` is not defined on `None` in union `Parameter | None`
- Found 558 diagnostics
+ Found 557 diagnostics

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- bson/codec_options.py:397:45: error[invalid-argument-type] Argument to function `issubclass` is incorrect: Expected `type`, found `object`
- Found 435 diagnostics
+ Found 434 diagnostics

trio (https://github.com/python-trio/trio)
- src/trio/_core/_generated_io_windows.py:112:68: error[invalid-argument-type] Argument to bound method `notify_closing` is incorrect: Expected `int | _HasFileNo`, found `Handle | int | _HasFileNo`
- src/trio/_core/_io_windows.py:322:16: error[call-non-callable] Object of type `object` is not callable
- src/trio/_core/_io_windows.py:367:24: error[call-non-callable] Object of type `object` is not callable
+ src/trio/_core/_io_windows.py:711:52: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ src/trio/_core/_io_windows.py:713:52: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/trio/_core/_tests/test_windows.py:263:20: error[call-non-callable] Object of type `object` is not callable
- src/trio/_core/_tests/test_windows.py:294:20: error[call-non-callable] Object of type `object` is not callable
- src/trio/_socket.py:879:20: error[unresolved-attribute] Attribute `share` is not defined on `socket` in union `Unknown | socket`
- src/trio/_windows_pipes.py:137:24: error[invalid-return-type] Return type does not match returned value: expected `bytes`, found `bytearray`
- Found 469 diagnostics
+ Found 464 diagnostics

setuptools (https://github.com/pypa/setuptools)
- setuptools/_vendor/packaging/version.py:48:24: error[call-non-callable] Object of type `object` is not callable
- Found 1177 diagnostics
+ Found 1176 diagnostics

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/_compat/typing.py:38:20: error[invalid-legacy-type-variable] A `TypeVar` definition must be a simple variable assignment
- src/scikit_build_core/_compat/typing.py:38:35: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `object`
- src/scikit_build_core/_compat/typing.py:38:42: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `object`
- src/scikit_build_core/_compat/typing.py:38:42: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool`, found `object`
- Found 59 diagnostics
+ Found 55 diagnostics

aiohttp (https://github.com/aio-libs/aiohttp)
- aiohttp/client.py:460:14: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `_BaseRequestContextManager[ClientResponse]`
- aiohttp/client.py:1291:14: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `_BaseRequestContextManager[ClientResponse]`
- aiohttp/client.py:1297:14: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `_BaseRequestContextManager[ClientResponse]`
- aiohttp/client.py:1303:14: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `_BaseRequestContextManager[ClientResponse]`
- aiohttp/client.py:1309:14: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `_BaseRequestContextManager[ClientResponse]`
- aiohttp/client.py:1315:14: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `_BaseRequestContextManager[ClientResponse]`
- aiohttp/client.py:1321:14: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `_BaseRequestContextManager[ClientResponse]`
- aiohttp/client.py:1327:14: error[empty-body] Function always implicitly returns `None`, which is not assignable to return type `_BaseRequestContextManager[ClientResponse]`
- Found 197 diagnostics
+ Found 189 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/internal/coverage/instrumentation_py3_11.py:172:27: error[unsupported-operator] Operator `<<` is not supported between objects of type `int | None` and `Literal[1]`
- ddtrace/internal/coverage/instrumentation_py3_11.py:336:46: error[invalid-argument-type] Argument to bound method `from_bytes` is incorrect: Expected `Iterable[SupportsIndex] | SupportsBytes | Buffer`, found `list[bytes | Unknown]`
- ddtrace/internal/coverage/instrumentation_py3_12.py:218:46: error[invalid-argument-type] Argument to bound method `from_bytes` is incorrect: Expected `Iterable[SupportsIndex] | SupportsBytes | Buffer`, found `list[bytes | Unknown]`
- ddtrace/internal/coverage/instrumentation_py3_12.py:243:21: error[invalid-assignment] Invalid subscript assignment with key of type `int` and value of type `tuple[None | str, tuple[str, ...]]` on object of type `dict[int, tuple[str, tuple[str, ...]]]`
- ddtrace/internal/coverage/instrumentation_py3_12.py:248:21: error[invalid-assignment] Invalid subscript assignment with key of type `int` and value of type `tuple[None | str, tuple[str]]` on object of type `dict[int, tuple[str, tuple[str, ...]]]`
- ddtrace/internal/products.py:27:34: error[unknown-argument] Argument `group` does not match any known parameter of function `entry_points`
- ddtrace/vendor/psutil/__init__.py:928:20: error[unresolved-attribute] Attribute `num_handles` is not defined on `Process` in union `Unknown | Process`
- Found 9361 diagnostics
+ Found 9354 diagnostics

pywin32 (https://github.com/mhammond/pywin32)
- Pythonwin/pywin/idle/PyParse.py:10:9: error[unresolved-attribute] Attribute `write` is not defined on `None` in union `TextIOWrapper[_WrappedBuffer] | None`
- Found 2739 diagnostics
+ Found 2738 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/external/gmpy.py:707:20: error[unresolved-attribute] Attribute `iroot` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:741:16: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:746:16: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:749:16: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:752:23: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:752:45: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:755:23: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:755:45: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:764:16: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- sympy/external/gmpy.py:770:17: error[unresolved-attribute] Attribute `fmpz` is not defined on `None` in union `ModuleType | None`
- Found 16479 diagnostics
+ Found 16469 diagnostics

scipy (https://github.com/scipy/scipy)
- scipy/_lib/_util.py:61:34: error[unknown-argument] Argument `annotation_format` does not match any known parameter of function `signature`
- Found 7976 diagnostics
+ Found 7975 diagnostics

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 10, 2026

Memory usage report

Memory usage unchanged ✅

@charliermarsh charliermarsh added ty Multi-file analysis & type inference ecosystem-analyzer labels Mar 10, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 10, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-key 0 302 0
invalid-await 40 0 0
unused-type-ignore-comment 15 0 0
unresolved-attribute 0 14 0
invalid-type-arguments 0 13 0
invalid-type-form 0 13 0
empty-body 0 12 0
unknown-argument 0 10 0
call-non-callable 0 9 0
invalid-parameter-default 0 8 0
invalid-argument-type 0 7 0
invalid-return-type 1 5 0
invalid-assignment 0 4 0
too-many-positional-arguments 0 4 0
unsupported-dynamic-base 0 3 0
unsupported-operator 0 2 0
invalid-legacy-type-variable 0 1 0
not-iterable 0 1 0
unused-awaitable 0 1 0
Total 56 409 0

Full report with detailed diff (timing results)

@charliermarsh
Copy link
Member Author

I... think we want this behavior?

@charliermarsh charliermarsh marked this pull request as draft March 10, 2026 01:51
@charliermarsh charliermarsh marked this pull request as ready for review March 10, 2026 01:58
@MichaReiser
Copy link
Member

@sharkdp has probably opinions on this

@sharkdp sharkdp assigned sharkdp and unassigned ibraheemdev Mar 10, 2026
@carljm carljm removed their request for review March 11, 2026 05:16
Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you!

Comment on lines +467 to +468
This also applies to deferred annotations on Python 3.14+, which otherwise make the unreachable
scope look more "real" during body checking:
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe

Suggested change
This also applies to deferred annotations on Python 3.14+, which otherwise make the unreachable
scope look more "real" during body checking:
This also applies to deferred annotations on Python 3.14+, which are resolved from the
perspective of the end of the scope, which may not be part of the unreachable section.

Comment on lines +445 to +450
// Nested scopes in statically unreachable branches should not produce body diagnostics.
if !semantic_index(ctx.db, ctx.file)
.is_scope_reachable(ctx.db, ctx.scope.file_scope_id(ctx.db))
{
return None;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the actual change that we want.

The empty-body rule was moved from function body inference to deferred function-definition validation to ensure that it keeps running (which seems to be intended) even for unreachable code.

I looked at those test cases and I would argue that we want a different behavior there. This might have been intended in the past, but we've since come to the conclusion that we may be required to silence all diagnostics in definitely-unreachable sections. So I'll push a change to this PR that removes most of the changes and only leaves this part. Instead, I'm going to modify the test cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is in reference to if not TYPE_CHECKING, I'm not sure that we should extrapolate from that to "all definitely unreachable sections" of code. I think we probably will need to suppress all errors in if not TYPE_CHECKING sections, and I think there are arguments for that that don't apply to other unreachable sections.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is in reference to if not TYPE_CHECKING, I'm not sure that we should extrapolate from that to "all definitely unreachable sections" of code.

Yes, I was referring to some recent discussions related to python/typing#2210. It's possible that those lines above are too big of a hammer (because they make no such distinction), but I'm less and less convinced that it's worth spending a lot of effort to emit diagnostics for code like

if False:
    "a" + 1

Sure, this line would definitely lead to a runtime error if it was reachable, but is that diagnostic really that useful? No other type checker makes an effort. And it is a reasonable developer/debugging use case to put an early return in a large function to silence diagnostics in "everything that comes below" (apart from the future "this is unreachable" graying out LSP feature / lint rule).

I probably shouldn't have said "we've since come to the conclusion" — the statement above was just based on some discussion with @AlexWaygood this morning.

What are some concrete scenarios where we would definitely want to emit a diagnostic in definitely-unreachable sections of code?

Copy link
Member

Choose a reason for hiding this comment

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

The only diagnostic which I would really like us to continue to try hard to emit in unreachable code is reveal_type diagnostics -- it's very confusing for users if a reveal_type call silently causes us not to emit a revealed-type diagnostic, especially if they have warnings about unreachable code turned off. Maybe assert_type and assert_never calls fall into a similar bucket there?

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 there might actually already be cases where we (accidentally?) suppress some of those diagnostics in unreachable regions, though, IIRC

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there might actually already be cases where we (accidentally?) suppress some of those diagnostics in unreachable regions, though, IIRC

This doesn't ring a bell for me -- any further memory of in which cases you recall this happening, or why?

Copy link
Contributor

@carljm carljm Mar 13, 2026

Choose a reason for hiding this comment

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

We did have user feedback way back in #15797 (comment) from a couple users that the desired behavior, at least for some kinds of unreachable code, for some developers, was "full diagnostics". I think it's clear that "full diagnostics" is not possible without false positives, but that does at least suggest that creating unreachable code intentionally during development, for other reasons, and still wanting full diagnostics on it, is also a valid developer use case.

Overall though, I don't think this matters too much either way and I'm happy for us to do whatever is simplest. (Up until now, I don't think we have gone to extra effort to preserve some diagnostics in unreachable code, I think it was the behavior that fell out naturally, and suppressing required extra work.) If we need to suppress all diagnostics in if not TYPE_CHECKING, then "simplest" is probably to suppress in all unreachable code, even if it doesn't follow as a strict requirement that we handle them the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there might actually already be cases where we (accidentally?) suppress some of those diagnostics in unreachable regions, though, IIRC

This doesn't ring a bell for me -- any further memory of in which cases you recall this happening, or why?

I think the current state is still accurately described in this mdtest section: https://github.com/astral-sh/ruff/blob/main/crates/ty_python_semantic/resources/mdtest/unreachable.md#no-incorrect-diagnostics-in-unreachable-code: "[…] we do not attempt to provide the full set of diagnostics in unreachable sections. In fact, a large number of diagnostics are suppressed in unreachable code, simply due to the fact that we infer Never for most of the symbols."

On top of this, Alex is right in the sense that there are some special diagnostics that are simply "turned off" in unreachable sections (to be more precise, we turn them off if the AST node on which we would emit the diagnostic is unreachable). For example, we turn off unresolved-reference here. See also this mdtest and the ones following.

We did have user feedback way back in #15797 (comment) from a couple users that the desired behavior, at least for some kinds of unreachable code, for some developers, was "full diagnostics". I think it's clear that "full diagnostics" is not possible without false positives, but that does at least suggest that creating unreachable code intentionally during development, for other reasons, and still wanting full diagnostics on it, is also a valid developer use case.

👍

Overall though, I don't think this matters too much either way and I'm happy for us to do whatever is simplest.

Okay

(Up until now, I don't think we have gone to extra effort to preserve some diagnostics in unreachable code, I think it was the behavior that fell out naturally, and suppressing required extra work.)

Yeah, maybe. I think it might have been easier to keep track of reachability constraints for all AST nodes (or for basic blocks, for performance reasons) and to simply suppress all diagnostics in unreachable code. I agree it's not like it was super hard to arrive at the current state, and maybe it's what fell out most naturally, but we did quite a few adjustments on top of "everything will be fine because we infer Never everywhere". To give one one additional example, consider something like

if sys.version_info >= (3, 11):
    import tomllib
    # …

If we wouldn't track reachability constraints for that import node in order to explicitly silence the unresolved-import diagnostic in unreachable sections, this would lead to a false positive when checking on lower Python versions.

So in conclusion, I think it's reasonable to try and make an effort to further patch little things like astral-sh/ty#2891 by dedicated means when they come up. But if we agree that it "doesn't matter too much either way", maybe the easier way would be the big hammer of silencing all diagnostics in unreachable code. This PR is somewhere weirdly in between these two approaches (in that it only swings the big hammer for nested scopes inside unreachable sections), so maybe we should indeed spend a bit more time discussing this before making a decision here.

Copy link
Member

@AlexWaygood AlexWaygood Mar 13, 2026

Choose a reason for hiding this comment

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

I think there might actually already be cases where we (accidentally?) suppress some of those diagnostics in unreachable regions, though, IIRC

This doesn't ring a bell for me -- any further memory of in which cases you recall this happening, or why?

Claude found a repro for me:

from typing import reveal_type, assert_type, assert_never
 
def after_return():
    x: int = 1
    return
    reveal_type(x)      # expected: info diagnostic showing type
                        # actual:   nothing
 
def always_false_branch():
    x: int = 1
    if False:
        reveal_type(x)   # expected: info diagnostic
                         # actual:   nothing
 
def exhaustive_narrowing(x: int | str):
    if isinstance(x, int):
        return 1
    elif isinstance(x, str):
        return 2
    else:
        reveal_type(x)        # expected: revealed type `Never`
                              # actual:   nothing
 
        assert_type(x, int)   # expected: type-assertion-failure
                              # actual:   nothing
 
        assert_never(x)

The issue is that in unreachable regions, the symbols reveal_type, assert_never and assert_type are all actually inferred as having type Never right now. So even the final assert_never call looks like it's working as expected... but it's actually not at all -- the function itself is being inferred as Never, so we're not inferring a call to the function typing.assert_never at all here. https://play.ty.dev/f2163845-feab-4be8-8423-29d461adb33f

note that reveal_type actually works much better... if you don't import it at all... https://play.ty.dev/3dc64038-1ee7-451f-a855-7b70f25c4150

@sharkdp sharkdp force-pushed the charlie/unreachable branch from 85b1132 to 137b350 Compare March 12, 2026 13:44
else:
def j_() -> str: ... # error: [empty-body]
def j():
raise NotImplementedError
Copy link
Contributor

Choose a reason for hiding this comment

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

The change to the code is not really necessary, but think this better reflects how someone would actually write this code. They would use the if TYPE_CHECKING branch to provide a type signature, and then use the else branch for the actual implementation (that may or may not have caused some diagnostics, if it were not in a non-TYPE_CHECKING block).

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.

call-non-callable in not TYPE_CHECKING scope only on Python 3.14

6 participants