Skip to content

[ty] Fix binary operator false-positive for constrained TypeVars#22782

Merged
charliermarsh merged 1 commit intomainfrom
charlie/con-2
Jan 23, 2026
Merged

[ty] Fix binary operator false-positive for constrained TypeVars#22782
charliermarsh merged 1 commit intomainfrom
charlie/con-2

Conversation

@charliermarsh
Copy link
Member

Summary

Closes astral-sh/ty#1972.

@charliermarsh charliermarsh added bug Something isn't working ty Multi-file analysis & type inference labels Jan 21, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 21, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 21, 2026

mypy_primer results

Changes were detected when running on open source projects
pyodide (https://github.com/pyodide/pyodide)
- src/tests/test_static_typing.py:56:20: error[unsupported-operator] Operator `*` is not supported between objects of type `T@f` and `Literal[2]`
- Found 940 diagnostics
+ Found 939 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/deployments/runner.py:997:70: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | ((...) -> Any)`
+ src/prefect/deployments/runner.py:997:70: warning[possibly-missing-attribute] Attribute `__name__` may be missing on object of type `Unknown | (((...) -> Any) & ((*args: object, **kwargs: object) -> object))`
- src/prefect/flow_engine.py:989:32: error[invalid-await] `Unknown | R@FlowRunEngine | Coroutine[Any, Any, R@FlowRunEngine]` is not awaitable
- src/prefect/flow_engine.py:1580:24: error[invalid-await] `Unknown | R@AsyncFlowRunEngine | Coroutine[Any, Any, R@AsyncFlowRunEngine]` is not awaitable
- src/prefect/flow_engine.py:1661:43: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Unknown | R@run_generator_flow_sync`
- src/prefect/flow_engine.py:1669:21: warning[possibly-missing-attribute] Attribute `throw` may be missing on object of type `Unknown | R@run_generator_flow_sync`
- src/prefect/flow_engine.py:1703:44: warning[possibly-missing-attribute] Attribute `__anext__` may be missing on object of type `Unknown | R@run_generator_flow_async`
- src/prefect/flow_engine.py:1710:25: warning[possibly-missing-attribute] Attribute `throw` may be missing on object of type `Unknown | R@run_generator_flow_async`
- src/prefect/flows.py:286:34: error[unresolved-attribute] Object of type `(**P@Flow) -> R@Flow` has no attribute `__name__`
+ src/prefect/flows.py:286:34: error[unresolved-attribute] Object of type `((**P@Flow) -> R@Flow) & ((*args: object, **kwargs: object) -> object)` has no attribute `__name__`
- src/prefect/flows.py:404:68: error[unresolved-attribute] Object of type `(**P@Flow) -> R@Flow` has no attribute `__name__`
+ src/prefect/flows.py:404:68: error[unresolved-attribute] Object of type `((**P@Flow) -> R@Flow) & ((*args: object, **kwargs: object) -> object)` has no attribute `__name__`
- src/prefect/flows.py:1809:21: error[no-matching-overload] No overload of function `run_coro_as_sync` matches arguments
+ src/prefect/flows.py:1749:53: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 5352 diagnostics
+ Found 5346 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
- Found 47 diagnostics
+ Found 46 diagnostics

hydpy (https://github.com/hydpy-dev/hydpy)
+ hydpy/core/parametertools.py:1540:20: error[invalid-return-type] Return type does not match returned value: expected `ArrayFloat@apply_timefactor`, found `int | float | ndarray[tuple[Any, ...], Unknown] | ArrayFloat@apply_timefactor`
+ hydpy/core/parametertools.py:1571:20: error[invalid-return-type] Return type does not match returned value: expected `ArrayFloat@revert_timefactor`, found `int | float | ndarray[tuple[Any, ...], Unknown] | ArrayFloat@revert_timefactor`
- hydpy/core/parametertools.py:1540:20: error[unsupported-operator] Operator `*` is not supported between objects of type `ArrayFloat@apply_timefactor` and `int | float`
- hydpy/core/parametertools.py:1542:20: error[unsupported-operator] Operator `/` is not supported between objects of type `ArrayFloat@apply_timefactor` and `int | float`
- hydpy/core/parametertools.py:1569:20: error[unsupported-operator] Operator `/` is not supported between objects of type `ArrayFloat@revert_timefactor` and `int | float`
- hydpy/core/parametertools.py:1571:20: error[unsupported-operator] Operator `*` is not supported between objects of type `ArrayFloat@revert_timefactor` and `int | float`
- Found 663 diagnostics
+ Found 661 diagnostics

rotki (https://github.com/rotki/rotki)
- rotkehlchen/chain/decoding/tools.py:96:44: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- rotkehlchen/chain/decoding/tools.py:99:13: error[invalid-argument-type] Argument to function `decode_transfer_direction` is incorrect: Expected `Sequence[A@BaseDecoderTools]`, found `Unknown | tuple[BTCAddress, ...] | tuple[ChecksumAddress, ...] | tuple[SubstrateAddress, ...] | tuple[SolanaAddress, ...]`
- rotkehlchen/chain/decoding/tools.py:100:62: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+ rotkehlchen/chain/decoding/tools.py:97:13: error[invalid-argument-type] Argument to function `decode_transfer_direction` is incorrect: Expected `BTCAddress | ChecksumAddress | SubstrateAddress | SolanaAddress`, found `A@BaseDecoderTools`
+ rotkehlchen/chain/decoding/tools.py:98:13: error[invalid-argument-type] Argument to function `decode_transfer_direction` is incorrect: Expected `BTCAddress | ChecksumAddress | SubstrateAddress | SolanaAddress | None`, found `A@BaseDecoderTools | None`
- Found 2052 diagnostics
+ Found 2051 diagnostics

No memory usage changes detected ✅

@charliermarsh charliermarsh changed the title [ty] Fix false-positive unsupported-operator for constrained TypeVars [ty] Fix binary operator false positive for constrained TypeVars Jan 21, 2026
@charliermarsh charliermarsh changed the title [ty] Fix binary operator false positive for constrained TypeVars [ty] Fix binary operator false-positive for constrained TypeVars Jan 21, 2026
@charliermarsh charliermarsh changed the base branch from main to charlie/con January 21, 2026 03:20
@charliermarsh charliermarsh marked this pull request as ready for review January 23, 2026 18:49
@charliermarsh charliermarsh force-pushed the charlie/con branch 3 times, most recently from a34725c to 0da8299 Compare January 23, 2026 20:18
Base automatically changed from charlie/con to main January 23, 2026 20:23
@charliermarsh charliermarsh enabled auto-merge (squash) January 23, 2026 20:27
@charliermarsh charliermarsh merged commit 4418e17 into main Jan 23, 2026
48 checks passed
@AlexWaygood AlexWaygood removed their request for review January 23, 2026 20:31
@charliermarsh charliermarsh deleted the charlie/con-2 branch January 23, 2026 20:31
charliermarsh added a commit that referenced this pull request Jan 23, 2026
carljm added a commit that referenced this pull request Jan 30, 2026
* main: (62 commits)
  [`refurb`] Do not add `abc.ABC` if already present (`FURB180`) (#22234)
  [ty] Add a new `assert-type-unspellable-subtype` diagnostic (#22815)
  [ty] Avoid duplicate syntax errors for `await` outside functions (#22826)
  [ty] Fix unary operator false-positive for constrained TypeVars (#22783)
  [ty] Fix binary operator false-positive for constrained TypeVars (#22782)
  [ty] Fix false-positive `unsupported-operator` for "symmetric" TypeVars (#22756)
  [`pydocstyle`] Clarify which quote styles are allowed (`D300`) (#22825)
  [ty] Use distributed versions of AND and OR on constraint sets (#22614)
  [ty] Add support for dict literals and dict() calls as default values for parameters with TypedDict types (#22161)
  Document `-` stdin convention in CLI help text (#22817)
  [ty] Make `infer_subscript_expression_types` a method on `Type` (#22731)
  [ty] Simplify `OverloadLiteral::spans` and `OverloadLiteral::parameter_span` (#22823)
  [ty] Require both `*args` and `**kwargs` when calling a `ParamSpec` callable (#22820)
  [ty] Handle tagged errors in conformance (#22746)
  Add `--color` cli option to force colored output (#22806)
  Identify notebooks by LSP didOpen instead of `.ipynb` file extension (#22810)
  [ty] Fix docstring rendering for literal blocks after doctests (#22676)
  [ty] Update salsa to fix out-of-order query validation (#22498)
  [ty] Inline cycle initial and recovery functions (#22814)
  [ty] Pass the generic context through the decorator (#22544)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False-positive unsupported-operator errors for value-constrained type variable

2 participants