Skip to content

Conversation

jhance
Copy link
Collaborator

@jhance jhance commented Apr 17, 2023

This adds tests for mixing star args with typevar tuples from PEP646. In order to do this we have to handle an additional case in applytype where the result of expanding an unpack is a homogenous tuple rather than a list of types.

This PR also includes (partially by accident) a fix to the empty case for type analysis. After re-reading the PEP we discover that the empty case is meant to be inferred as a Tuple[Any, ...] rather than an empty tuple and must fix that behavior as well as some of the previous test cases that assumed that it meant an empty tuple.

When we actually call target(*args) from the testcase in call we expose a crash in mypy. This will be handled by a subsequent PR.

@github-actions

This comment has been minimized.

@jhance jhance force-pushed the unspecified-paramaters branch from 394dd53 to 683042f Compare April 17, 2023 17:21
@github-actions

This comment has been minimized.

Comment on lines +167 to +171
arg_types=(
callable.arg_types[:star_index]
+ [expanded_tvt.args[0]]
+ callable.arg_types[star_index + 1 :]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
arg_types=(
callable.arg_types[:star_index]
+ [expanded_tvt.args[0]]
+ callable.arg_types[star_index + 1 :]
)
arg_types=[
*callable.arg_types[:star_index],
expanded_tvt.args[0],
*callable.arg_types[star_index + 1 :],
]

@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2023

According to mypy_primer, this change doesn't affect type check results on a corpus of 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.

LGTM

@JukkaL JukkaL merged commit 61b9b9c into python:master May 3, 2023
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.

3 participants