Skip to content

[ty] Detect invalid partially stringified PEP-604 unions#23285

Merged
AlexWaygood merged 8 commits intomainfrom
alex/type-expression-quotes
Mar 6, 2026
Merged

[ty] Detect invalid partially stringified PEP-604 unions#23285
AlexWaygood merged 8 commits intomainfrom
alex/type-expression-quotes

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Feb 15, 2026

Summary

PEP-604 unions such as "int" | str fail at runtime on Python <3.14 without __future__ annotations. There are conformance-suite tests that mandate that we should detect this runtime error even inside type expressions.

This PR employs multi-inference in order to detect these errors, even inside type expressions.

Test Plan

Mdtests and snapshots added and updated.

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Feb 15, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 15, 2026

Typing conformance results improved 🎉

The percentage of diagnostics emitted that were expected errors increased from 87.07% to 87.10%. The percentage of expected errors that received a diagnostic increased from 77.62% to 77.81%.

Summary

How are test cases classified?

Each test case represents one expected error annotation or a group of annotations sharing a tag. Counts are per test case, not per diagnostic — multiple diagnostics on the same line count as one. Required annotations (E) are true positives when ty flags the expected location and false negatives when it does not. Optional annotations (E?) are true positives when flagged but true negatives (not false negatives) when not. Tagged annotations (E[tag]) require ty to flag exactly one of the tagged lines; tagged multi-annotations (E[tag+]) allow any number up to the tag count. Flagging unexpected locations counts as a false positive.

Metric Old New Diff Outcome
True Positives 808 810 +2 ⏫ (✅)
False Positives 120 120 +0
False Negatives 233 231 -2 ⏬ (✅)
Total Diagnostics 1003 1005 +2
Precision 87.07% 87.10% +0.03% ⏫ (✅)
Recall 77.62% 77.81% +0.19% ⏫ (✅)

Test file breakdown

1 file altered
File True Positives False Positives False Negatives Status
annotations_forward_refs.py 22 (+2) ✅ 4 0 (-2) ✅ 📈 Improving
Total (all files) 810 (+2) ✅ 120 231 (-2) ✅ 63/131

True positives added (2)

2 diagnostics
Test case Diff

annotations_forward_refs.py:24

+error[unsupported-operator] Operator `|` is unsupported between objects of type `Literal["ClassA"]` and `<class 'int'>`

annotations_forward_refs.py:25

+error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `Literal["ClassA"]`

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 15, 2026

Memory usage report

Summary

Project Old New Diff Outcome
prefect 694.19MB 694.69MB +0.07% (511.40kB)
sphinx 265.38MB 265.49MB +0.04% (111.41kB)
trio 118.04MB 118.08MB +0.04% (44.91kB)
flake8 47.91MB 47.92MB +0.03% (16.17kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
check_file_impl 17.25MB 17.61MB +2.09% (369.63kB)
infer_definition_types 87.33MB 87.37MB +0.05% (46.17kB)
infer_deferred_types 14.16MB 14.20MB +0.23% (33.82kB)
Type<'db>::class_member_with_policy_ 17.10MB 17.11MB +0.09% (16.51kB)
infer_scope_types_impl 51.92MB 51.94MB +0.03% (15.75kB)
Type<'db>::member_lookup_with_policy_ 15.26MB 15.27MB +0.04% (6.75kB)
Type<'db>::member_lookup_with_policy_::interned_arguments 5.44MB 5.44MB +0.11% (5.99kB)
Type<'db>::class_member_with_policy_::interned_arguments 9.19MB 9.20MB +0.06% (5.69kB)
infer_expression_types_impl 59.59MB 59.60MB +0.01% (3.72kB)
infer_expression_type_impl 14.26MB 14.26MB +0.02% (2.59kB)
StaticClassLiteral<'db>::implicit_attribute_inner_ 9.72MB 9.72MB +0.01% (904.00B)
all_negative_narrowing_constraints_for_expression 2.58MB 2.58MB +0.02% (548.00B)
UnionType 3.51MB 3.51MB +0.01% (496.00B)
all_narrowing_constraints_for_expression 6.92MB 6.92MB +0.01% (496.00B)
is_redundant_with_impl::interned_arguments 5.36MB 5.36MB +0.01% (352.00B)
... 16 more

sphinx

Name Old New Diff Outcome
check_file_impl 5.05MB 5.12MB +1.53% (78.94kB)
infer_scope_types_impl 15.57MB 15.59MB +0.07% (11.64kB)
Type<'db>::class_member_with_policy_ 7.55MB 7.56MB +0.10% (7.72kB)
Type<'db>::member_lookup_with_policy_ 6.11MB 6.11MB +0.04% (2.69kB)
Type<'db>::member_lookup_with_policy_::interned_arguments 2.54MB 2.55MB +0.10% (2.54kB)
Type<'db>::class_member_with_policy_::interned_arguments 3.99MB 3.99MB +0.06% (2.44kB)
StaticClassLiteral<'db>::implicit_attribute_inner_ 2.38MB 2.39MB +0.07% (1.64kB)
StaticClassLiteral<'db>::implicit_attribute_inner_::interned_arguments 1.91MB 1.91MB +0.07% (1.41kB)
StringLiteralType 2.03MB 2.03MB +0.03% (560.00B)
infer_expression_types_impl 21.50MB 21.50MB +0.00% (496.00B)
place_by_id 1.37MB 1.37MB +0.02% (248.00B)
infer_definition_types 24.06MB 24.06MB +0.00% (224.00B)
StaticClassLiteral<'db>::try_metaclass_ 351.89kB 352.09kB +0.06% (208.00B)
place_by_id::interned_arguments 1.04MB 1.04MB +0.01% (144.00B)
InternedType 1.55kB 1.69kB +9.09% (144.00B)
... 5 more

trio

Name Old New Diff Outcome
check_file_impl 1.92MB 1.95MB +1.38% (27.05kB)
Type<'db>::class_member_with_policy_ 2.00MB 2.01MB +0.24% (4.90kB)
infer_scope_types_impl 4.79MB 4.79MB +0.07% (3.63kB)
Type<'db>::member_lookup_with_policy_ 1.70MB 1.70MB +0.13% (2.20kB)
Type<'db>::member_lookup_with_policy_::interned_arguments 870.39kB 872.22kB +0.21% (1.83kB)
Type<'db>::class_member_with_policy_::interned_arguments 1.11MB 1.11MB +0.14% (1.62kB)
infer_definition_types 7.59MB 7.59MB +0.02% (1.37kB)
StaticClassLiteral<'db>::implicit_attribute_inner_ 773.05kB 774.14kB +0.14% (1.09kB)
StaticClassLiteral<'db>::implicit_attribute_inner_::interned_arguments 618.19kB 619.12kB +0.15% (960.00B)
InternedType 1.12kB 1.27kB +12.50% (144.00B)
Type<'db>::apply_specialization_::interned_arguments 645.39kB 645.47kB +0.01% (80.00B)
Type<'db>::apply_specialization_ 737.39kB 737.45kB +0.01% (56.00B)

flake8

Name Old New Diff Outcome
check_file_impl 336.29kB 344.70kB +2.50% (8.41kB)
Type<'db>::class_member_with_policy_ 549.85kB 551.86kB +0.37% (2.01kB)
infer_scope_types_impl 1002.64kB 1004.35kB +0.17% (1.70kB)
Type<'db>::member_lookup_with_policy_::interned_arguments 207.09kB 208.00kB +0.44% (936.00B)
Type<'db>::member_lookup_with_policy_ 410.35kB 411.20kB +0.21% (864.00B)
Type<'db>::class_member_with_policy_::interned_arguments 300.83kB 301.54kB +0.24% (728.00B)
infer_expression_types_impl 1.06MB 1.06MB +0.04% (496.00B)
StaticClassLiteral<'db>::implicit_attribute_inner_ 295.25kB 295.69kB +0.15% (448.00B)
StaticClassLiteral<'db>::implicit_attribute_inner_::interned_arguments 239.72kB 240.09kB +0.16% (384.00B)
place_by_id 143.80kB 143.93kB +0.08% (124.00B)
infer_expression_type_impl 158.34kB 158.43kB +0.06% (92.00B)
place_by_id::interned_arguments 106.80kB 106.88kB +0.07% (72.00B)

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 15, 2026

mypy_primer results

Changes were detected when running on open source projects
pyp (https://github.com/hauntsaninja/pyp)
+ pyp.py:343:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Call'>` and `None`
- Found 6 diagnostics
+ Found 7 diagnostics

packaging (https://github.com/pypa/packaging)
+ src/packaging/_tokenizer.py:106:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Token'>` and `None`
+ src/packaging/requirements.py:50:19: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/packaging/requirements.py:53:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Marker'>` and `None`
+ src/packaging/specifiers.py:311:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'tuple[str, Version]'>` and `None`
- Found 18 diagnostics
+ Found 22 diagnostics

pip (https://github.com/pypa/pip)
+ src/pip/_internal/cache.py:193:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'DirectUrl'>` and `None`
+ src/pip/_internal/cli/base_command.py:65:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'TempDirectoryTypeRegistry'>` and `None`
+ src/pip/_internal/cli/index_command.py:63:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'PipSession'>` and `None`
+ src/pip/_internal/index/collector.py:278:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_internal/index/collector.py:279:38: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_internal/index/package_finder.py:669:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'BaseSpecifier'>` and `None`
+ src/pip/_internal/index/package_finder.py:669:57: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Hashes'>` and `None`
+ src/pip/_internal/metadata/pkg_resources.py:85:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Mapping[Any, str]'>` and `None`
+ src/pip/_internal/models/target_python.py:66:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[Tag]'>` and `None`
+ src/pip/_internal/models/target_python.py:67:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'set[Tag]'>` and `None`
+ src/pip/_internal/network/auth.py:243:36: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Credentials'>` and `None`
+ src/pip/_internal/network/session.py:348:51: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ src/pip/_internal/network/session.py:389:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'InsecureCacheControlAdapter'>` and `<class 'InsecureHTTPAdapter'>`
+ src/pip/_internal/req/req_install.py:97:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_internal/req/req_install.py:113:40: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Link'>` and `None`
+ src/pip/_internal/req/req_install.py:117:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'DirectUrl'>` and `None`
+ src/pip/_internal/req/req_install.py:120:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_internal/req/req_install.py:135:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'BaseDistribution'>` and `None`
+ src/pip/_internal/req/req_install.py:140:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'TempDirectory'>` and `None`
+ src/pip/_internal/req/req_install.py:142:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'bool'>` and `None`
+ src/pip/_internal/req/req_install.py:160:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_internal/req/req_install.py:164:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'BaseDistribution'>` and `None`
+ src/pip/_internal/req/req_install.py:167:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[str]'>` and `None`
+ src/pip/_internal/req/req_install.py:173:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'BuildBackendHookCaller'>` and `None`
+ src/pip/_internal/req/req_install.py:179:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Path'>` and `None`
+ src/pip/_internal/req/req_uninstall.py:588:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[bytes]'>` and `None`
+ src/pip/_internal/resolution/resolvelib/candidates.py:162:21: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ src/pip/_internal/resolution/resolvelib/found_candidates.py:133:21: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'bool'>` and `None`
+ src/pip/_internal/resolution/resolvelib/requirements.py:56:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_internal/resolution/resolvelib/requirements.py:57:21: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ src/pip/_internal/resolution/resolvelib/requirements.py:133:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_internal/resolution/resolvelib/requirements.py:134:21: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ src/pip/_internal/resolution/resolvelib/requirements.py:164:21: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ src/pip/_internal/resolution/resolvelib/resolver.py:74:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Result[Requirement, Candidate, str]'>` and `None`
+ src/pip/_internal/vcs/subversion.py:196:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'tuple[int, ...]'>` and `None`
+ src/pip/_vendor/dependency_groups/_implementation.py:81:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Requirement'>` and `<class 'DependencyGroupInclude'>`
+ src/pip/_vendor/packaging/_tokenizer.py:106:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Token'>` and `None`
+ src/pip/_vendor/packaging/requirements.py:41:19: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/packaging/requirements.py:44:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Marker'>` and `None`
+ src/pip/_vendor/packaging/specifiers.py:269:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'tuple[str, Version]'>` and `None`
+ src/pip/_vendor/pkg_resources/__init__.py:3374:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/resolvelib/resolvers/resolution.py:86:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[State[RT@Resolution, CT@Resolution, KT@Resolution]]'>` and `None`
+ src/pip/_vendor/resolvelib/resolvers/resolution.py:87:39: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ src/pip/_vendor/resolvelib/structs.py:162:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Iterable[RT@_FactoryIterableView]'>` and `None`
+ src/pip/_vendor/truststore/_api.py:31:69: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'bytes'>`
+ src/pip/_vendor/truststore/_api.py:109:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/truststore/_api.py:110:18: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'SSLSession'>` and `None`
+ src/pip/_vendor/truststore/_api.py:141:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/truststore/_api.py:142:18: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'SSLSession'>` and `None`
+ src/pip/_vendor/truststore/_api.py:156:17: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'bytes'>`
+ src/pip/_vendor/truststore/_api.py:157:17: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'bytes'>`
+ src/pip/_vendor/truststore/_api.py:211:58: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[Any]'>` and `<class 'list[bytes]'>`
+ src/pip/_vendor/truststore/_api.py:325:21: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'SSLSocket'>` and `<class 'SSLObject'>`
+ src/pip/_vendor/truststore/_api.py:325:69: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/truststore/_macos.py:36:15: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/truststore/_macos.py:383:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/truststore/_macos.py:440:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[bytes]'>` and `None`
+ src/pip/_vendor/truststore/_openssl.py:64:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/truststore/_windows.py:326:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/truststore/_windows.py:390:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[bytes]'>` and `None`
+ src/pip/_vendor/truststore/_windows.py:417:19: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'c_void_p'>` and `None`
+ src/pip/_vendor/truststore/_windows.py:421:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ src/pip/_vendor/truststore/_windows.py:511:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
- Found 637 diagnostics
+ Found 700 diagnostics

pyjwt (https://github.com/jpadilla/pyjwt)
+ jwt/jwks_client.py:73:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'JWKSetCache'>` and `None`
- Found 35 diagnostics
+ Found 36 diagnostics

dedupe (https://github.com/dedupeio/dedupe)
+ dedupe/api.py:83:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Fingerprinter'>` and `None`
+ dedupe/api.py:677:13: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'MutableMapping[int, Mapping[str, Any]]'>` and `<class 'MutableMapping[str, Mapping[str, Any]]'>`
+ dedupe/predicates.py:168:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
- Found 52 diagnostics
+ Found 55 diagnostics

PyWinCtl (https://github.com/Kalmat/PyWinCtl)
+ src/pywinctl/_main.py:453:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class '_WatchDogWorker'>` and `None`
- Found 21 diagnostics
+ Found 22 diagnostics

PyGithub (https://github.com/PyGithub/PyGithub)
+ github/AccessToken.py:57:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ github/AccessToken.py:58:45: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ github/AdvisoryVulnerabilityPackage.py:69:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/Auth.py:527:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/Auth.py:528:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/Authorization.py:66:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/Authorization.py:67:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/CheckRun.py:93:39: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/CodeScanAlert.py:70:48: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/CodeScanAlert.py:71:39: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/CodeScanAlert.py:72:39: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `None`
+ github/CodeScanAlert.py:73:44: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/CodeScanAlert.py:74:43: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/CodeScanAlert.py:75:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/CommitComment.py:90:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/CommitStatus.py:71:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/CopilotSeat.py:52:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Attribute[NamedUser]'>` and `<class '_NotSetType'>`
+ github/CopilotSeat.py:53:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Attribute[Team]'>` and `<class '_NotSetType'>`
+ github/CopilotSeat.py:54:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Attribute[datetime]'>` and `<class '_NotSetType'>`
+ github/CopilotSeat.py:55:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Attribute[datetime]'>` and `<class '_NotSetType'>`
+ github/CopilotSeat.py:56:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Attribute[str]'>` and `<class '_NotSetType'>`
+ github/CopilotSeat.py:59:42: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Attribute[datetime]'>` and `<class '_NotSetType'>`
+ github/CopilotSeat.py:60:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Attribute[str]'>` and `<class '_NotSetType'>`
+ github/CopilotSeat.py:61:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Attribute[datetime]'>` and `<class '_NotSetType'>`
+ github/DependabotAlert.py:64:39: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/DependabotAlert.py:65:39: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/DependabotAlert.py:66:44: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/DependabotAlert.py:67:43: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/DependabotAlertVulnerability.py:50:51: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/Deployment.py:81:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/Deployment.py:96:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/DiscussionBase.py:59:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `None`
+ github/DiscussionCommentBase.py:59:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `None`
+ github/EnvironmentProtectionRuleReviewer.py:65:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Team'>`
+ github/GitReleaseAsset.py:73:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/GithubApp.py:88:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/Installation.py:106:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/Invitation.py:77:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/Invitation.py:78:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/Issue.py:132:45: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/Issue.py:133:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `None`
+ github/Issue.py:162:39: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/IssueComment.py:95:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/IssueEvent.py:83:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/IssueEvent.py:84:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/IssueEvent.py:85:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/IssueEvent.py:101:45: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/IssueEvent.py:103:43: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/Migration.py:94:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/NamedUser.py:107:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/NamedUser.py:108:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/NamedUser.py:111:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/NamedUser.py:116:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/NamedUser.py:123:38: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/NamedUser.py:124:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'bool'>` and `None`
+ github/NamedUser.py:130:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/NamedUser.py:150:39: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/NamedUser.py:154:43: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/Organization.py:189:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/OrganizationCustomProperty.py:90:40: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'list[str]'>`
+ github/PaginatedList.py:206:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ github/Project.py:83:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/PublicKey.py:82:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'int'>`
+ github/PullRequest.py:168:36: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/PullRequest.py:188:36: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/PullRequest.py:203:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
- github/Repository.py:381:84: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ github/RepositoryDiscussion.py:65:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'RepositoryDiscussionComment'>` and `None`
+ github/RepositoryPreferences.py:66:63: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'bool'>` and `<class 'int'>`
+ github/Requester.py:431:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'HTTPRequestsConnectionClass'>` and `<class 'HTTPSRequestsConnectionClass'>`
+ github/Requester.py:433:42: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'HTTPRequestsConnectionClass'>` and `<class 'HTTPSRequestsConnectionClass'>`
- github/Requester.py:1411:52: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ github/SecretScanAlert.py:60:65: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/SecretScanAlert.py:61:66: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/SecretScanAlert.py:62:66: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `None`
+ github/SecretScanAlert.py:63:74: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/SecretScanAlert.py:65:54: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/SecretScanAlert.py:66:54: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `None`
+ github/SecretScanAlert.py:67:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/SecretScanAlert.py:68:45: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ github/SecretScanAlert.py:69:38: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'datetime'>` and `None`
+ github/SecretScanAlert.py:70:38: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `None`
+ github/SelfHostedActionsRunner.py:64:48: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `<class 'str'>`
+ github/StatsContributor.py:109:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'NamedUser'>` and `<class 'Organization'>`
+ github/WorkflowJob.py:53:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ tests/Framework.py:383:40: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'float'>` and `None`
+ tests/Framework.py:384:38: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'float'>` and `None`
+ tests/Framework.py:388:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
- Found 326 diagnostics
+ Found 410 diagnostics

nox (https://github.com/wntrblm/nox)
+ nox/manifest.py:74:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ nox/sessions.py:995:20: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'ProcessEnv'>` and `None`
+ nox/sessions.py:997:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Result'>` and `None`
+ nox/virtualenv.py:590:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `None` and `<class 'str'>`
- Found 23 diagnostics
+ Found 27 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/_internal/_discriminated_union.py:109:36: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ pydantic/_internal/_docs_extraction.py:16:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ pydantic/_internal/_docs_extraction.py:18:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<special-form 'type[AST]'>` and `None`
+ pydantic/_internal/_namespace_utils.py:230:33: error[unsupported-operator] Operator `|` is unsupported between objects of type `<special-form 'type[Any]'>` and `<class 'TypeAliasType'>`
+ pydantic/_internal/_repr.py:18:42: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ pydantic/_internal/_repr.py:19:42: error[unsupported-operator] Operator `|` is unsupported between objects of type `<special-form 'typing.Any'>` and `<class 'tuple[Any]'>`
- 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 `dict[str, int | float | str | ... omitted 3 union elements] | dict[Never, Never] | (((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 `dict[str, Divergent] | dict[Never, Never] | (((dict[str, Divergent], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`
- Found 3186 diagnostics
+ Found 3192 diagnostics

optuna (https://github.com/optuna/optuna)
+ optuna/_imports.py:27:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'tuple[Exception, str]'>` and `None`
+ optuna/importance/_fanova/_fanova.py:49:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[_FanovaTree]'>` and `None`
+ optuna/importance/_fanova/_fanova.py:50:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'dict[int, ndarray[Unknown, dtype[Any]]]'>` and `None`
+ optuna/importance/_fanova/_fanova.py:51:42: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[ndarray[Unknown, dtype[Any]]]'>` and `None`
+ optuna/pruners/_hyperband.py:162:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ optuna/pruners/_successive_halving.py:158:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ optuna/samplers/_gp/sampler.py:197:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[GPRegressor]'>` and `None`
+ optuna/samplers/_gp/sampler.py:198:44: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[GPRegressor]'>` and `None`
+ optuna/samplers/_lazy_random_state.py:15:20: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'RandomState'>` and `None`
+ optuna/samplers/_qmc.py:164:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'dict[str, BaseDistribution]'>` and `None`
+ optuna/samplers/_tpe/sampler.py:353:46: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class '_GroupDecomposedSearchSpace'>` and `None`
+ optuna/samplers/_tpe/sampler.py:354:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class '_SearchSpaceGroup'>` and `None`
+ optuna/search_space/group_decomposed.py:43:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ optuna/search_space/intersection.py:79:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'dict[str, BaseDistribution]'>` and `None`
+ optuna/search_space/intersection.py:80:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ optuna/storages/_cached_storage.py:32:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[StudyDirection]'>` and `None`
+ optuna/storages/_cached_storage.py:33:20: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ optuna/storages/_heartbeat.py:109:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Thread'>` and `None`
+ optuna/storages/_heartbeat.py:110:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Event'>` and `None`
+ optuna/storages/_in_memory.py:424:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ optuna/terminator/median_erroreval.py:62:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'float'>` and `None`
+ optuna/testing/storages.py:85:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'IO[Any]'>` and `None`
+ optuna/testing/storages.py:87:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Thread'>` and `None`
+ optuna/testing/storages.py:88:21: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'GrpcStorageProxy'>` and `None`
+ optuna/testing/storages.py:89:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'BaseStorage'>` and `None`
+ optuna/testing/storages.py:90:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'BaseStorage'>` and `None`
+ optuna/testing/tempfile_pool.py:25:21: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'IO[bytes]'>` and `<class 'IO[str]'>`
+ optuna/testing/threading.py:11:19: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'BaseException'>` and `None`
+ optuna/trial/_frozen.py:158:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[int | float]'>` and `None`
+ optuna/trial/_trial.py:62:37: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'dict[str, BaseDistribution]'>` and `None`
+ optuna/trial/_trial.py:63:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'dict[str, Any]'>` and `None`
+ tests/storages_tests/journal_tests/test_journal.py:46:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'IO[Any]'>` and `None`
- Found 607 diagnostics
+ Found 639 diagnostics

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/domains/c/_ast.py:31:5: error[unsupported-operator] Operator `|` is unsupported between objects of type `Literal["ASTStruct"]` and `Literal["ASTUnion"]`
- Found 405 diagnostics
+ Found 406 diagnostics

mkdocs (https://github.com/mkdocs/mkdocs)
+ mkdocs/config/config_options.py:698:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ mkdocs/config/config_options.py:1053:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Config'>` and `None`
+ mkdocs/contrib/search/search_index.py:176:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'ContentSection'>` and `None`
+ mkdocs/livereload/__init__.py:120:45: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'bytes'>` and `None`
+ mkdocs/structure/pages.py:57:34: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
- Found 220 diagnostics
+ Found 225 diagnostics

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ pymongo/asynchronous/mongo_client.py:773:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'float'>` and `None`
+ pymongo/asynchronous/mongo_client.py:775:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class '_EventListeners'>` and `None`
+ pymongo/asynchronous/topology.py:114:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Queue[Any]'>` and `None`
+ pymongo/synchronous/mongo_client.py:773:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'float'>` and `None`
+ pymongo/synchronous/mongo_client.py:775:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class '_EventListeners'>` and `None`
+ pymongo/synchronous/topology.py:114:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Queue[Any]'>` and `None`
- Found 430 diagnostics
+ Found 436 diagnostics

setuptools (https://github.com/pypa/setuptools)
+ setuptools/_distutils/command/install.py:251:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/command/install.py:252:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/command/install.py:253:20: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/command/install.py:261:20: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/command/install.py:270:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/compilers/C/base.py:139:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:192:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'list[str]'>`
+ setuptools/_distutils/dist.py:197:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'PathLike[str]'>`
+ setuptools/_distutils/dist.py:198:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[str]'>` and `None`
+ setuptools/_distutils/dist.py:1142:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1143:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1144:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1145:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1146:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1147:36: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1148:23: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1149:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1150:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1151:36: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1152:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'list[str]'>`
+ setuptools/_distutils/dist.py:1153:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'list[str]'>`
+ setuptools/_distutils/dist.py:1154:31: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'list[str]'>`
+ setuptools/_distutils/dist.py:1155:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_distutils/dist.py:1157:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'list[str]'>`
+ setuptools/_distutils/dist.py:1158:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'list[str]'>`
+ setuptools/_distutils/dist.py:1159:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'list[str]'>`
+ setuptools/_distutils/filelist.py:39:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Iterable[str]'>` and `None`
+ setuptools/_vendor/packaging/_tokenizer.py:106:26: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Token'>` and `None`
+ setuptools/_vendor/packaging/requirements.py:41:19: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_vendor/packaging/requirements.py:44:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Marker'>` and `None`
+ setuptools/_vendor/packaging/specifiers.py:269:29: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'tuple[str, Version]'>` and `None`
+ setuptools/_vendor/wheel/_bdist_wheel.py:251:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_vendor/wheel/_bdist_wheel.py:255:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_vendor/wheel/_bdist_wheel.py:257:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'bool'>` and `None`
+ setuptools/_vendor/wheel/_bdist_wheel.py:263:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'int'>`
+ setuptools/_vendor/wheel/_bdist_wheel.py:265:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/_vendor/wheel/_bdist_wheel.py:266:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<special-form 'Literal[False]'>`
+ setuptools/_vendor/wheel/wheelfile.py:82:38: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'tuple[None, None]'>` and `<class 'tuple[int, bytes]'>`
+ setuptools/command/bdist_wheel.py:209:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/command/bdist_wheel.py:211:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/command/bdist_wheel.py:212:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/command/bdist_wheel.py:215:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/command/bdist_wheel.py:217:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/command/bdist_wheel.py:218:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'bool'>` and `None`
+ setuptools/command/bdist_wheel.py:224:27: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<class 'int'>`
+ setuptools/command/bdist_wheel.py:226:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/command/bdist_wheel.py:227:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `<special-form 'Literal[False]'>`
+ setuptools/config/expand.py:438:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Mapping[_K@LazyMappingProxy, _V_co@LazyMappingProxy]'>` and `None`
+ setuptools/dist.py:309:36: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'bool'>` and `None`
+ setuptools/dist.py:310:36: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'dict[str, list[str]]'>` and `None`
+ setuptools/dist.py:312:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ setuptools/tests/integration/helpers.py:44:24: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'TarFile'>` and `<class 'ZipFile'>`
- Found 1123 diagnostics
+ Found 1175 diagnostics

strawberry (https://github.com/strawberry-graphql/strawberry)
- strawberry/federation/schema.py:162:37: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 332 diagnostics
+ Found 331 diagnostics

xarray (https://github.com/pydata/xarray)
+ xarray/core/dataarray.py:126:52: error[unsupported-operator] Operator `|` is unsupported between objects of type `Literal["DataArray"]` and `<class 'Dataset'>`
- Found 1711 diagnostics
+ Found 1712 diagnostics

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/build/wheel.py:99:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
+ src/scikit_build_core/hatch/plugin.py:41:25: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Path'>` and `None`
+ src/scikit_build_core/resources/_editable_redirect.py:30:28: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
- Found 59 diagnostics
+ Found 62 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ .gitlab/validate-ddtrace-package.py:60:79: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ .gitlab/validate-ddtrace-package.py:141:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ ddtrace/errortracking/_handled_exceptions/bytecode_reporting.py:104:12: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'HandledExceptionReportingInjector'>` and `None`
+ ddtrace/errortracking/_handled_exceptions/callbacks.py:30:51: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'tuple[Exception, Span, SpanEvent]'>` and `None`
+ ddtrace/errortracking/_handled_exceptions/monitoring_reporting.py:21:58: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ ddtrace/profiling/collector/pytorch.py:38:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Tracer'>` and `None`
+ ddtrace/profiling/profiler.py:133:32: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Collector'>` and `<class 'MemoryCollector'>`
+ scripts/check-dependency-ci-coverage.py:75:19: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'int'>` and `None`
+ scripts/check-dependency-ci-coverage.py:99:46: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Version'>` and `None`
+ tests/appsec/integrations/fastapi_tests/test_fastapi_appsec_iast.py:600:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ tests/appsec/integrations/fastapi_tests/test_fastapi_appsec_iast.py:601:16: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'float'>` and `None`
+ tests/appsec/integrations/fastapi_tests/test_fastapi_appsec_iast.py:602:14: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'float'>` and `None`
+ tests/appsec/integrations/pygoat_tests/test_pygoat.py:65:83: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
+ tests/appsec/integrations/pygoat_tests/test_pygoat.py:65:103: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
- Found 9273 diagnostics
+ Found 9287 diagnostics

altair (https://github.com/vega/altair)
+ altair/datasets/_data.py:258:30: error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'list[LiteralString]'>` and `None`
+ altair/datasets/_data.py:258:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<special-form 'Literal["airports", "annual_precip", "anscombe", "barley", "birdstrikes", ... omitted 68 literals]'>` and `<special-form 'typing.LiteralString'>`
+ altair/datasets/_data.py:258:35: error[unsupported-operator] Operator `|` is unsupported between objects of type `<special-form 'Literal["airports", "annual_precip", "anscombe", "barley", "birdstrikes", ... omitted 68 literals]'>` and `<special-form 'typing.LiteralString'>`
+ altair/utils/execeval.py:21:22: error[unsupported-operator] Operator `|` is unsupported between objects of type `<special-form 'typing.Any'>` and `None`
- Found 1070 diagnostics
+ Found 1074 diagnostics

core (https://github.com/home-assistant/core)
+ homeassistant/components/powerfox/coordinator.py:27:5: error[unsupported-operator] Operator `|` is unsupported between objects of type `Literal["PowerfoxDataUpdateCoordinator"]` and `Literal["PowerfoxReportDataUpdateCoordinator"]`
- Found 12083 diagnostics
+ Found 12084 diagnostics

@AlexWaygood AlexWaygood force-pushed the alex/type-expression-quotes branch 3 times, most recently from 82402fc to 46cd0f0 Compare February 15, 2026 17:07
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 15, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
unsupported-operator 286 0 0
invalid-await 40 0 0
unused-type-ignore-comment 0 3 0
invalid-return-type 1 0 0
Total 327 3 0

Full report with detailed diff (timing results)

@AlexWaygood

This comment was marked as resolved.

@AlexWaygood AlexWaygood marked this pull request as ready for review February 15, 2026 17:23
@AlexWaygood AlexWaygood changed the title [ty] Detect invalid partially stringified PEP-604 unions [ty] Detect (some) invalid partially stringified PEP-604 unions Feb 15, 2026
@AlexWaygood AlexWaygood force-pushed the alex/type-expression-quotes branch 2 times, most recently from 32606e9 to 65e68c5 Compare February 15, 2026 22:38
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Nice!

@carljm
Copy link
Contributor

carljm commented Feb 16, 2026

Oh, Codex found a regression here that we should add a test for and fix before landing; this PR wrongly emits a diagnostic on this:

def f(x: "int | 'Foo'"): ...

Fix is to skip the diagnostic if self.deferred_state.in_string_annotation().

Comment on lines +166 to +168
| Self::Unknown
| Self::AlwaysTruthy
| Self::AlwaysFalsy
Copy link
Member Author

Choose a reason for hiding this comment

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

it's necessary to change the fallback types of these special forms now, or we start complaining that they can't be used in | unions on Python <3.14

@carljm carljm self-requested a review February 16, 2026 07:36
@carljm carljm self-assigned this Feb 16, 2026
@AlexWaygood AlexWaygood marked this pull request as draft February 16, 2026 14:19
@AlexWaygood AlexWaygood changed the title [ty] Detect (some) invalid partially stringified PEP-604 unions [ty] Detect invalid partially stringified PEP-604 unions Feb 16, 2026
@sharkdp sharkdp removed their request for review February 17, 2026 08:10
@AlexWaygood AlexWaygood force-pushed the alex/type-expression-quotes branch 2 times, most recently from 05cfb07 to 38f53e9 Compare February 20, 2026 19:25
@AlexWaygood AlexWaygood force-pushed the alex/type-expression-quotes branch 2 times, most recently from 4fb14d6 to c23ef35 Compare February 24, 2026 18:42
@AlexWaygood AlexWaygood force-pushed the alex/type-expression-quotes branch from c23ef35 to 288f4c8 Compare February 26, 2026 11:03
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Nice! Sorry for the delayed review.

x: int

class Meta(type):
def __or__(cls, other: str) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an invalid override of type.__or__; not sure why we don't catch it?

The invalid override part is the return type, which doesn't seem essential to this test.

In fact I don't even think defining __or__ here is necessary to the test, since type.__or__ accepts Any for its argument. But maybe the test is clearer with it.

Copy link
Member Author

@AlexWaygood AlexWaygood Mar 4, 2026

Choose a reason for hiding this comment

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

This is an invalid override of type.__or__; not sure why we don't catch it?

hmmm... it's something to do with the | _typeshed.Self union in the return type of type.__or__. _typeshed.Self is just a common-or-garden TypeVar; I can repro with just this:

from typing import TypeVar

T = TypeVar("T")

class Foo1:
    def method(self: T) -> T:
        return self

class Foo2(Foo1):
    def method(self) -> str:
        return ""

Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect it's due to the fact that we check the types of methods as accessed on instances when doing Liskov checks

Copy link
Member Author

Choose a reason for hiding this comment

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

But for now I changed the return annotation in this test

Comment on lines +162 to +165
self.infer_expression(&binary.left, TypeContext::default())
};
let right_type_value =
self.infer_expression(&binary.right, TypeContext::default());
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think there is a problem here if there are other diagnostics that will show up either in type-expression or value-expression inference, for example an undefined name; we now get those diagnostics twice. For example in def f(x: int | Foo): ... if Foo is undefined, we now get duplicate diagnostics.

This seems a bit nettlesome to fix. It might require adding a no-diagnostics mode to TypeInferenceBuilder?

Copy link
Member Author

Choose a reason for hiding this comment

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

This seems a bit nettlesome to fix. It might require adding a no-diagnostics mode to TypeInferenceBuilder?

Not that nettlesome at all! Ibraheem already added it for his previous multi-inference shenanigans; it turns out we already had all the infrastructure we needed to easily fix this.

@carljm
Copy link
Contributor

carljm commented Mar 3, 2026

I think we could consider going back to your first implementation here instead of fixing my latest comment? :/ Just not sure how much extra work it's worth to do better here.

@AlexWaygood AlexWaygood marked this pull request as draft March 4, 2026 21:51
@AlexWaygood AlexWaygood marked this pull request as ready for review March 5, 2026 14:47
@astral-sh-bot astral-sh-bot bot requested a review from carljm March 5, 2026 14:47
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Nice!

let right_ty = self.infer_type_expression(&binary.right);

// Detect runtime errors from e.g. `int | "bytes"` on Python <3.14 without `__future__` annotations.
if !self.deferred_state.is_deferred() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have an exemption here for if TYPE_CHECKING: blocks?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I can add that. Though there's really no reason ever to have partially stringized PEP-604 unions in your code; it's just an antipattern, especially in regions that don't require any stringized annotations at all (because they will never even be executed at runtime).

But you're right that we may as well avoid false positives here.

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.

2 participants