Skip to content

Discard TypeEvaluator if cancellation leaves partially-constructed function type in cache #8118

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

Merged
merged 4 commits into from
Jun 11, 2024

Conversation

debonte
Copy link
Collaborator

@debonte debonte commented Jun 11, 2024

This is the function equivalent of the class cancellation fix in #5786.

If getTypeOfFunctionDecorated or getTypeOfLambdaWithExpectedType are cancelled before they complete, which would leave a partially evaluated function type in the type cache, we now set isTypeCacheInvalid to true on the OperationCanceledException. This will cause Program._runEvaluatorWithCancellationToken to discard the TypeEvaluator and create a new instance.

I believe this will address microsoft/pylance-release#4295.

This comment has been minimized.

@erictraut
Copy link
Collaborator

You hit the same MacOS test failure that I've been seeing sporadically. It tends to go away if you run the test again, but that's unnerving. I've never been able to repro it locally on my Mac. I've reviewed the test code to try to determine potential causes, and I'm not able to find the problem. It could be related to a timeout in the test framework. I somewhat suspect that it's related to my other recent change that I asked you to code review. This error started at about the same time.

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@erictraut
Copy link
Collaborator

@debonte, is the PR ready from your standpoint? If so, let's merge it so we can get it into today's pyright release.

@debonte debonte merged commit 807b160 into microsoft:main Jun 11, 2024
12 checks passed
@debonte debonte deleted the pylance4295 branch June 11, 2024 22:02
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