Skip to content

Fix several tests on Python 3.11 #13259

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 1 commit into from
Jul 28, 2022
Merged
Changes from all commits
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
16 changes: 11 additions & 5 deletions test-data/unit/check-python38.test
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ h(arg=0) # E: Unexpected keyword argument "arg" for "h"
i(arg=0) # E: Unexpected keyword argument "arg"

[case testWalrus]
# flags: --strict-optional
# flags: --strict-optional --python-version 3.8
from typing import NamedTuple, Optional, List
from typing_extensions import Final

Expand Down Expand Up @@ -385,6 +385,7 @@ reveal_type(z2) # E: Name "z2" is not defined # N: Revealed type is "Any"
[builtins fixtures/isinstancelist.pyi]

[case testWalrusConditionalTypeBinder]
# flags: --python-version 3.8
from typing import Union
from typing_extensions import Literal

Expand All @@ -405,7 +406,7 @@ else:
[builtins fixtures/property.pyi]

[case testWalrusConditionalTypeCheck]
# flags: --strict-optional
# flags: --strict-optional --python-version 3.8
from typing import Optional

maybe_str: Optional[str]
Expand All @@ -421,6 +422,7 @@ reveal_type(maybe_str) # N: Revealed type is "Union[builtins.str, None]"
[builtins fixtures/bool.pyi]

[case testWalrusConditionalTypeCheck2]
# flags: --python-version 3.8
from typing import Optional

maybe_str: Optional[str]
Expand All @@ -436,6 +438,7 @@ reveal_type(maybe_str) # N: Revealed type is "Union[builtins.str, None]"
[builtins fixtures/bool.pyi]

[case testWalrusPartialTypes]
# flags: --python-version 3.8
from typing import List

def check_partial_list() -> None:
Expand All @@ -452,7 +455,7 @@ def check_partial_list() -> None:
[builtins fixtures/list.pyi]

[case testWalrusAssignmentAndConditionScopeForLiteral]
# flags: --warn-unreachable
# flags: --warn-unreachable --python-version 3.8

if (x := 0):
reveal_type(x) # E: Statement is unreachable
Expand All @@ -462,7 +465,7 @@ else:
reveal_type(x) # N: Revealed type is "builtins.int"

[case testWalrusAssignmentAndConditionScopeForProperty]
# flags: --warn-unreachable
# flags: --warn-unreachable --python-version 3.8

from typing_extensions import Literal

Expand Down Expand Up @@ -490,7 +493,7 @@ reveal_type(y) # N: Revealed type is "Literal[False]"
[builtins fixtures/property.pyi]

[case testWalrusAssignmentAndConditionScopeForFunction]
# flags: --warn-unreachable
# flags: --warn-unreachable --python-version 3.8

from typing_extensions import Literal

Expand Down Expand Up @@ -523,6 +526,7 @@ reveal_type(z) # N: Revealed type is "Literal[False]"
[builtins fixtures/tuple.pyi]

[case testWalrusExpr]
# flags: --python-version 3.8
def func() -> None:
foo = Foo()
if x := foo.x:
Expand All @@ -533,6 +537,7 @@ class Foo:
self.x = 123

[case testWalrusTypeGuard]
# flags: --python-version 3.8
from typing_extensions import TypeGuard
def is_float(a: object) -> TypeGuard[float]: pass
def main(a: object) -> None:
Expand All @@ -542,6 +547,7 @@ def main(a: object) -> None:
[builtins fixtures/tuple.pyi]

[case testWalrusRedefined]
# flags: --python-version 3.8
def foo() -> None:
x = 0
[x := x + y for y in [1, 2, 3]]
Expand Down