-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conformance tests for Callables (#1731)
Added new conformance test to go along with the recently-accepted new sections in the "Callables" chapter of the typing spec.
- Loading branch information
Showing
13 changed files
with
1,071 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
conformant = "Pass" | ||
conformant = "Partial" | ||
notes = """ | ||
Incorrectly treats "*args: T, **kwargs: T" as "..." when T is specialized to Any. | ||
Does not treat "*args: Any, **kargs: Any" as "..." when separated by keyword parameter. | ||
""" | ||
output = """ | ||
callables_annotation.py:13: error: Too few arguments [call-arg] | ||
callables_annotation.py:14: error: Argument 2 has incompatible type "int"; expected "str" [arg-type] | ||
callables_annotation.py:15: error: Too many arguments [call-arg] | ||
callables_annotation.py:17: error: Unexpected keyword argument "a" [call-arg] | ||
callables_annotation.py:17: error: Unexpected keyword argument "b" [call-arg] | ||
callables_annotation.py:23: error: Too many arguments [call-arg] | ||
callables_annotation.py:40: error: Please use "Callable[[<parameters>], <return type>]" or "Callable" [misc] | ||
callables_annotation.py:41: error: The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type] | ||
callables_annotation.py:41: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas | ||
callables_annotation.py:42: error: Bracketed expression "[...]" is not valid as a type [valid-type] | ||
callables_annotation.py:42: note: Did you mean "List[...]"? | ||
callables_annotation.py:43: error: Please use "Callable[[<parameters>], <return type>]" or "Callable" [misc] | ||
callables_annotation.py:44: error: Unexpected "..." [misc] | ||
callables_annotation.py:25: error: Too few arguments [call-arg] | ||
callables_annotation.py:26: error: Argument 2 has incompatible type "int"; expected "str" [arg-type] | ||
callables_annotation.py:27: error: Too many arguments [call-arg] | ||
callables_annotation.py:29: error: Unexpected keyword argument "a" [call-arg] | ||
callables_annotation.py:29: error: Unexpected keyword argument "b" [call-arg] | ||
callables_annotation.py:35: error: Too many arguments [call-arg] | ||
callables_annotation.py:55: error: Please use "Callable[[<parameters>], <return type>]" or "Callable" [misc] | ||
callables_annotation.py:56: error: The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type] | ||
callables_annotation.py:56: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas | ||
callables_annotation.py:57: error: Bracketed expression "[...]" is not valid as a type [valid-type] | ||
callables_annotation.py:57: note: Did you mean "List[...]"? | ||
callables_annotation.py:58: error: Please use "Callable[[<parameters>], <return type>]" or "Callable" [misc] | ||
callables_annotation.py:59: error: Unexpected "..." [misc] | ||
callables_annotation.py:91: error: Incompatible types in assignment (expression has type "Callable[[], str]", variable has type "Callable[[int, VarArg(Any), KwArg(Any)], str]") [assignment] | ||
callables_annotation.py:93: error: Incompatible types in assignment (expression has type "Callable[[NamedArg(int, 'a')], str]", variable has type "Callable[[int, VarArg(Any), KwArg(Any)], str]") [assignment] | ||
callables_annotation.py:136: error: Expression is of type "Proto3", not "Callable[..., None]" [assert-type] | ||
callables_annotation.py:139: error: Incompatible types in assignment (expression has type "Proto7", variable has type "Proto6") [assignment] | ||
callables_annotation.py:139: note: Following member(s) of "Proto7" have conflicts: | ||
callables_annotation.py:139: note: Expected: | ||
callables_annotation.py:139: note: def __call__(self, int, /, *args: Any, k: str, **kwargs: Any) -> None | ||
callables_annotation.py:139: note: Got: | ||
callables_annotation.py:139: note: def __call__(self, float, /, b: int, *, k: str, m: str) -> None | ||
callables_annotation.py:152: error: Incompatible types in assignment (expression has type "Callable[[], str]", variable has type "Callable[[int, VarArg(Any), KwArg(Any)], str]") [assignment] | ||
callables_annotation.py:167: error: Incompatible types in assignment (expression has type "Callable[[int, str], str]", variable has type "Callable[[str, VarArg(Any), KwArg(Any)], str]") [assignment] | ||
callables_annotation.py:169: error: Incompatible types in assignment (expression has type "Callable[[int, str], str]", variable has type "Callable[[str, VarArg(Any), KwArg(Any)], str]") [assignment] | ||
""" | ||
conformance_automated = "Pass" | ||
conformance_automated = "Fail" | ||
errors_diff = """ | ||
Line 134: Expected 1 errors | ||
Line 139: Unexpected errors ['callables_annotation.py:139: error: Incompatible types in assignment (expression has type "Proto7", variable has type "Proto6") [assignment]'] | ||
""" |
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,179 @@ | ||
conformant = "Pass" | ||
errors_diff = """ | ||
""" | ||
output = """ | ||
callables_subtyping.py:26: error: Incompatible types in assignment (expression has type "Callable[[int], int]", variable has type "Callable[[float], float]") [assignment] | ||
callables_subtyping.py:29: error: Incompatible types in assignment (expression has type "Callable[[float], float]", variable has type "Callable[[int], int]") [assignment] | ||
callables_subtyping.py:51: error: Incompatible types in assignment (expression has type "PosOnly2", variable has type "Standard2") [assignment] | ||
callables_subtyping.py:52: error: Incompatible types in assignment (expression has type "KwOnly2", variable has type "Standard2") [assignment] | ||
callables_subtyping.py:52: note: Following member(s) of "KwOnly2" have conflicts: | ||
callables_subtyping.py:52: note: Expected: | ||
callables_subtyping.py:52: note: def __call__(self, a: int, b: int) -> None | ||
callables_subtyping.py:52: note: Got: | ||
callables_subtyping.py:52: note: def __call__(self, *, b: int, a: int) -> None | ||
callables_subtyping.py:55: error: Incompatible types in assignment (expression has type "KwOnly2", variable has type "PosOnly2") [assignment] | ||
callables_subtyping.py:55: note: Following member(s) of "KwOnly2" have conflicts: | ||
callables_subtyping.py:55: note: Expected: | ||
callables_subtyping.py:55: note: def __call__(self, int, int, /) -> None | ||
callables_subtyping.py:55: note: Got: | ||
callables_subtyping.py:55: note: def __call__(self, *, b: int, a: int) -> None | ||
callables_subtyping.py:58: error: Incompatible types in assignment (expression has type "PosOnly2", variable has type "KwOnly2") [assignment] | ||
callables_subtyping.py:58: note: Following member(s) of "PosOnly2" have conflicts: | ||
callables_subtyping.py:58: note: Expected: | ||
callables_subtyping.py:58: note: def __call__(self, *, b: int, a: int) -> None | ||
callables_subtyping.py:58: note: Got: | ||
callables_subtyping.py:58: note: def __call__(self, int, int, /) -> None | ||
callables_subtyping.py:82: error: Incompatible types in assignment (expression has type "NoArgs3", variable has type "IntArgs3") [assignment] | ||
callables_subtyping.py:82: note: Following member(s) of "NoArgs3" have conflicts: | ||
callables_subtyping.py:82: note: Expected: | ||
callables_subtyping.py:82: note: def __call__(self, *args: int) -> None | ||
callables_subtyping.py:82: note: Got: | ||
callables_subtyping.py:82: note: def __call__(self) -> None | ||
callables_subtyping.py:85: error: Incompatible types in assignment (expression has type "NoArgs3", variable has type "FloatArgs3") [assignment] | ||
callables_subtyping.py:85: note: Following member(s) of "NoArgs3" have conflicts: | ||
callables_subtyping.py:85: note: Expected: | ||
callables_subtyping.py:85: note: def __call__(self, *args: float) -> None | ||
callables_subtyping.py:85: note: Got: | ||
callables_subtyping.py:85: note: def __call__(self) -> None | ||
callables_subtyping.py:86: error: Incompatible types in assignment (expression has type "IntArgs3", variable has type "FloatArgs3") [assignment] | ||
callables_subtyping.py:86: note: Following member(s) of "IntArgs3" have conflicts: | ||
callables_subtyping.py:86: note: Expected: | ||
callables_subtyping.py:86: note: def __call__(self, *args: float) -> None | ||
callables_subtyping.py:86: note: Got: | ||
callables_subtyping.py:86: note: def __call__(self, *args: int) -> None | ||
callables_subtyping.py:116: error: Incompatible types in assignment (expression has type "IntArgs4", variable has type "PosOnly4") [assignment] | ||
callables_subtyping.py:116: note: Following member(s) of "IntArgs4" have conflicts: | ||
callables_subtyping.py:116: note: Expected: | ||
callables_subtyping.py:116: note: def __call__(self, int, str, /) -> None | ||
callables_subtyping.py:116: note: Got: | ||
callables_subtyping.py:116: note: def __call__(self, *args: int) -> None | ||
callables_subtyping.py:119: error: Incompatible types in assignment (expression has type "StrArgs4", variable has type "IntStrArgs4") [assignment] | ||
callables_subtyping.py:119: note: Following member(s) of "StrArgs4" have conflicts: | ||
callables_subtyping.py:119: note: Expected: | ||
callables_subtyping.py:119: note: def __call__(self, *args: int | str) -> None | ||
callables_subtyping.py:119: note: Got: | ||
callables_subtyping.py:119: note: def __call__(self, int, /, *args: str) -> None | ||
callables_subtyping.py:120: error: Incompatible types in assignment (expression has type "IntArgs4", variable has type "IntStrArgs4") [assignment] | ||
callables_subtyping.py:120: note: Following member(s) of "IntArgs4" have conflicts: | ||
callables_subtyping.py:120: note: Expected: | ||
callables_subtyping.py:120: note: def __call__(self, *args: int | str) -> None | ||
callables_subtyping.py:120: note: Got: | ||
callables_subtyping.py:120: note: def __call__(self, *args: int) -> None | ||
callables_subtyping.py:122: error: Incompatible types in assignment (expression has type "IntArgs4", variable has type "StrArgs4") [assignment] | ||
callables_subtyping.py:122: note: Following member(s) of "IntArgs4" have conflicts: | ||
callables_subtyping.py:122: note: Expected: | ||
callables_subtyping.py:122: note: def __call__(self, int, /, *args: str) -> None | ||
callables_subtyping.py:122: note: Got: | ||
callables_subtyping.py:122: note: def __call__(self, *args: int) -> None | ||
callables_subtyping.py:124: error: Incompatible types in assignment (expression has type "StrArgs4", variable has type "IntArgs4") [assignment] | ||
callables_subtyping.py:124: note: Following member(s) of "StrArgs4" have conflicts: | ||
callables_subtyping.py:124: note: Expected: | ||
callables_subtyping.py:124: note: def __call__(self, *args: int) -> None | ||
callables_subtyping.py:124: note: Got: | ||
callables_subtyping.py:124: note: def __call__(self, int, /, *args: str) -> None | ||
callables_subtyping.py:125: error: Incompatible types in assignment (expression has type "IntStrArgs4", variable has type "Standard4") [assignment] | ||
callables_subtyping.py:126: error: Incompatible types in assignment (expression has type "StrArgs4", variable has type "Standard4") [assignment] | ||
callables_subtyping.py:151: error: Incompatible types in assignment (expression has type "NoKwargs5", variable has type "IntKwargs5") [assignment] | ||
callables_subtyping.py:151: note: Following member(s) of "NoKwargs5" have conflicts: | ||
callables_subtyping.py:151: note: Expected: | ||
callables_subtyping.py:151: note: def __call__(self, **kwargs: int) -> None | ||
callables_subtyping.py:151: note: Got: | ||
callables_subtyping.py:151: note: def __call__(self) -> None | ||
callables_subtyping.py:154: error: Incompatible types in assignment (expression has type "NoKwargs5", variable has type "FloatKwargs5") [assignment] | ||
callables_subtyping.py:154: note: Following member(s) of "NoKwargs5" have conflicts: | ||
callables_subtyping.py:154: note: Expected: | ||
callables_subtyping.py:154: note: def __call__(self, **kwargs: float) -> None | ||
callables_subtyping.py:154: note: Got: | ||
callables_subtyping.py:154: note: def __call__(self) -> None | ||
callables_subtyping.py:155: error: Incompatible types in assignment (expression has type "IntKwargs5", variable has type "FloatKwargs5") [assignment] | ||
callables_subtyping.py:155: note: Following member(s) of "IntKwargs5" have conflicts: | ||
callables_subtyping.py:155: note: Expected: | ||
callables_subtyping.py:155: note: def __call__(self, **kwargs: float) -> None | ||
callables_subtyping.py:155: note: Got: | ||
callables_subtyping.py:155: note: def __call__(self, **kwargs: int) -> None | ||
callables_subtyping.py:187: error: Incompatible types in assignment (expression has type "IntKwargs6", variable has type "KwOnly6") [assignment] | ||
callables_subtyping.py:187: note: Following member(s) of "IntKwargs6" have conflicts: | ||
callables_subtyping.py:187: note: Expected: | ||
callables_subtyping.py:187: note: def __call__(self, *, a: int, b: str) -> None | ||
callables_subtyping.py:187: note: Got: | ||
callables_subtyping.py:187: note: def __call__(self, **kwargs: int) -> None | ||
callables_subtyping.py:190: error: Incompatible types in assignment (expression has type "StrKwargs6", variable has type "IntStrKwargs6") [assignment] | ||
callables_subtyping.py:190: note: Following member(s) of "StrKwargs6" have conflicts: | ||
callables_subtyping.py:190: note: Expected: | ||
callables_subtyping.py:190: note: def __call__(self, **kwargs: int | str) -> None | ||
callables_subtyping.py:190: note: Got: | ||
callables_subtyping.py:190: note: def __call__(self, *, a: int, **kwargs: str) -> None | ||
callables_subtyping.py:191: error: Incompatible types in assignment (expression has type "IntKwargs6", variable has type "IntStrKwargs6") [assignment] | ||
callables_subtyping.py:191: note: Following member(s) of "IntKwargs6" have conflicts: | ||
callables_subtyping.py:191: note: Expected: | ||
callables_subtyping.py:191: note: def __call__(self, **kwargs: int | str) -> None | ||
callables_subtyping.py:191: note: Got: | ||
callables_subtyping.py:191: note: def __call__(self, **kwargs: int) -> None | ||
callables_subtyping.py:193: error: Incompatible types in assignment (expression has type "IntKwargs6", variable has type "StrKwargs6") [assignment] | ||
callables_subtyping.py:193: note: Following member(s) of "IntKwargs6" have conflicts: | ||
callables_subtyping.py:193: note: Expected: | ||
callables_subtyping.py:193: note: def __call__(self, *, a: int, **kwargs: str) -> None | ||
callables_subtyping.py:193: note: Got: | ||
callables_subtyping.py:193: note: def __call__(self, **kwargs: int) -> None | ||
callables_subtyping.py:195: error: Incompatible types in assignment (expression has type "StrKwargs6", variable has type "IntKwargs6") [assignment] | ||
callables_subtyping.py:195: note: Following member(s) of "StrKwargs6" have conflicts: | ||
callables_subtyping.py:195: note: Expected: | ||
callables_subtyping.py:195: note: def __call__(self, **kwargs: int) -> None | ||
callables_subtyping.py:195: note: Got: | ||
callables_subtyping.py:195: note: def __call__(self, *, a: int, **kwargs: str) -> None | ||
callables_subtyping.py:196: error: Incompatible types in assignment (expression has type "IntStrKwargs6", variable has type "Standard6") [assignment] | ||
callables_subtyping.py:196: note: Following member(s) of "IntStrKwargs6" have conflicts: | ||
callables_subtyping.py:196: note: Expected: | ||
callables_subtyping.py:196: note: def __call__(self, a: int, b: str) -> None | ||
callables_subtyping.py:196: note: Got: | ||
callables_subtyping.py:196: note: def __call__(self, **kwargs: int | str) -> None | ||
callables_subtyping.py:197: error: Incompatible types in assignment (expression has type "StrKwargs6", variable has type "Standard6") [assignment] | ||
callables_subtyping.py:197: note: Following member(s) of "StrKwargs6" have conflicts: | ||
callables_subtyping.py:197: note: Expected: | ||
callables_subtyping.py:197: note: def __call__(self, a: int, b: str) -> None | ||
callables_subtyping.py:197: note: Got: | ||
callables_subtyping.py:197: note: def __call__(self, *, a: int, **kwargs: str) -> None | ||
callables_subtyping.py:236: error: Incompatible types in assignment (expression has type "NoDefaultArg8", variable has type "DefaultArg8") [assignment] | ||
callables_subtyping.py:236: note: Following member(s) of "NoDefaultArg8" have conflicts: | ||
callables_subtyping.py:236: note: Expected: | ||
callables_subtyping.py:236: note: def __call__(self, x: int = ...) -> None | ||
callables_subtyping.py:236: note: Got: | ||
callables_subtyping.py:236: note: def __call__(self, x: int) -> None | ||
callables_subtyping.py:237: error: Incompatible types in assignment (expression has type "NoX8", variable has type "DefaultArg8") [assignment] | ||
callables_subtyping.py:237: note: Following member(s) of "NoX8" have conflicts: | ||
callables_subtyping.py:237: note: Expected: | ||
callables_subtyping.py:237: note: def __call__(self, x: int = ...) -> None | ||
callables_subtyping.py:237: note: Got: | ||
callables_subtyping.py:237: note: def __call__(self) -> None | ||
callables_subtyping.py:240: error: Incompatible types in assignment (expression has type "NoX8", variable has type "NoDefaultArg8") [assignment] | ||
callables_subtyping.py:240: note: Following member(s) of "NoX8" have conflicts: | ||
callables_subtyping.py:240: note: Expected: | ||
callables_subtyping.py:240: note: def __call__(self, x: int) -> None | ||
callables_subtyping.py:240: note: Got: | ||
callables_subtyping.py:240: note: def __call__(self) -> None | ||
callables_subtyping.py:243: error: Incompatible types in assignment (expression has type "NoDefaultArg8", variable has type "NoX8") [assignment] | ||
callables_subtyping.py:243: note: Following member(s) of "NoDefaultArg8" have conflicts: | ||
callables_subtyping.py:243: note: Expected: | ||
callables_subtyping.py:243: note: def __call__(self) -> None | ||
callables_subtyping.py:243: note: Got: | ||
callables_subtyping.py:243: note: def __call__(self, x: int) -> None | ||
callables_subtyping.py:273: error: Incompatible types in assignment (expression has type "Overloaded9", variable has type "FloatArg9") [assignment] | ||
callables_subtyping.py:273: note: Following member(s) of "Overloaded9" have conflicts: | ||
callables_subtyping.py:273: note: Expected: | ||
callables_subtyping.py:273: note: def __call__(self, x: float) -> float | ||
callables_subtyping.py:273: note: Got: | ||
callables_subtyping.py:273: note: @overload | ||
callables_subtyping.py:273: note: def __call__(self, x: int) -> int | ||
callables_subtyping.py:273: note: @overload | ||
callables_subtyping.py:273: note: def __call__(self, x: str) -> str | ||
callables_subtyping.py:297: error: Incompatible types in assignment (expression has type "StrArg10", variable has type "Overloaded10") [assignment] | ||
callables_subtyping.py:297: note: Following member(s) of "StrArg10" have conflicts: | ||
callables_subtyping.py:297: note: Expected: | ||
callables_subtyping.py:297: note: @overload | ||
callables_subtyping.py:297: note: def __call__(self, x: int, y: str) -> float | ||
callables_subtyping.py:297: note: @overload | ||
callables_subtyping.py:297: note: def __call__(self, x: str) -> complex | ||
callables_subtyping.py:297: note: Got: | ||
callables_subtyping.py:297: note: def __call__(self, x: str) -> complex | ||
""" | ||
conformance_automated = "Pass" |
Oops, something went wrong.