Fix checking multiple assignments based on tuple unpacking involving partially initialised variables (Fixes #12915). #14423
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix checking multiple assignments based on tuple unpacking involving partially initialised variables (Fixes #12915).
This commit introduces two changes:
undefined_rvalue
logic completely. This logic bothered me because it introduced the necessity to make the mentioned conversion twice (which was not always successful due to reasons I do not fully understand).Test new case
testDefinePartiallyInitialisedVariableDuringTupleUnpacking
covers issue #12915.I had to adjust some other test cases. In my opinion, the error messages are now more transparent, consistent, and complete. Removing the
undefined_rvalue
logic also seems to fix one more bug. In the test casestestInferenceWithTypeVariableTwiceInReturnType
andtestInferenceWithTypeVariableTwiceInReturnTypeAndMultipleVariables
, there were three assignments for which Mypy did not report errors but, in my opinion, should.So, for the current test data set, removing the
undefined_rvalue
logic seems to introduce mere benefits than drawbacks (meaning, different error messages than before). I hope it does not break any Mypy functionalities not covered by the tests.