Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review
  • Loading branch information
sobolevn committed Jul 14, 2023
commit a9d34ea61ed5762fb48555e8a9993aaa54842542
1 change: 1 addition & 0 deletions test-data/unit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ feature you added. If you added a new `check-*.test` file, it will be autodiscov
Add the test in this format anywhere in the file:

[case testNewSyntaxBasics]
# flags: --python-version 3.10
x: int
x = 5
y: int = 5
Expand Down
7 changes: 5 additions & 2 deletions test-data/unit/check-union-or-syntax.test
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ x: List[int | str]
reveal_type(x) # N: Revealed type is "builtins.list[Union[builtins.int, builtins.str]]"
[builtins fixtures/list.pyi]

[case testUnionOrSyntaxWithQuotedFunctionTypes]
[case testUnionOrSyntaxWithQuotedFunctionTypesPre310]
# flags: --python-version 3.9
from typing import Union
Comment thread
sobolevn marked this conversation as resolved.
def f(x: 'Union[int, str, None]') -> 'Union[int, None]':
reveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str, None]"
Expand All @@ -78,7 +79,8 @@ def g(x: "int | str | None") -> "int | None":
return 42
reveal_type(g) # N: Revealed type is "def (x: Union[builtins.int, builtins.str, None]) -> Union[builtins.int, None]"

[case testUnionOrSyntaxWithQuotedVariableTypes]
[case testUnionOrSyntaxWithQuotedVariableTypesPre310]
# flags: --python-version 3.9
y: "int | str" = 42
reveal_type(y) # N: Revealed type is "Union[builtins.int, builtins.str]"

Expand Down Expand Up @@ -135,6 +137,7 @@ x: int | None
x: int | None # E: X | Y syntax for unions requires Python 3.10

[case testUnionOrSyntaxInStubFile]
Comment thread
sobolevn marked this conversation as resolved.
# flags: --python-version 3.9
from lib import x
[file lib.pyi]
x: int | None
Expand Down