[ty] Add materialization to Divergent type#24255
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 86.61%. The percentage of expected errors that received a diagnostic held steady at 81.56%. The number of fully passing files held steady at 70/132. |
Memory usage reportMemory usage unchanged ✅ |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
40 | 0 | 0 |
index-out-of-bounds |
0 | 1 | 0 |
invalid-assignment |
0 | 1 | 0 |
invalid-return-type |
1 | 0 | 0 |
| Total | 41 | 2 | 0 |
Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.
Raw diff:
rotki (https://github.com/rotki/rotki)
- rotkehlchen/exchanges/coinbase.py:466:40 error[invalid-assignment] Object of type `dict[str, list[dict[Unknown, Unknown]]]` is not assignable to `defaultdict[str, list[dict[Unknown, Unknown]]]`
scipy (https://github.com/scipy/scipy)
- scipy/interpolate/_interpolate.py:2264:56 error[index-out-of-bounds] Index 1 is out of bounds for tuple `tuple[int]` with length 16a610f1 to
85f0d4e
Compare
046d697 to
4cfcae6
Compare
| Type::Dynamic(_) | Type::Divergent(_) => *self, | ||
| Type::Dynamic(_) => *self, | ||
|
|
||
| Type::Divergent(divergent) => match divergent.materialization_kind() { |
There was a problem hiding this comment.
This behavior looks good, but IntersectionBuilder doesn't do the same (it will add a materialized divergent as just a normal negated element). This could break all_negated_types_identical_to_intersection_with_single_negated_element property test (if property tests included Divergent, which they don't currently -- but it might be useful validation of this stack to add both materialized and non-materialized Divergent to the property tests, and run them.) I think IntersectionBuilder should gain some recognition of materialized Divergent to fix this.
| source: Type<'db>, | ||
| target: Type<'db>, | ||
| ) -> ConstraintSet<'db, 'c> { | ||
| if let Some(source) = source.materialized_divergent_fallback() { |
There was a problem hiding this comment.
Are there other places that need similar handling to this? Type::subscript? try_upcast_to_callable_with_policy? Member access?
85f0d4e to
dce8f53
Compare
dce8f53 to
b8334c7
Compare
4cfcae6 to
af77a5c
Compare
Merging this PR will improve performance by 7.47%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | ty_micro[many_enum_members_2] |
172.6 ms | 160.6 ms | +7.47% |
Comparing charlie/divergent-two (9f85c4a) with main (e871de4)
Footnotes
-
60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
af77a5c to
3e9746b
Compare
b8334c7 to
6ebadc8
Compare
3e9746b to
eb89858
Compare
eb89858 to
fb70452
Compare
fb70452 to
9f85c4a
Compare
* main: (35 commits) Store definition indexes as u32 (#24307) Avoid re-using symbol in RUF024 fix (#24316) [ty] Add materialization to `Divergent` type (#24255) [ty] Make `Divergent` a top-level type variant (#24252) [ty] Fix nested global and nonlocal lookups through forwarding scopes (#24279) Fetch the cargo-dist binary directly instead of using the installer (#24258) [ty] Fix panic on `list[Annotated[()]]` (#24303) Don't measure the AST deallocation time in parser benchmarks (#24301) Enable CodSpeed's memory benchmarks for simulation benchmarks (#24298) Upgrade imara-diff to 0.2.0 (#24299) [ty] Represent `InitVar` as a special form internally, not a class (#24248) `RUF067`: Allow dunder-named assignments in non-strict mode [`pyupgrade`] UP018 should detect more unnecessarily wrapped literals (UP018) (#24093) [ty] Remove unused `system.glob` method (#24300) [ty] Reject functional TypedDict with mismatched name (#24295) Update Rust crate arc-swap to v1.9.0 (#24292) [ty] Remove unused `@Todo(Functional TypedDicts)` (#24297) Update CodSpeedHQ/action action to v4.12.1 (#24290) Update taiki-e/install-action action to v2.69.6 (#24293) Update Rust crate toml to v1.0.7 (#24289) ...
Summary
This PR follows #24245 (comment) such that we preserve the top or bottom materialization on
Divergentmaterializing recursive types.