[ty] Add a new assert-type-unspellable-subtype diagnostic#22815
[ty] Add a new assert-type-unspellable-subtype diagnostic#22815AlexWaygood merged 1 commit intomainfrom
assert-type-unspellable-subtype diagnostic#22815Conversation
Typing conformance results improved 🎉The percentage of diagnostics emitted that were expected errors increased from 77.33% to 78.71%. The percentage of expected errors that received a diagnostic held steady at 69.23%. Summary
False positives removedDetails
|
|
2ffecd3 to
93c0c4b
Compare
|
(I do think that the ideal state is to get the typing conformance suite to a place where it uses fewer |
This comment was marked as off-topic.
This comment was marked as off-topic.
| pub(crate) static ASSERT_TYPE_UNSPELLABLE_SUBTYPE = { | ||
| summary: "detects failed type assertions", | ||
| status: LintStatus::stable("0.0.14"), | ||
| default_level: Level::Error, |
There was a problem hiding this comment.
Should this be a warning by default, given that this is only a suspicious pattern?
There was a problem hiding this comment.
I think it should still be an error — the assertion is still failing. The spec says that assert_type should only pass if the two types are equivalent, and we only emit this error if the two types are not equivalent
93c0c4b to
67b2237
Compare
|
I feel confident that splitting this into two error codes is an improvement. I'm less confident that it's appropriate to ignore the new error code when we run the conformance script (or if it'll be okay to publish results upstream with the new error code ignored). But that part is easy to revert/revisit later; it's just a one-line change to the Python script. |
* 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) ...
Fixes astral-sh/ty#1762. If a type assertion fails, but the actual type is an unspellable subtype of the asserted type, we now emit
assert-type-unspellable-subtyperather thantype-assertion-failure. We also ignore this error inscripts/conformance.py. This results in 17 fewer false positives on the conformance suite, and it's also something that our users have asked for.