-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue that results in a false positive "type could not be deter…
…mined because it refers to itself" error caused by a false dependency due to narrowing logic. This may also improve type analysis performance in some code. This addresses #9139.
- Loading branch information
Showing
3 changed files
with
94 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This sample tests a case where type evaluation for a type guard | ||
# within a loop may trigger a false positive "type depends on itself" | ||
# error message. | ||
|
||
# For details, see https://github.com/microsoft/pyright/issues/9139. | ||
|
||
from enum import StrEnum | ||
|
||
|
||
class MyEnum(StrEnum): | ||
A = "A" | ||
|
||
|
||
for _ in range(2): | ||
x: dict[MyEnum, int] = {} | ||
|
||
if MyEnum.A in x: | ||
... | ||
|
||
for _ in x.values(): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters