Skip to content

Commit eb60bd6

Browse files
authored
[ty] more simplification of infer_parameterized_legacy_typing_alias (#18526)
Address post-land review on #18489
1 parent b21ac56 commit eb60bd6

File tree

1 file changed

+7
-7
lines changed
  • crates/ty_python_semantic/src/types

1 file changed

+7
-7
lines changed

crates/ty_python_semantic/src/types/infer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9108,12 +9108,12 @@ impl<'db> TypeInferenceBuilder<'db, '_> {
91089108
class: KnownClass,
91099109
) -> Type<'db> {
91109110
let arguments = &*subscript_node.slice;
9111-
let (args, args_number) = if let ast::Expr::Tuple(t) = arguments {
9112-
(t.iter(), t.len())
9111+
let args = if let ast::Expr::Tuple(t) = arguments {
9112+
&*t.elts
91139113
} else {
9114-
(std::slice::from_ref(arguments).iter(), 1)
9114+
std::slice::from_ref(arguments)
91159115
};
9116-
if args_number != expected_arg_count {
9116+
if args.len() != expected_arg_count {
91179117
if let Some(builder) = self.context.report_lint(&INVALID_TYPE_FORM, subscript_node) {
91189118
let noun = if expected_arg_count == 1 {
91199119
"argument"
@@ -9122,14 +9122,14 @@ impl<'db> TypeInferenceBuilder<'db, '_> {
91229122
};
91239123
builder.into_diagnostic(format_args!(
91249124
"Legacy alias `{alias}` expected exactly {expected_arg_count} {noun}, \
9125-
got {args_number}",
9125+
got {}",
9126+
args.len()
91269127
));
91279128
}
91289129
}
91299130
let ty = class.to_specialized_instance(
91309131
self.db(),
9131-
args.into_iter()
9132-
.map(|node| self.infer_type_expression(node)),
9132+
args.iter().map(|node| self.infer_type_expression(node)),
91339133
);
91349134
if arguments.is_tuple_expr() {
91359135
self.store_expression_type(arguments, ty);

0 commit comments

Comments
 (0)