Skip to content

Conversation

@carljm
Copy link
Contributor

@carljm carljm commented Jun 6, 2025

Just a quick review-comment follow-up.

@carljm carljm requested a review from AlexWaygood as a code owner June 6, 2025 01:24
@carljm carljm added the ty Multi-file analysis & type inference label Jun 6, 2025
@carljm carljm requested review from dcreager and sharkdp as code owners June 6, 2025 01:24
@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2025

mypy_primer results

No ecosystem changes detected ✅

@carljm carljm merged commit cb8246b into main Jun 6, 2025
35 checks passed
@carljm carljm deleted the cjm/remove-unnecessary-either branch June 6, 2025 01:39
@AlexWaygood
Copy link
Member

It could be even simpler, FWIW...

--- a/crates/ty_python_semantic/src/types/infer.rs
+++ b/crates/ty_python_semantic/src/types/infer.rs
@@ -9021,9 +9021,9 @@ impl<'db> TypeInferenceBuilder<'db, '_> {
     ) -> Type<'db> {
         let arguments = &*subscript_node.slice;
         let (args, args_number) = if let ast::Expr::Tuple(t) = arguments {
-            (t.iter(), t.len())
+            (&*t.elts, t.len())
         } else {
-            (std::slice::from_ref(arguments).iter(), 1)
+            (std::slice::from_ref(arguments), 1)
         };
         if args_number != expected_arg_count {
             if let Some(builder) = self.context.report_lint(&INVALID_TYPE_FORM, subscript_node) {
@@ -9040,8 +9040,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> {
         }
         let ty = class.to_specialized_instance(
             self.db(),
-            args.into_iter()
-                .map(|node| self.infer_type_expression(node)),
+            args.iter().map(|node| self.infer_type_expression(node)),
         );
         if arguments.is_tuple_expr() {
             self.store_expression_type(arguments, ty);

...but I don't think it's worth a followup PR just for this :P

@MichaReiser
Copy link
Member

MichaReiser commented Jun 6, 2025

In which case you could even remove the len because of slice.len ;)

Maybe something for claude

@carljm
Copy link
Contributor Author

carljm commented Jun 7, 2025

PRs are cheap :) #18526

And this is too simple for Claude -- it'd be way more work to explain it to Claude than to just make the change.

@carljm carljm added the internal An internal refactor or improvement label Jun 7, 2025
carljm added a commit that referenced this pull request Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants