-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Implement basic typevartuple constraints/inference #12688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mypy/checkexpr.py
Outdated
@@ -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) |
There was a problem hiding this comment.
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).
mypy/constraints.py
Outdated
@@ -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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug prints
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
There was a problem hiding this 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, ...]" |
There was a problem hiding this comment.
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.
Implements basic inference for TypeVarTuple along with various
check
tests verifying uses ofTypeVarTuple
with functions works reasonably.