[ty] Fix type checking for multi-member enums within in a function block#23683
[ty] Fix type checking for multi-member enums within in a function block#23683carljm merged 4 commits intoastral-sh:mainfrom
Conversation
Typing conformance results regressed ❌The percentage of diagnostics emitted that were expected errors decreased from 85.94% to 85.92%. The percentage of expected errors that received a diagnostic decreased from 78.17% to 78.13%. Summary
Optional Diagnostics RemovedDetails
|
|
Memory usage reportMemory usage unchanged ✅ |
|
In this case the conformance suite "regressions" reported by our script are both actually good news :-) They're marked as "optional errors" in the upstream conformance suite because the spec does not mandate that type checkers have to infer precise Literal types on those lines — it's permitted for the assertions to fail. But if the assertions pass (and the optional errors are therefore not emitted), that's even better! |
|
@AlexWaygood Thanks for checking on that, I had moved this back to draft so I could look into it. Everything seems fine to me, so I'll mark it as ready again. |
carljm
left a comment
There was a problem hiding this comment.
Thanks! Pushing a few updates I noticed and then will land if CI looks good.
|
|
||
| To do: <https://typing.python.org/en/latest/spec/enums.html#enum-definition> | ||
|
|
||
| ### `value` and `_value_` |
There was a problem hiding this comment.
These tests don't belong under "Function syntax", and partly duplicate existing tests above.
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
2 | 0 | 1 |
unused-type-ignore-comment |
0 | 3 | 0 |
invalid-assignment |
2 | 0 | 0 |
redundant-cast |
1 | 0 | 0 |
type-assertion-failure |
1 | 0 | 0 |
unsupported-operator |
1 | 0 | 0 |
| Total | 7 | 3 | 1 |
* main: [ty] Split up `types/class.rs` (#23714) [ty] Rework module resolution to be breadth-first instead of depth-first (#22449) [ty] Move tests and type-alias-related code out of `types.rs` (#23711) [ty] Move TypeVar-related code to a `types::typevar` submodule (#23710) Fail CI on new linter ecosystem panics (#23597) [ty] Fix handling of non-Python text documents [ty] Move `CallableType`, and related methods/types, to a new `types::callable` submodule (#23707) [ty] Avoid stack overflow with recursive typevar (#23652) [ty] Add a diagnostic for an unused awaitable (#23650) [ty] Fix union `*args` binding for optional positional parameters (#23124) [`refurb`] Fix `FURB101` and `FURB103` false positives when I/O variable is used later (#23542) [ty] Fix type checking for multi-member enums within in a function block (#23683) [ty] Improve folding for decorators (#23543) [`airflow`] Extract common utilities for use in new rules (#23630)
Summary
TypeErrors between an enum member'svalueattribute and the enum itself are silently suppressedwhen inside a function due to resolution as
AnyMinimal example:
Test Plan
crates/ty_python_semantic/resources/mdtest/enums.mdunder the Function Syntax heading