Skip to content

Conversation

@tyralla
Copy link
Collaborator

@tyralla tyralla commented Dec 29, 2025

Fixes #19256
(and removes some to-do comments)

We implemented all the logic in previous PRs for loops and finally clauses. This PR just activates the available features for functions (for performance reasons, only if there are at least two expansions).

I decided against grouping separate responses to revealed_type for individual expansions into unions, which would be more confusing than helpful in my opinion, and so also added the IterationErrorWatcher.collect_revealed_types option.

…ability.

Fixes python#19256
(and removes some to-do comments)

We implemented all the logic in previous PRs for loops and finally clauses.  This PR just activates the available features for functions (for performance reasons, only if there are at least two expansions).

I decided against grouping separate responses to `revealed_type` for individual expansions into unions, which would be more confusing than helpful in my opinion, and so also added the `IterationErrorWatcher.collect_revealed_types` option.
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

hydpy (https://github.com/hydpy-dev/hydpy)
+ hydpy/exe/xmltools.py:1852: error: Unused "type: ignore" comment  [unused-ignore]
+ hydpy/exe/xmltools.py:1855: error: Unused "type: ignore" comment  [unused-ignore]

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/utilities/templating.py:230: error: Redundant cast to "list[Any]"  [redundant-cast]

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/http_parser.py:277:20: error: Non-overlapping equality check (left operand type: "bytes", right operand type: "Literal['\r\n']")  [comparison-overlap]
+ aiohttp/http_parser.py:277:20: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-comparison-overlap for more info

altair (https://github.com/vega/altair)
- altair/vegalite/v6/api.py:1181: error: Redundant cast to "_Conditional[list[_ConditionClosed]]"  [redundant-cast]

operator (https://github.com/canonical/operator)
- ops/pebble.py:1854: error: Redundant cast to "str"  [redundant-cast]
- ops/pebble.py:1855: error: Redundant cast to "str"  [redundant-cast]

rotki (https://github.com/rotki/rotki)
+ rotkehlchen/chain/mixins/rpc_nodes.py:129: error: Right operand of "and" is never evaluated  [unreachable]

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/node_iter.py:130: error: Statement is unreachable  [unreachable]
+ static_frame/core/node_iter.py:167: error: Statement is unreachable  [unreachable]
+ static_frame/core/node_iter.py:349: error: Subclass of "Frame[Any, Any, *tuple[Any, ...]]" and "Bus[Any]" cannot exist: have distinct disjoint bases  [unreachable]
+ static_frame/core/node_iter.py:349: error: Subclass of "Series[Any, Any]" and "Bus[Any]" cannot exist: have distinct disjoint bases  [unreachable]
+ static_frame/core/node_iter.py:349: error: Subclass of "Frame[Any, Any, *tuple[Any, ...]]" and "Yarn[Any]" cannot exist: have distinct disjoint bases  [unreachable]
+ static_frame/core/node_iter.py:349: error: Subclass of "Series[Any, Any]" and "Yarn[Any]" cannot exist: have distinct disjoint bases  [unreachable]
+ static_frame/core/node_iter.py:353: error: Statement is unreachable  [unreachable]

xarray (https://github.com/pydata/xarray)
+ xarray/core/dtypes.py:74: error: Unused "type: ignore" comment  [unused-ignore]
+ xarray/core/groupby.py:1046: error: Unused "type: ignore" comment  [unused-ignore]

@tyralla
Copy link
Collaborator Author

tyralla commented Dec 29, 2025

As far as I can tell, nearly all of the primer results are improvements. The one I am most uncertain of is the one concerning rotkehlchen. I think this is a false positive triggered by the Walrus operator somehow.

Performance measurements:

master                    13.180s (0.0%) | stdev 3.164s
feature/unreachable_type_var_constraints 12.619s (-4.3%) | stdev 3.167s
Total time taken by the whole benchmarking program (including any setup): 17 minutes, 20 seconds

master                    7.683s (0.0%) | stdev 0.189s
feature/unreachable_type_var_constraints 7.779s (+1.2%) | stdev 0.255s
Total time taken by the whole benchmarking program (including any setup): 10 minutes, 59 seconds

master                    8.048s (0.0%) | stdev 0.184s
feature/unreachable_type_var_constraints 8.084s (+0.5%) | stdev 0.208s
Total time taken by the whole benchmarking program (including any setup): 13 minutes, 47 seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unreachability should work for constrained type vars

1 participant