-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PEP 695] Add daemon tests that use new type parameter syntax (#17327)
Add some basic mypy daemon test coverage, and make it possible to write daemon tests that only work on recent Python versions. Everything tested seems to work already. Work on #15238.
- Loading branch information
Showing
7 changed files
with
210 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
[case testPEP695TypeAliasDep] | ||
# flags: --enable-incomplete-feature=NewGenericSyntax | ||
import m | ||
def g() -> m.C: | ||
return m.f() | ||
[file m.py] | ||
type C = int | ||
|
||
def f() -> int: | ||
pass | ||
[file m.py.2] | ||
type C = str | ||
|
||
def f() -> int: | ||
pass | ||
[out] | ||
== | ||
main:4: error: Incompatible return value type (got "int", expected "str") | ||
|
||
[case testPEP695ChangeOldStyleToNewStyleTypeAlias] | ||
# flags: --enable-incomplete-feature=NewGenericSyntax | ||
from m import A | ||
A() | ||
|
||
[file m.py] | ||
A = int | ||
|
||
[file m.py.2] | ||
type A = int | ||
[typing fixtures/typing-full.pyi] | ||
[builtins fixtures/tuple.pyi] | ||
[out] | ||
== | ||
main:3: error: "TypeAliasType" not callable | ||
|
||
[case testPEP695VarianceChangesDueToDependency] | ||
# flags: --enable-incomplete-feature=NewGenericSyntax | ||
from a import C | ||
|
||
x: C[object] = C[int]() | ||
|
||
[file a.py] | ||
from b import A | ||
|
||
class C[T]: | ||
def f(self) -> A[T]: ... | ||
|
||
[file b.py] | ||
class A[T]: | ||
def f(self) -> T: ... | ||
|
||
[file b.py.2] | ||
class A[T]: | ||
def f(self) -> list[T]: ... | ||
|
||
[out] | ||
== | ||
main:4: error: Incompatible types in assignment (expression has type "C[int]", variable has type "C[object]") | ||
|
||
[case testPEP695TypeAliasChangesDueToDependency] | ||
# flags: --enable-incomplete-feature=NewGenericSyntax | ||
from a import A | ||
x: A | ||
x = 0 | ||
x = '' | ||
|
||
[file a.py] | ||
from b import B | ||
type A = B[int, str] | ||
|
||
[file b.py] | ||
from typing import Union as B | ||
|
||
[file b.py.2] | ||
from builtins import tuple as B | ||
|
||
[builtins fixtures/tuple.pyi] | ||
[out] | ||
== | ||
main:4: error: Incompatible types in assignment (expression has type "int", variable has type "tuple[int, str]") | ||
main:5: error: Incompatible types in assignment (expression has type "str", variable has type "tuple[int, str]") |