forked from microsoft/pyright
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
899799d
commit 0c5c7b6
Showing
103 changed files
with
1,256 additions
and
1,286 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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 |
---|---|---|
|
@@ -4,4 +4,3 @@ | |
import html.entities | ||
|
||
x = html.escape | ||
|
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
61 changes: 6 additions & 55 deletions
61
packages/pyright-internal/src/tests/samples/isinstance1.py
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 |
---|---|---|
@@ -1,57 +1,8 @@ | ||
# This sample tests basic type narrowing behavior for | ||
# the isinstance call. | ||
# This sample tests the use of "self.__class__" and "__class__" | ||
# in an isinstance call. | ||
|
||
from typing import Any, List, Optional, Type, TypedDict, Union | ||
|
||
|
||
def func1(x: Union[List[str], int]): | ||
if isinstance(x, list): | ||
reveal_type(x, expected_text="List[str]") | ||
else: | ||
reveal_type(x, expected_text="int") | ||
|
||
|
||
def func2(x: Any): | ||
if isinstance(x, list): | ||
reveal_type(x, expected_text="list[Unknown]") | ||
else: | ||
reveal_type(x, expected_text="Any") | ||
|
||
|
||
def func3(x): | ||
if isinstance(x, list): | ||
reveal_type(x, expected_text="list[Unknown]") | ||
else: | ||
reveal_type(x, expected_text="Unknown") | ||
|
||
|
||
class SomeTypedDict(TypedDict): | ||
name: str | ||
|
||
|
||
def func4(x: Union[int, SomeTypedDict]): | ||
if isinstance(x, dict): | ||
reveal_type(x, expected_text="SomeTypedDict") | ||
else: | ||
reveal_type(x, expected_text="int") | ||
|
||
|
||
def func5(x: int | str | complex): | ||
if isinstance(x, (int, str)): | ||
reveal_type(x, expected_text="int | str") | ||
else: | ||
reveal_type(x, expected_text="complex") | ||
|
||
|
||
def func6(x: Type[int] | Type[str] | Type[complex]): | ||
if issubclass(x, (int, str)): | ||
reveal_type(x, expected_text="type[int] | type[str]") | ||
else: | ||
reveal_type(x, expected_text="type[complex]") | ||
|
||
|
||
def func7(x: Optional[Union[int, SomeTypedDict]]): | ||
if isinstance(x, (dict, type(None))): | ||
reveal_type(x, expected_text="SomeTypedDict | None") | ||
else: | ||
reveal_type(x, expected_text="int") | ||
class Foo: | ||
def bar(self): | ||
a = isinstance(object(), self.__class__) | ||
b = isinstance(object(), __class__) |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
|
||
# pyright: strict | ||
|
||
|
||
def func1(keys: list[str]): | ||
filter(lambda s: s.startswith(""), keys) |
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
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
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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# within a loop body. | ||
|
||
|
||
class Foo: | ||
class ClassA: | ||
def non_property(self) -> int: | ||
... | ||
|
||
|
File renamed without changes.
4 changes: 1 addition & 3 deletions
4
...ght-internal/src/tests/samples/loops14.py → ...ight-internal/src/tests/samples/loop14.py
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions
4
...ight-internal/src/tests/samples/loops2.py → ...right-internal/src/tests/samples/loop2.py
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.