You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The return annotation is guaranteed to be a name,
// as verified by `uses_custom_var()`.
let typevar_name = returns.as_name_expr().unwrap().id();
And the reason is that, contrary to what the comment says, uses_custom_typevar does not guarantee that the return Expr will be an ExprName, due to the map_subscript call here:
We should switch to a more type-safe code pattern here. Note that although the panic occurs in autofix logic, the panic occurs even if you run Ruff without --fix, since we create fixes for diagnostics even if --fix is not specified.
The text was updated successfully, but these errors were encountered:
Description
Running
ruff check --select=PYI019 --preview foo.pyi
triggers a panic iffoo.pyi
has this contents:The panic occurs at this line here:
ruff/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs
Lines 295 to 297 in 59be5f5
And the reason is that, contrary to what the comment says,
uses_custom_typevar
does not guarantee that the returnExpr
will be anExprName
, due to themap_subscript
call here:ruff/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs
Lines 187 to 189 in 59be5f5
(The
map_subscript
call also looks buggy, FWIW.)We should switch to a more type-safe code pattern here. Note that although the panic occurs in autofix logic, the panic occurs even if you run Ruff without
--fix
, since we create fixes for diagnostics even if--fix
is not specified.The text was updated successfully, but these errors were encountered: