Skip to content

Conversation

jhance
Copy link
Collaborator

@jhance jhance commented Apr 28, 2022

Implements basic inference for TypeVarTuple along with various check tests verifying uses of TypeVarTuple with functions works reasonably.

@@ -1019,13 +1019,22 @@ def check_callable_call(self,
callee.arg_kinds, callee.arg_names,
lambda i: self.accept(args[i]))

print(callee)
print(callee.variables)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove debug prints (here and below).

@@ -694,6 +694,30 @@ def infer_against_overloaded(self, overloaded: Overloaded,

def visit_tuple_type(self, template: TupleType) -> List[Constraint]:
actual = self.actual
print("XX")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More debug prints

mypy/infer.py Outdated
@@ -46,6 +46,8 @@ def infer_function_type_arguments(callee_type: CallableType,
# Infer constraints.
constraints = infer_constraints_for_callable(
callee_type, arg_types, arg_kinds, formal_to_actual, context)
print("constraints")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug prints

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as the next incremental step towards TypeVarTuple support.


reveal_type(g(args, args)) # N: Revealed type is "Tuple[builtins.int, builtins.str]"
reveal_type(g(args, args2)) # N: Revealed type is "Tuple[builtins.int, builtins.str]"
reveal_type(g(args, args3)) # N: Revealed type is "builtins.tuple[builtins.object, ...]"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are against the PEP -- we should not take a join when inferring TypeVarTuples. But we can revisit this later.

@JukkaL JukkaL merged commit d64efcd into python:master Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants