diff --git a/conformance/results/mypy/annotations_generators.toml b/conformance/results/mypy/annotations_generators.toml index 5d0520f8a..fbeeb9cdf 100644 --- a/conformance/results/mypy/annotations_generators.toml +++ b/conformance/results/mypy/annotations_generators.toml @@ -3,13 +3,13 @@ notes = """ Does not report incompatible Generator type in `yield from` statement. """ output = """ -annotations_generators.py:50: error: Missing return statement [return] -annotations_generators.py:53: error: Incompatible return value type (got "bool", expected "C") [return-value] -annotations_generators.py:56: error: Incompatible types in "yield" (actual type "int", expected type "A") [misc] -annotations_generators.py:65: error: Incompatible types in "yield" (actual type "int", expected type "A") [misc] -annotations_generators.py:74: error: Incompatible types in "yield" (actual type "B", expected type "A") [misc] -annotations_generators.py:85: error: The return type of a generator function should be "Generator" or one of its supertypes [misc] -annotations_generators.py:90: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes [misc] -annotations_generators.py:117: error: Incompatible types in "yield from" (actual type "A", expected type "B") [misc] -annotations_generators.py:118: error: Incompatible types in "yield from" (actual type "int", expected type "B") [misc] +annotations_generators.py:51: error: Missing return statement [return] +annotations_generators.py:54: error: Incompatible return value type (got "bool", expected "C") [return-value] +annotations_generators.py:57: error: Incompatible types in "yield" (actual type "int", expected type "A") [misc] +annotations_generators.py:66: error: Incompatible types in "yield" (actual type "int", expected type "A") [misc] +annotations_generators.py:75: error: Incompatible types in "yield" (actual type "B", expected type "A") [misc] +annotations_generators.py:86: error: The return type of a generator function should be "Generator" or one of its supertypes [misc] +annotations_generators.py:91: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes [misc] +annotations_generators.py:118: error: Incompatible types in "yield from" (actual type "A", expected type "B") [misc] +annotations_generators.py:119: error: Incompatible types in "yield from" (actual type "int", expected type "B") [misc] """ diff --git a/conformance/results/mypy/annotations_methods.toml b/conformance/results/mypy/annotations_methods.toml index 2146548eb..cbbdd307c 100644 --- a/conformance/results/mypy/annotations_methods.toml +++ b/conformance/results/mypy/annotations_methods.toml @@ -1,3 +1,7 @@ conformant = "Pass" +notes = """ +Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings. +""" output = """ +annotations_methods.py:42: error: Expression is of type "B", not "A" [assert-type] """ diff --git a/conformance/results/mypy/directives_assert_type.toml b/conformance/results/mypy/directives_assert_type.toml index 73330752d..ed6efb743 100644 --- a/conformance/results/mypy/directives_assert_type.toml +++ b/conformance/results/mypy/directives_assert_type.toml @@ -2,9 +2,10 @@ conformant = "Pass" output = """ directives_assert_type.py:27: error: Expression is of type "int | str", not "int" [assert-type] directives_assert_type.py:28: error: Expression is of type "Any", not "int" [assert-type] -directives_assert_type.py:30: error: "assert_type" expects 2 arguments [misc] -directives_assert_type.py:30: error: Too few arguments for "assert_type" [call-arg] -directives_assert_type.py:31: error: Expression is of type "Literal['']", not "int" [assert-type] -directives_assert_type.py:32: error: "assert_type" expects 2 arguments [misc] -directives_assert_type.py:32: error: Too many arguments for "assert_type" [call-arg] +directives_assert_type.py:29: error: Expression is of type "Literal[4]", not "int" [assert-type] +directives_assert_type.py:31: error: "assert_type" expects 2 arguments [misc] +directives_assert_type.py:31: error: Too few arguments for "assert_type" [call-arg] +directives_assert_type.py:32: error: Expression is of type "Literal['']", not "int" [assert-type] +directives_assert_type.py:33: error: "assert_type" expects 2 arguments [misc] +directives_assert_type.py:33: error: Too many arguments for "assert_type" [call-arg] """ diff --git a/conformance/results/mypy/directives_type_ignore_file1.toml b/conformance/results/mypy/directives_type_ignore_file1.toml new file mode 100644 index 000000000..2146548eb --- /dev/null +++ b/conformance/results/mypy/directives_type_ignore_file1.toml @@ -0,0 +1,3 @@ +conformant = "Pass" +output = """ +""" diff --git a/conformance/results/mypy/directives_type_ignore_file2.toml b/conformance/results/mypy/directives_type_ignore_file2.toml new file mode 100644 index 000000000..b5962200b --- /dev/null +++ b/conformance/results/mypy/directives_type_ignore_file2.toml @@ -0,0 +1,4 @@ +conformant = "Pass" +output = """ +directives_type_ignore_file2.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] +""" diff --git a/conformance/results/mypy/overloads_basic.toml b/conformance/results/mypy/overloads_basic.toml index c09c13dad..09a06cf60 100644 --- a/conformance/results/mypy/overloads_basic.toml +++ b/conformance/results/mypy/overloads_basic.toml @@ -1,9 +1,9 @@ conformant = "Pass" output = """ -overloads_basic.py:35: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload] -overloads_basic.py:35: note: Possible overload variants: -overloads_basic.py:35: note: def __getitem__(self, int, /) -> int -overloads_basic.py:35: note: def __getitem__(self, slice, /) -> bytes -overloads_basic.py:59: error: Single overload definition, multiple required [misc] -overloads_basic.py:69: error: An overloaded function outside a stub file must have an implementation [no-overload-impl] +overloads_basic.py:37: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload] +overloads_basic.py:37: note: Possible overload variants: +overloads_basic.py:37: note: def __getitem__(self, int, /) -> int +overloads_basic.py:37: note: def __getitem__(self, slice, /) -> bytes +overloads_basic.py:62: error: Single overload definition, multiple required [misc] +overloads_basic.py:74: error: An overloaded function outside a stub file must have an implementation [no-overload-impl] """ diff --git a/conformance/results/mypy/protocols_definition.toml b/conformance/results/mypy/protocols_definition.toml index f586e887d..96227ab9d 100644 --- a/conformance/results/mypy/protocols_definition.toml +++ b/conformance/results/mypy/protocols_definition.toml @@ -6,50 +6,50 @@ Does not detect protocol mismatch if concrete method's parameters are position-o """ output = """ protocols_definition.py:30: error: List item 0 has incompatible type "int"; expected "SupportsClose" [list-item] -protocols_definition.py:62: error: Protocol members cannot be defined via assignment to self [misc] -protocols_definition.py:62: error: "Template" has no attribute "temp" [attr-defined] -protocols_definition.py:109: error: Incompatible types in assignment (expression has type "Concrete2_Good2", variable has type "Template2") [assignment] -protocols_definition.py:109: note: Protocol member Template2.val1 expected class variable, got instance variable -protocols_definition.py:110: error: Incompatible types in assignment (expression has type "Concrete2_Bad1", variable has type "Template2") [assignment] -protocols_definition.py:111: error: Incompatible types in assignment (expression has type "Concrete2_Bad2", variable has type "Template2") [assignment] -protocols_definition.py:111: note: Following member(s) of "Concrete2_Bad2" have conflicts: -protocols_definition.py:111: note: val1: expected "Sequence[int]", got "Sequence[float]" -protocols_definition.py:111: note: Protocol member Template2.val1 expected class variable, got instance variable -protocols_definition.py:112: error: Incompatible types in assignment (expression has type "Concrete2_Bad3", variable has type "Template2") [assignment] -protocols_definition.py:112: note: Following member(s) of "Concrete2_Bad3" have conflicts: -protocols_definition.py:112: note: val1: expected "Sequence[int]", got "list[int]" -protocols_definition.py:112: note: Protocol member Template2.val1 expected class variable, got instance variable -protocols_definition.py:151: error: Incompatible types in assignment (expression has type "Concrete3_Bad1", variable has type "Template3") [assignment] -protocols_definition.py:152: error: Incompatible types in assignment (expression has type "Concrete3_Bad2", variable has type "Template3") [assignment] -protocols_definition.py:152: note: Protocol member Template3.val1 expected instance variable, got class variable -protocols_definition.py:153: error: Incompatible types in assignment (expression has type "Concrete3_Bad3", variable has type "Template3") [assignment] -protocols_definition.py:153: note: Protocol member Template3.val1 expected settable variable, got read-only attribute -protocols_definition.py:154: error: Incompatible types in assignment (expression has type "Concrete3_Bad4", variable has type "Template3") [assignment] -protocols_definition.py:154: note: Following member(s) of "Concrete3_Bad4" have conflicts: -protocols_definition.py:154: note: val1: expected "Sequence[int]", got "Sequence[float]" -protocols_definition.py:155: error: Incompatible types in assignment (expression has type "Concrete3_Bad5", variable has type "Template3") [assignment] -protocols_definition.py:155: note: Following member(s) of "Concrete3_Bad5" have conflicts: -protocols_definition.py:155: note: val1: expected "Sequence[int]", got "list[int]" -protocols_definition.py:213: error: Incompatible types in assignment (expression has type "Concrete4_Bad1", variable has type "Template4") [assignment] -protocols_definition.py:213: note: Following member(s) of "Concrete4_Bad1" have conflicts: -protocols_definition.py:213: note: val1: expected "Sequence[float]", got "Callable[[], Sequence[int]]" -protocols_definition.py:214: error: Incompatible types in assignment (expression has type "Concrete4_Bad2", variable has type "Template4") [assignment] -protocols_definition.py:276: error: Incompatible types in assignment (expression has type "Concrete5_Bad2", variable has type "Template5") [assignment] -protocols_definition.py:276: note: Following member(s) of "Concrete5_Bad2" have conflicts: -protocols_definition.py:276: note: Expected: -protocols_definition.py:276: note: def method1(self, a: int, b: int) -> float -protocols_definition.py:276: note: Got: -protocols_definition.py:276: note: def method1(self, *, a: int, b: int) -> float -protocols_definition.py:278: error: Incompatible types in assignment (expression has type "Concrete5_Bad5", variable has type "Template5") [assignment] -protocols_definition.py:278: note: Following member(s) of "Concrete5_Bad5" have conflicts: -protocols_definition.py:278: note: Expected: -protocols_definition.py:278: note: def method1(self, a: int, b: int) -> float -protocols_definition.py:278: note: Got: -protocols_definition.py:278: note: def method1(self: Any, a: int, b: int) -> float -protocols_definition.py:328: error: Incompatible types in assignment (expression has type "Concrete6_Bad1", variable has type "Template6") [assignment] -protocols_definition.py:328: note: Protocol member Template6.val1 expected settable variable, got read-only attribute -protocols_definition.py:329: error: Incompatible types in assignment (expression has type "Concrete6_Bad2", variable has type "Template6") [assignment] -protocols_definition.py:329: note: Protocol member Template6.val1 expected settable variable, got read-only attribute -protocols_definition.py:330: error: Incompatible types in assignment (expression has type "Concrete6_Bad3", variable has type "Template6") [assignment] -protocols_definition.py:330: note: Protocol member Template6.val1 expected settable variable, got read-only attribute +protocols_definition.py:67: error: Protocol members cannot be defined via assignment to self [misc] +protocols_definition.py:67: error: "Template" has no attribute "temp" [attr-defined] +protocols_definition.py:114: error: Incompatible types in assignment (expression has type "Concrete2_Good2", variable has type "Template2") [assignment] +protocols_definition.py:114: note: Protocol member Template2.val1 expected class variable, got instance variable +protocols_definition.py:115: error: Incompatible types in assignment (expression has type "Concrete2_Bad1", variable has type "Template2") [assignment] +protocols_definition.py:116: error: Incompatible types in assignment (expression has type "Concrete2_Bad2", variable has type "Template2") [assignment] +protocols_definition.py:116: note: Following member(s) of "Concrete2_Bad2" have conflicts: +protocols_definition.py:116: note: val1: expected "Sequence[int]", got "Sequence[float]" +protocols_definition.py:116: note: Protocol member Template2.val1 expected class variable, got instance variable +protocols_definition.py:117: error: Incompatible types in assignment (expression has type "Concrete2_Bad3", variable has type "Template2") [assignment] +protocols_definition.py:117: note: Following member(s) of "Concrete2_Bad3" have conflicts: +protocols_definition.py:117: note: val1: expected "Sequence[int]", got "list[int]" +protocols_definition.py:117: note: Protocol member Template2.val1 expected class variable, got instance variable +protocols_definition.py:156: error: Incompatible types in assignment (expression has type "Concrete3_Bad1", variable has type "Template3") [assignment] +protocols_definition.py:157: error: Incompatible types in assignment (expression has type "Concrete3_Bad2", variable has type "Template3") [assignment] +protocols_definition.py:157: note: Protocol member Template3.val1 expected instance variable, got class variable +protocols_definition.py:158: error: Incompatible types in assignment (expression has type "Concrete3_Bad3", variable has type "Template3") [assignment] +protocols_definition.py:158: note: Protocol member Template3.val1 expected settable variable, got read-only attribute +protocols_definition.py:159: error: Incompatible types in assignment (expression has type "Concrete3_Bad4", variable has type "Template3") [assignment] +protocols_definition.py:159: note: Following member(s) of "Concrete3_Bad4" have conflicts: +protocols_definition.py:159: note: val1: expected "Sequence[int]", got "Sequence[float]" +protocols_definition.py:160: error: Incompatible types in assignment (expression has type "Concrete3_Bad5", variable has type "Template3") [assignment] +protocols_definition.py:160: note: Following member(s) of "Concrete3_Bad5" have conflicts: +protocols_definition.py:160: note: val1: expected "Sequence[int]", got "list[int]" +protocols_definition.py:218: error: Incompatible types in assignment (expression has type "Concrete4_Bad1", variable has type "Template4") [assignment] +protocols_definition.py:218: note: Following member(s) of "Concrete4_Bad1" have conflicts: +protocols_definition.py:218: note: val1: expected "Sequence[float]", got "Callable[[], Sequence[int]]" +protocols_definition.py:219: error: Incompatible types in assignment (expression has type "Concrete4_Bad2", variable has type "Template4") [assignment] +protocols_definition.py:287: error: Incompatible types in assignment (expression has type "Concrete5_Bad3", variable has type "Template5") [assignment] +protocols_definition.py:287: note: Following member(s) of "Concrete5_Bad3" have conflicts: +protocols_definition.py:287: note: Expected: +protocols_definition.py:287: note: def method1(self, a: int, b: int) -> float +protocols_definition.py:287: note: Got: +protocols_definition.py:287: note: def method1(self, *, a: int, b: int) -> float +protocols_definition.py:289: error: Incompatible types in assignment (expression has type "Concrete5_Bad5", variable has type "Template5") [assignment] +protocols_definition.py:289: note: Following member(s) of "Concrete5_Bad5" have conflicts: +protocols_definition.py:289: note: Expected: +protocols_definition.py:289: note: def method1(self, a: int, b: int) -> float +protocols_definition.py:289: note: Got: +protocols_definition.py:289: note: def method1(self: Any, a: int, b: int) -> float +protocols_definition.py:339: error: Incompatible types in assignment (expression has type "Concrete6_Bad1", variable has type "Template6") [assignment] +protocols_definition.py:339: note: Protocol member Template6.val1 expected settable variable, got read-only attribute +protocols_definition.py:340: error: Incompatible types in assignment (expression has type "Concrete6_Bad2", variable has type "Template6") [assignment] +protocols_definition.py:340: note: Protocol member Template6.val1 expected settable variable, got read-only attribute +protocols_definition.py:341: error: Incompatible types in assignment (expression has type "Concrete6_Bad3", variable has type "Template6") [assignment] +protocols_definition.py:341: note: Protocol member Template6.val1 expected settable variable, got read-only attribute """ diff --git a/conformance/results/mypy/protocols_merging.toml b/conformance/results/mypy/protocols_merging.toml index 11b32c536..5433425a6 100644 --- a/conformance/results/mypy/protocols_merging.toml +++ b/conformance/results/mypy/protocols_merging.toml @@ -9,4 +9,5 @@ protocols_merging.py:53: note: __len__ protocols_merging.py:54: error: Incompatible types in assignment (expression has type "SCConcrete2", variable has type "SizedAndClosable3") [assignment] protocols_merging.py:68: error: All bases of a protocol must be protocols [misc] protocols_merging.py:83: error: Cannot instantiate abstract class "SizedAndClosable4" with abstract attribute "close" [abstract] +protocols_merging.py:84: error: Incompatible types in assignment (expression has type "SCConcrete1", variable has type "SizedAndClosable4") [assignment] """ diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index 40e101253..1842b0d7a 100644 --- a/conformance/results/mypy/version.toml +++ b/conformance/results/mypy/version.toml @@ -1,2 +1,2 @@ version = "mypy 1.8.0" -test_duration = 1.3135571479797363 +test_duration = 0.6594910621643066 diff --git a/conformance/results/pyre/annotations_generators.toml b/conformance/results/pyre/annotations_generators.toml index eb4111820..48bda1ea9 100644 --- a/conformance/results/pyre/annotations_generators.toml +++ b/conformance/results/pyre/annotations_generators.toml @@ -4,17 +4,19 @@ Does not report invalid return type for generator when function implicitly retur Incorrectly evaluates type of call to async generator. """ output = """ -annotations_generators.py:53:8 Incompatible return type [7]: Expected `Generator[A, B, C]` but got `Generator[typing.Any, typing.Any, bool]`. -annotations_generators.py:56:8 Incompatible return type [7]: Expected `Generator[A, B, C]` but got `Generator[int, typing.Any, typing.Any]`. -annotations_generators.py:65:8 Incompatible return type [7]: Expected `Generator[A, int, typing.Any]` but got `Generator[int, typing.Any, typing.Any]`. -annotations_generators.py:74:4 Incompatible return type [7]: Expected `Iterator[A]` but got `Generator[B, typing.Any, typing.Any]`. -annotations_generators.py:86:4 Incompatible return type [7]: Expected `int` but got `Generator[None, typing.Any, typing.Any]`. -annotations_generators.py:87:4 Incompatible return type [7]: Expected `int` but got `Generator[typing.Any, typing.Any, int]`. -annotations_generators.py:90:0 Incompatible async generator return type [57]: Expected return annotation to be AsyncGenerator or a superclass but got `int`. -annotations_generators.py:91:4 Incompatible return type [7]: Expected `int` but got `AsyncGenerator[None, typing.Any]`. -annotations_generators.py:117:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[A, None, typing.Any]`. -annotations_generators.py:118:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[int, None, typing.Any]`. -annotations_generators.py:134:4 Incompatible return type [7]: Expected `Generator[None, str, None]` but got `Generator[None, int, typing.Any]`. -annotations_generators.py:166:35 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[Type[Variable[_T_co](covariant)], Type[Variable[_T_contra](contravariant)]]` but got `Tuple[Type[str], None]`. -annotations_generators.py:173:35 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[Type[Variable[_T_co](covariant)], Type[Variable[_T_contra](contravariant)]]` but got `Tuple[Type[str], None]`. +annotations_generators.py:54:8 Incompatible return type [7]: Expected `Generator[A, B, C]` but got `Generator[typing.Any, typing.Any, bool]`. +annotations_generators.py:57:8 Incompatible return type [7]: Expected `Generator[A, B, C]` but got `Generator[int, typing.Any, typing.Any]`. +annotations_generators.py:66:8 Incompatible return type [7]: Expected `Generator[A, int, typing.Any]` but got `Generator[int, typing.Any, typing.Any]`. +annotations_generators.py:75:4 Incompatible return type [7]: Expected `Iterator[A]` but got `Generator[B, typing.Any, typing.Any]`. +annotations_generators.py:87:4 Incompatible return type [7]: Expected `int` but got `Generator[None, typing.Any, typing.Any]`. +annotations_generators.py:88:4 Incompatible return type [7]: Expected `int` but got `Generator[typing.Any, typing.Any, int]`. +annotations_generators.py:91:0 Incompatible async generator return type [57]: Expected return annotation to be AsyncGenerator or a superclass but got `int`. +annotations_generators.py:92:4 Incompatible return type [7]: Expected `int` but got `AsyncGenerator[None, typing.Any]`. +annotations_generators.py:118:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[A, None, typing.Any]`. +annotations_generators.py:119:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[int, None, typing.Any]`. +annotations_generators.py:135:4 Incompatible return type [7]: Expected `Generator[None, str, None]` but got `Generator[None, int, typing.Any]`. +annotations_generators.py:167:35 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[Type[Variable[_T_co](covariant)], Type[Variable[_T_contra](contravariant)]]` but got `Tuple[Type[str], None]`. +annotations_generators.py:174:35 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[Type[Variable[_T_co](covariant)], Type[Variable[_T_contra](contravariant)]]` but got `Tuple[Type[str], None]`. +annotations_generators.py:182:48 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[Type[Variable[_T_co](covariant)], Type[Variable[_T_contra](contravariant)], Type[Variable[_V_co](covariant)]]` but got `Tuple[object, object, typing.Any]`. +annotations_generators.py:182:58 Undefined attribute [16]: `AsyncIterator` has no attribute `__getitem__`. """ diff --git a/conformance/results/pyre/annotations_methods.toml b/conformance/results/pyre/annotations_methods.toml index 2146548eb..d93e17525 100644 --- a/conformance/results/pyre/annotations_methods.toml +++ b/conformance/results/pyre/annotations_methods.toml @@ -1,3 +1,6 @@ conformant = "Pass" +notes = """ +Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings. +""" output = """ """ diff --git a/conformance/results/pyre/directives_assert_type.toml b/conformance/results/pyre/directives_assert_type.toml index 157333cad..b83af4108 100644 --- a/conformance/results/pyre/directives_assert_type.toml +++ b/conformance/results/pyre/directives_assert_type.toml @@ -3,6 +3,6 @@ notes = """ Does not understand "assert_type". """ output = """ -directives_assert_type.py:30:4 Missing argument [20]: Call `assert_type` expects argument in position 0. -directives_assert_type.py:32:4 Too many arguments [19]: Call `assert_type` expects 2 positional arguments, 3 were provided. +directives_assert_type.py:31:4 Missing argument [20]: Call `assert_type` expects argument in position 0. +directives_assert_type.py:33:4 Too many arguments [19]: Call `assert_type` expects 2 positional arguments, 3 were provided. """ diff --git a/conformance/results/pyre/directives_no_type_check.toml b/conformance/results/pyre/directives_no_type_check.toml index 3dbb72581..639a79cb5 100644 --- a/conformance/results/pyre/directives_no_type_check.toml +++ b/conformance/results/pyre/directives_no_type_check.toml @@ -5,4 +5,7 @@ Does not honor @no_type_check decorator. output = """ directives_no_type_check.py:16:12 Unsupported operand [58]: `+` is not supported for operand types `int` and `str`. directives_no_type_check.py:17:4 Incompatible return type [7]: Expected `None` but got `int`. +directives_no_type_check.py:20:6 Incompatible parameter type [6]: In call `func1`, for 1st positional argument, expected `int` but got `bytes`. +directives_no_type_check.py:20:18 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `str` but got `bytes`. +directives_no_type_check.py:21:0 Missing argument [20]: Call `func1` expects argument `a`. """ diff --git a/conformance/results/pyre/directives_type_ignore_file1.toml b/conformance/results/pyre/directives_type_ignore_file1.toml new file mode 100644 index 000000000..2dc002af4 --- /dev/null +++ b/conformance/results/pyre/directives_type_ignore_file1.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Does not support file-level `#type: ignore` comment. +""" +output = """ +directives_type_ignore_file1.py:16:0 Incompatible variable type [9]: x is declared to have type `int` but is used as type `str`. +""" diff --git a/conformance/results/pyre/directives_type_ignore_file2.toml b/conformance/results/pyre/directives_type_ignore_file2.toml new file mode 100644 index 000000000..dba9f5dd6 --- /dev/null +++ b/conformance/results/pyre/directives_type_ignore_file2.toml @@ -0,0 +1,4 @@ +conformant = "Pass" +output = """ +directives_type_ignore_file2.py:14:0 Incompatible variable type [9]: x is declared to have type `int` but is used as type `str`. +""" diff --git a/conformance/results/pyre/overloads_basic.toml b/conformance/results/pyre/overloads_basic.toml index 82331534e..0dd93e644 100644 --- a/conformance/results/pyre/overloads_basic.toml +++ b/conformance/results/pyre/overloads_basic.toml @@ -3,6 +3,6 @@ notes = """ Does not reject a function with a single @overload signature. """ output = """ -overloads_basic.py:35:2 Incompatible parameter type [6]: In call `Bytes.__getitem__`, for 1st positional argument, expected `int` but got `str`. -overloads_basic.py:70:0 Missing overload implementation [42]: Overloaded function `func2` must have an implementation. +overloads_basic.py:37:2 Incompatible parameter type [6]: In call `Bytes.__getitem__`, for 1st positional argument, expected `int` but got `str`. +overloads_basic.py:75:0 Missing overload implementation [42]: Overloaded function `func2` must have an implementation. """ diff --git a/conformance/results/pyre/protocols_definition.toml b/conformance/results/pyre/protocols_definition.toml index 9894d4a3c..3f95938f1 100644 --- a/conformance/results/pyre/protocols_definition.toml +++ b/conformance/results/pyre/protocols_definition.toml @@ -9,15 +9,16 @@ Does not reject immutable frozen dataclass attribute in concrete class when prot """ output = """ protocols_definition.py:30:10 Incompatible parameter type [6]: In call `close_all`, for 1st positional argument, expected `Iterable[SupportsClose]` but got `Iterable[int]`. -protocols_definition.py:62:8 Undefined attribute [16]: `Template` has no attribute `temp`. -protocols_definition.py:110:0 Incompatible variable type [9]: v2_bad1 is declared to have type `Template2` but is used as type `Concrete2_Bad1`. -protocols_definition.py:111:0 Incompatible variable type [9]: v2_bad2 is declared to have type `Template2` but is used as type `Concrete2_Bad2`. -protocols_definition.py:151:0 Incompatible variable type [9]: v3_bad1 is declared to have type `Template3` but is used as type `Concrete3_Bad1`. -protocols_definition.py:154:0 Incompatible variable type [9]: v3_bad4 is declared to have type `Template3` but is used as type `Concrete3_Bad4`. -protocols_definition.py:213:0 Incompatible variable type [9]: v4_bad1 is declared to have type `Template4` but is used as type `Concrete4_Bad1`. -protocols_definition.py:214:0 Incompatible variable type [9]: v4_bad2 is declared to have type `Template4` but is used as type `Concrete4_Bad2`. -protocols_definition.py:275:0 Incompatible variable type [9]: v5_bad1 is declared to have type `Template5` but is used as type `Concrete5_Bad1`. -protocols_definition.py:276:0 Incompatible variable type [9]: v5_bad2 is declared to have type `Template5` but is used as type `Concrete5_Bad2`. -protocols_definition.py:277:0 Incompatible variable type [9]: v5_bad3 is declared to have type `Template5` but is used as type `Concrete5_Bad3`. -protocols_definition.py:278:0 Incompatible variable type [9]: v5_bad5 is declared to have type `Template5` but is used as type `Concrete5_Bad5`. +protocols_definition.py:67:8 Undefined attribute [16]: `Template` has no attribute `temp`. +protocols_definition.py:115:0 Incompatible variable type [9]: v2_bad1 is declared to have type `Template2` but is used as type `Concrete2_Bad1`. +protocols_definition.py:116:0 Incompatible variable type [9]: v2_bad2 is declared to have type `Template2` but is used as type `Concrete2_Bad2`. +protocols_definition.py:156:0 Incompatible variable type [9]: v3_bad1 is declared to have type `Template3` but is used as type `Concrete3_Bad1`. +protocols_definition.py:159:0 Incompatible variable type [9]: v3_bad4 is declared to have type `Template3` but is used as type `Concrete3_Bad4`. +protocols_definition.py:218:0 Incompatible variable type [9]: v4_bad1 is declared to have type `Template4` but is used as type `Concrete4_Bad1`. +protocols_definition.py:219:0 Incompatible variable type [9]: v4_bad2 is declared to have type `Template4` but is used as type `Concrete4_Bad2`. +protocols_definition.py:285:0 Incompatible variable type [9]: v5_bad1 is declared to have type `Template5` but is used as type `Concrete5_Bad1`. +protocols_definition.py:286:0 Incompatible variable type [9]: v5_bad2 is declared to have type `Template5` but is used as type `Concrete5_Bad2`. +protocols_definition.py:287:0 Incompatible variable type [9]: v5_bad3 is declared to have type `Template5` but is used as type `Concrete5_Bad3`. +protocols_definition.py:288:0 Incompatible variable type [9]: v5_bad4 is declared to have type `Template5` but is used as type `Concrete5_Bad4`. +protocols_definition.py:289:0 Incompatible variable type [9]: v5_bad5 is declared to have type `Template5` but is used as type `Concrete5_Bad5`. """ diff --git a/conformance/results/pyre/protocols_merging.toml b/conformance/results/pyre/protocols_merging.toml index e808fa798..ee1a86c18 100644 --- a/conformance/results/pyre/protocols_merging.toml +++ b/conformance/results/pyre/protocols_merging.toml @@ -7,4 +7,5 @@ protocols_merging.py:52:0 Incompatible variable type [9]: s6 is declared to have protocols_merging.py:53:0 Incompatible variable type [9]: s7 is declared to have type `SizedAndClosable2` but is used as type `SCConcrete2`. protocols_merging.py:54:0 Incompatible variable type [9]: s8 is declared to have type `SizedAndClosable3` but is used as type `SCConcrete2`. protocols_merging.py:83:4 Invalid class instantiation [45]: Cannot instantiate abstract class `SizedAndClosable4` with abstract method `close`. +protocols_merging.py:84:0 Incompatible variable type [9]: y is declared to have type `SizedAndClosable4` but is used as type `SCConcrete1`. """ diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml index b8ce5474c..1045fff1a 100644 --- a/conformance/results/pyre/version.toml +++ b/conformance/results/pyre/version.toml @@ -1,2 +1,2 @@ version = "pyre 0.9.19" -test_duration = 2.098888874053955 +test_duration = 2.1209452152252197 diff --git a/conformance/results/pyright/annotations_generators.toml b/conformance/results/pyright/annotations_generators.toml index 91fcdd77f..9104ee128 100644 --- a/conformance/results/pyright/annotations_generators.toml +++ b/conformance/results/pyright/annotations_generators.toml @@ -1,32 +1,32 @@ conformant = "Pass" output = """ -annotations_generators.py:53:16 - error: Expression of type "Literal[False]" cannot be assigned to return type "C" +annotations_generators.py:54:16 - error: Expression of type "Literal[False]" cannot be assigned to return type "C"   "Literal[False]" is incompatible with "C" (reportGeneralTypeIssues) -annotations_generators.py:56:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]" +annotations_generators.py:57:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]"   "Literal[3]" is incompatible with "A" (reportGeneralTypeIssues) -annotations_generators.py:50:21 - error: Function with declared return type "C" must return value on all code paths +annotations_generators.py:51:21 - error: Function with declared return type "C" must return value on all code paths   "None" is incompatible with "C" (reportGeneralTypeIssues) -annotations_generators.py:65:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]" +annotations_generators.py:66:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]"   "Literal[3]" is incompatible with "A" (reportGeneralTypeIssues) -annotations_generators.py:74:11 - error: Return type of generator function must be compatible with "Generator[B, Any, Any]" +annotations_generators.py:75:11 - error: Return type of generator function must be compatible with "Generator[B, Any, Any]"   "B" is incompatible with "A" (reportGeneralTypeIssues) -annotations_generators.py:86:11 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]" +annotations_generators.py:87:11 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]"   "Generator[None, Unknown, Unknown]" is incompatible with "int" (reportGeneralTypeIssues) -annotations_generators.py:85:21 - error: Return type of generator function must be compatible with "Generator[Any, Any, Any]" +annotations_generators.py:86:21 - error: Return type of generator function must be compatible with "Generator[Any, Any, Any]"   "Generator[Any, Any, Any]" is incompatible with "int" (reportGeneralTypeIssues) -annotations_generators.py:91:11 - error: Return type of async generator function must be compatible with "AsyncGenerator[None, Any]" +annotations_generators.py:92:11 - error: Return type of async generator function must be compatible with "AsyncGenerator[None, Any]"   "AsyncGenerator[None, Unknown, Unknown]" is incompatible with "int" (reportGeneralTypeIssues) -annotations_generators.py:90:27 - error: Return type of async generator function must be compatible with "AsyncGenerator[Any, Any]" +annotations_generators.py:91:27 - error: Return type of async generator function must be compatible with "AsyncGenerator[Any, Any]"   "AsyncGenerator[Any, Any, Any]" is incompatible with "int" (reportGeneralTypeIssues) -annotations_generators.py:117:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]" +annotations_generators.py:118:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]"   "Generator[A, Unknown, Unknown]" is incompatible with "Iterator[B]"     Type parameter "_T_co@Iterator" is covariant, but "A" is not a subtype of "B"       "A" is incompatible with "B" (reportGeneralTypeIssues) -annotations_generators.py:118:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]" +annotations_generators.py:119:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]"   "Generator[int, Unknown, Unknown]" is incompatible with "Iterator[B]"     Type parameter "_T_co@Iterator" is covariant, but "int" is not a subtype of "B"       "int" is incompatible with "B" (reportGeneralTypeIssues) -annotations_generators.py:134:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]" +annotations_generators.py:135:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]"   "Generator[None, int, Unknown]" is incompatible with "Generator[None, str, None]"     Type parameter "_SendT_contra@Generator" is contravariant, but "int" is not a supertype of "str"       "str" is incompatible with "int" (reportGeneralTypeIssues) diff --git a/conformance/results/pyright/annotations_methods.toml b/conformance/results/pyright/annotations_methods.toml index 2146548eb..3a22f5f82 100644 --- a/conformance/results/pyright/annotations_methods.toml +++ b/conformance/results/pyright/annotations_methods.toml @@ -1,3 +1,8 @@ conformant = "Pass" +notes = """ +Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings. +""" output = """ +annotations_methods.py:46:8 - error: Argument of type "A" cannot be assigned to parameter "self" of type "B" in function "copy" +  "A" is incompatible with "B" (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/directives_assert_type.toml b/conformance/results/pyright/directives_assert_type.toml index b7039e73c..ea8b7aa4a 100644 --- a/conformance/results/pyright/directives_assert_type.toml +++ b/conformance/results/pyright/directives_assert_type.toml @@ -2,7 +2,8 @@ conformant = "Pass" output = """ directives_assert_type.py:27:17 - error: "assert_type" mismatch: expected "int" but received "int | str" (reportGeneralTypeIssues) directives_assert_type.py:28:17 - error: "assert_type" mismatch: expected "int" but received "Any" (reportGeneralTypeIssues) -directives_assert_type.py:30:5 - error: "assert_type" expects two positional arguments -directives_assert_type.py:31:17 - error: "assert_type" mismatch: expected "int" but received "Literal['']" (reportGeneralTypeIssues) -directives_assert_type.py:32:5 - error: "assert_type" expects two positional arguments +directives_assert_type.py:29:17 - error: "assert_type" mismatch: expected "int" but received "Literal[4]" (reportGeneralTypeIssues) +directives_assert_type.py:31:5 - error: "assert_type" expects two positional arguments +directives_assert_type.py:32:17 - error: "assert_type" mismatch: expected "int" but received "Literal['']" (reportGeneralTypeIssues) +directives_assert_type.py:33:5 - error: "assert_type" expects two positional arguments """ diff --git a/conformance/results/pyright/directives_no_type_check.toml b/conformance/results/pyright/directives_no_type_check.toml index b921a6545..6bc67f59b 100644 --- a/conformance/results/pyright/directives_no_type_check.toml +++ b/conformance/results/pyright/directives_no_type_check.toml @@ -6,4 +6,9 @@ output = """ directives_no_type_check.py:16:9 - error: Operator "+" not supported for types "int" and "str" (reportGeneralTypeIssues) directives_no_type_check.py:17:12 - error: Expression of type "Literal[1]" cannot be assigned to return type "None"   "Literal[1]" is incompatible with "None" (reportGeneralTypeIssues) +directives_no_type_check.py:20:7 - error: Argument of type "Literal[b"invalid"]" cannot be assigned to parameter "a" of type "int" in function "func1" +  "Literal[b"invalid"]" is incompatible with "int" (reportGeneralTypeIssues) +directives_no_type_check.py:20:19 - error: Argument of type "Literal[b"arguments"]" cannot be assigned to parameter "b" of type "str" in function "func1" +  "Literal[b"arguments"]" is incompatible with "str" (reportGeneralTypeIssues) +directives_no_type_check.py:21:1 - error: Arguments missing for parameters "a", "b" (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/directives_type_ignore_file1.toml b/conformance/results/pyright/directives_type_ignore_file1.toml new file mode 100644 index 000000000..2146548eb --- /dev/null +++ b/conformance/results/pyright/directives_type_ignore_file1.toml @@ -0,0 +1,3 @@ +conformant = "Pass" +output = """ +""" diff --git a/conformance/results/pyright/directives_type_ignore_file2.toml b/conformance/results/pyright/directives_type_ignore_file2.toml new file mode 100644 index 000000000..37ecf19c9 --- /dev/null +++ b/conformance/results/pyright/directives_type_ignore_file2.toml @@ -0,0 +1,5 @@ +conformant = "Pass" +output = """ +directives_type_ignore_file2.py:14:10 - error: Expression of type "Literal['']" cannot be assigned to declared type "int" +  "Literal['']" is incompatible with "int" (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/overloads_basic.toml b/conformance/results/pyright/overloads_basic.toml index ad1074f59..7d79eea21 100644 --- a/conformance/results/pyright/overloads_basic.toml +++ b/conformance/results/pyright/overloads_basic.toml @@ -1,8 +1,8 @@ conformant = "Pass" output = """ -overloads_basic.py:35:1 - error: No overloads for "__getitem__" match the provided arguments (reportGeneralTypeIssues) -overloads_basic.py:35:1 - error: Argument of type "Literal['']" cannot be assigned to parameter "__s" of type "slice" in function "__getitem__" +overloads_basic.py:37:1 - error: No overloads for "__getitem__" match the provided arguments (reportGeneralTypeIssues) +overloads_basic.py:37:1 - error: Argument of type "Literal['']" cannot be assigned to parameter "__s" of type "slice" in function "__getitem__"   "Literal['']" is incompatible with "slice" (reportGeneralTypeIssues) -overloads_basic.py:60:5 - error: "func1" is marked as overload, but additional overloads are missing (reportGeneralTypeIssues) -overloads_basic.py:70:5 - error: "func2" is marked as overload, but no implementation is provided (reportGeneralTypeIssues) +overloads_basic.py:63:5 - error: "func1" is marked as overload, but additional overloads are missing (reportGeneralTypeIssues) +overloads_basic.py:75:5 - error: "func2" is marked as overload, but no implementation is provided (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/protocols_definition.toml b/conformance/results/pyright/protocols_definition.toml index 6475619f9..bd9150093 100644 --- a/conformance/results/pyright/protocols_definition.toml +++ b/conformance/results/pyright/protocols_definition.toml @@ -6,79 +6,84 @@ output = """ protocols_definition.py:30:12 - error: Argument of type "list[int]" cannot be assigned to parameter "things" of type "Iterable[SupportsClose]" in function "close_all"   "Literal[1]" is incompatible with protocol "SupportsClose"     "close" is not present (reportGeneralTypeIssues) -protocols_definition.py:62:14 - error: Instance or class variables within a Protocol class must be explicitly declared within the class body -protocols_definition.py:110:22 - error: Expression of type "Concrete2_Bad1" cannot be assigned to declared type "Template2" +protocols_definition.py:67:14 - error: Instance or class variables within a Protocol class must be explicitly declared within the class body +protocols_definition.py:115:22 - error: Expression of type "Concrete2_Bad1" cannot be assigned to declared type "Template2"   "Concrete2_Bad1" is incompatible with protocol "Template2"     "val1" is not present (reportGeneralTypeIssues) -protocols_definition.py:111:22 - error: Expression of type "Concrete2_Bad2" cannot be assigned to declared type "Template2" +protocols_definition.py:116:22 - error: Expression of type "Concrete2_Bad2" cannot be assigned to declared type "Template2"   "Concrete2_Bad2" is incompatible with protocol "Template2"     "val1" is invariant because it is mutable     "val1" is an incompatible type       "Sequence[float]" is incompatible with "Sequence[int]" (reportGeneralTypeIssues) -protocols_definition.py:112:22 - error: Expression of type "Concrete2_Bad3" cannot be assigned to declared type "Template2" +protocols_definition.py:117:22 - error: Expression of type "Concrete2_Bad3" cannot be assigned to declared type "Template2"   "Concrete2_Bad3" is incompatible with protocol "Template2"     "val1" is invariant because it is mutable     "val1" is an incompatible type       "list[int]" is incompatible with "Sequence[int]" (reportGeneralTypeIssues) -protocols_definition.py:151:22 - error: Expression of type "Concrete3_Bad1" cannot be assigned to declared type "Template3" +protocols_definition.py:156:22 - error: Expression of type "Concrete3_Bad1" cannot be assigned to declared type "Template3"   "Concrete3_Bad1" is incompatible with protocol "Template3"     "val1" is not present (reportGeneralTypeIssues) -protocols_definition.py:153:22 - error: Expression of type "Concrete3_Bad3" cannot be assigned to declared type "Template3" +protocols_definition.py:158:22 - error: Expression of type "Concrete3_Bad3" cannot be assigned to declared type "Template3"   "Concrete3_Bad3" is incompatible with protocol "Template3"     "val1" is invariant because it is mutable     "val1" is an incompatible type       "property" is incompatible with "Sequence[int]" (reportGeneralTypeIssues) -protocols_definition.py:154:22 - error: Expression of type "Concrete3_Bad4" cannot be assigned to declared type "Template3" +protocols_definition.py:159:22 - error: Expression of type "Concrete3_Bad4" cannot be assigned to declared type "Template3"   "Concrete3_Bad4" is incompatible with protocol "Template3"     "val1" is invariant because it is mutable     "val1" is an incompatible type       "Sequence[float]" is incompatible with "Sequence[int]" (reportGeneralTypeIssues) -protocols_definition.py:155:22 - error: Expression of type "Concrete3_Bad5" cannot be assigned to declared type "Template3" +protocols_definition.py:160:22 - error: Expression of type "Concrete3_Bad5" cannot be assigned to declared type "Template3"   "Concrete3_Bad5" is incompatible with protocol "Template3"     "val1" is invariant because it is mutable     "val1" is an incompatible type       "list[int]" is incompatible with "Sequence[int]" (reportGeneralTypeIssues) -protocols_definition.py:213:22 - error: Expression of type "Concrete4_Bad1" cannot be assigned to declared type "Template4" +protocols_definition.py:218:22 - error: Expression of type "Concrete4_Bad1" cannot be assigned to declared type "Template4"   "Concrete4_Bad1" is incompatible with protocol "Template4"     "val1" is an incompatible type       "function" is incompatible with "Sequence[float]" (reportGeneralTypeIssues) -protocols_definition.py:214:22 - error: Expression of type "Concrete4_Bad2" cannot be assigned to declared type "Template4" +protocols_definition.py:219:22 - error: Expression of type "Concrete4_Bad2" cannot be assigned to declared type "Template4"   "Concrete4_Bad2" is incompatible with protocol "Template4"     "val1" is not present (reportGeneralTypeIssues) -protocols_definition.py:266:17 - warning: Static methods should not take a "self" or "cls" parameter (reportSelfClsParameterName) -protocols_definition.py:275:22 - error: Expression of type "Concrete5_Bad1" cannot be assigned to declared type "Template5" +protocols_definition.py:276:17 - warning: Static methods should not take a "self" or "cls" parameter (reportSelfClsParameterName) +protocols_definition.py:285:22 - error: Expression of type "Concrete5_Bad1" cannot be assigned to declared type "Template5"   "Concrete5_Bad1" is incompatible with protocol "Template5"     "method1" is an incompatible type       Type "(a: Unknown, c: Unknown) -> int" cannot be assigned to type "(a: int, b: int) -> float"         Parameter name mismatch: "b" versus "c" (reportGeneralTypeIssues) -protocols_definition.py:276:22 - error: Expression of type "Concrete5_Bad2" cannot be assigned to declared type "Template5" +protocols_definition.py:286:22 - error: Expression of type "Concrete5_Bad2" cannot be assigned to declared type "Template5"   "Concrete5_Bad2" is incompatible with protocol "Template5"     "method1" is an incompatible type +      Type "(a: int, c: int) -> int" cannot be assigned to type "(a: int, b: int) -> float" +        Parameter name mismatch: "b" versus "c" (reportGeneralTypeIssues) +protocols_definition.py:287:22 - error: Expression of type "Concrete5_Bad3" cannot be assigned to declared type "Template5" +  "Concrete5_Bad3" is incompatible with protocol "Template5" +    "method1" is an incompatible type       Type "(*, a: int, b: int) -> float" cannot be assigned to type "(a: int, b: int) -> float"         Function accepts too many positional parameters; expected 0 but received 2           Keyword parameter "a" is missing in destination           Keyword parameter "b" is missing in destination (reportGeneralTypeIssues) -protocols_definition.py:277:22 - error: Expression of type "Concrete5_Bad3" cannot be assigned to declared type "Template5" -  "Concrete5_Bad3" is incompatible with protocol "Template5" +protocols_definition.py:288:22 - error: Expression of type "Concrete5_Bad4" cannot be assigned to declared type "Template5" +  "Concrete5_Bad4" is incompatible with protocol "Template5"     "method1" is an incompatible type       Type "(a: int, b: int, /) -> float" cannot be assigned to type "(a: int, b: int) -> float"         Position-only parameter mismatch; parameter "a" is not position-only         Position-only parameter mismatch; parameter "b" is not position-only         Position-only parameter mismatch; expected 2 but received 0 (reportGeneralTypeIssues) -protocols_definition.py:278:22 - error: Expression of type "Concrete5_Bad5" cannot be assigned to declared type "Template5" +protocols_definition.py:289:22 - error: Expression of type "Concrete5_Bad5" cannot be assigned to declared type "Template5"   "Concrete5_Bad5" is incompatible with protocol "Template5"     "method1" is an incompatible type       Type "(self: Unknown, a: int, b: int) -> float" cannot be assigned to type "(a: int, b: int) -> float"         Parameter name mismatch: "a" versus "self"         Parameter name mismatch: "b" versus "a" (reportGeneralTypeIssues) -protocols_definition.py:328:22 - error: Expression of type "Concrete6_Bad1" cannot be assigned to declared type "Template6" +protocols_definition.py:339:22 - error: Expression of type "Concrete6_Bad1" cannot be assigned to declared type "Template6"   "Concrete6_Bad1" is incompatible with protocol "Template6"     "val1" is an incompatible type       Property setter method is missing (reportGeneralTypeIssues) -protocols_definition.py:329:22 - error: Expression of type "Concrete6_Bad2" cannot be assigned to declared type "Template6" +protocols_definition.py:340:22 - error: Expression of type "Concrete6_Bad2" cannot be assigned to declared type "Template6"   "Concrete6_Bad2" is incompatible with protocol "Template6"     "val1" is writable in protocol (reportGeneralTypeIssues) -protocols_definition.py:330:22 - error: Expression of type "Concrete6_Bad3" cannot be assigned to declared type "Template6" +protocols_definition.py:341:22 - error: Expression of type "Concrete6_Bad3" cannot be assigned to declared type "Template6"   "Concrete6_Bad3" is incompatible with protocol "Template6"     "val1" is writable in protocol (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/protocols_merging.toml b/conformance/results/pyright/protocols_merging.toml index eb2b31d32..3a1308853 100644 --- a/conformance/results/pyright/protocols_merging.toml +++ b/conformance/results/pyright/protocols_merging.toml @@ -11,4 +11,6 @@ protocols_merging.py:54:25 - error: Expression of type "SCConcrete2" cannot be a protocols_merging.py:68:16 - error: Protocol class "type[BadProto]" cannot derive from non-protocol class "type[SizedAndClosable3]" protocols_merging.py:83:5 - error: Cannot instantiate abstract class "SizedAndClosable4"   "SizedAndClosable4.close" is abstract (reportGeneralTypeIssues) +protocols_merging.py:84:24 - error: Expression of type "SCConcrete1" cannot be assigned to declared type "SizedAndClosable4" +  "SCConcrete1" is incompatible with "SizedAndClosable4" (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index f5bef6ecc..60b29ec76 100644 --- a/conformance/results/pyright/version.toml +++ b/conformance/results/pyright/version.toml @@ -1,2 +1,2 @@ version = "pyright 1.1.344" -test_duration = 1.2716259956359863 +test_duration = 1.2410261631011963 diff --git a/conformance/results/pytype/annotations_generators.toml b/conformance/results/pytype/annotations_generators.toml index a596cdbed..c08eb1d06 100644 --- a/conformance/results/pytype/annotations_generators.toml +++ b/conformance/results/pytype/annotations_generators.toml @@ -5,33 +5,36 @@ Reports invalid error when return type of generator is annotated as a compatible Does not report type violation in `yield from` statement. """ output = """ -File "annotations_generators.py", line 53, in generator2: bad return type [bad-return-type] +File "annotations_generators.py", line 54, in generator2: bad return type [bad-return-type] Expected: C Actually returned: bool -File "annotations_generators.py", line 56, in generator2: bad return type [bad-return-type] +File "annotations_generators.py", line 57, in generator2: bad return type [bad-return-type] Expected: C Actually returned: None -File "annotations_generators.py", line 56, in generator2: bad return type [bad-return-type] +File "annotations_generators.py", line 57, in generator2: bad return type [bad-return-type] Expected: A Actually returned: int -File "annotations_generators.py", line 65, in generator3: bad return type [bad-return-type] +File "annotations_generators.py", line 66, in generator3: bad return type [bad-return-type] Expected: A Actually returned: int -File "annotations_generators.py", line 74, in generator5: bad return type [bad-return-type] +File "annotations_generators.py", line 75, in generator5: bad return type [bad-return-type] Expected: A Actually returned: B -File "annotations_generators.py", line 85, in : Bad return type 'int' for generator function generator8 [bad-yield-annotation] +File "annotations_generators.py", line 86, in : Bad return type 'int' for generator function generator8 [bad-yield-annotation] Expected Generator, Iterable or Iterator -File "annotations_generators.py", line 90, in : Bad return type 'int' for async generator function generator9 [bad-yield-annotation] +File "annotations_generators.py", line 91, in : Bad return type 'int' for async generator function generator9 [bad-yield-annotation] Expected AsyncGenerator, AsyncIterable or AsyncIterator -File "annotations_generators.py", line 99, in : Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation] +File "annotations_generators.py", line 100, in : Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation] Expected Generator, Iterable or Iterator -File "annotations_generators.py", line 108, in : Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation] +File "annotations_generators.py", line 109, in : Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation] Expected AsyncGenerator, AsyncIterable or AsyncIterator -File "annotations_generators.py", line 117, in generator18: bad return type [bad-return-type] +File "annotations_generators.py", line 118, in generator18: bad return type [bad-return-type] Expected: B Actually returned: A -File "annotations_generators.py", line 118, in generator18: bad return type [bad-return-type] +File "annotations_generators.py", line 119, in generator18: bad return type [bad-return-type] Expected: B Actually returned: A +File "annotations_generators.py", line 182, in : Callable[[], AsyncIterator[int]] [assert-type] + Expected: Callable[[], Coroutine[Any, Any, AsyncIterator[int]]] + Actual: Callable[[], AsyncIterator[int]] """ diff --git a/conformance/results/pytype/annotations_methods.toml b/conformance/results/pytype/annotations_methods.toml index 2146548eb..8feb2032f 100644 --- a/conformance/results/pytype/annotations_methods.toml +++ b/conformance/results/pytype/annotations_methods.toml @@ -1,3 +1,9 @@ conformant = "Pass" +notes = """ +Type evaluation differs from other type checkers because of ambiguity in the spec related to method bindings. +""" output = """ +File "annotations_methods.py", line 42, in : B [assert-type] + Expected: A + Actual: B """ diff --git a/conformance/results/pytype/directives_assert_type.toml b/conformance/results/pytype/directives_assert_type.toml index a5584f52d..caec764c9 100644 --- a/conformance/results/pytype/directives_assert_type.toml +++ b/conformance/results/pytype/directives_assert_type.toml @@ -6,13 +6,13 @@ File "directives_assert_type.py", line 27, in func1: Union[int, str] [assert-typ File "directives_assert_type.py", line 28, in func1: Any [assert-type] Expected: int Actual: Any -File "directives_assert_type.py", line 30, in func1: Function assert_type expects 2 arg(s), got 0 [wrong-arg-count] +File "directives_assert_type.py", line 31, in func1: Function assert_type expects 2 arg(s), got 0 [wrong-arg-count] Expected: (variable, type) Actually passed: () -File "directives_assert_type.py", line 31, in func1: str [assert-type] +File "directives_assert_type.py", line 32, in func1: str [assert-type] Expected: int Actual: str -File "directives_assert_type.py", line 32, in func1: Function assert_type expects 2 arg(s), got 3 [wrong-arg-count] +File "directives_assert_type.py", line 33, in func1: Function assert_type expects 2 arg(s), got 3 [wrong-arg-count] Expected: (variable, type) Actually passed: (variable, type, _) """ diff --git a/conformance/results/pytype/directives_no_type_check.toml b/conformance/results/pytype/directives_no_type_check.toml index ade858621..81bfe75b3 100644 --- a/conformance/results/pytype/directives_no_type_check.toml +++ b/conformance/results/pytype/directives_no_type_check.toml @@ -8,4 +8,10 @@ File "directives_no_type_check.py", line 16, in func1: unsupported operand type( File "directives_no_type_check.py", line 17, in func1: bad return type [bad-return-type] Expected: None Actually returned: int +File "directives_no_type_check.py", line 20, in : Function func1 was called with the wrong arguments [wrong-arg-types] + Expected: (a: int, ...) + Actually passed: (a: bytes, ...) +File "directives_no_type_check.py", line 21, in : Missing parameter 'a' in call to function func1 [missing-parameter] + Expected: (a, b) + Actually passed: () """ diff --git a/conformance/results/pytype/directives_type_ignore_file1.toml b/conformance/results/pytype/directives_type_ignore_file1.toml new file mode 100644 index 000000000..2146548eb --- /dev/null +++ b/conformance/results/pytype/directives_type_ignore_file1.toml @@ -0,0 +1,3 @@ +conformant = "Pass" +output = """ +""" diff --git a/conformance/results/pytype/directives_type_ignore_file2.toml b/conformance/results/pytype/directives_type_ignore_file2.toml new file mode 100644 index 000000000..fe1d892b9 --- /dev/null +++ b/conformance/results/pytype/directives_type_ignore_file2.toml @@ -0,0 +1,6 @@ +conformant = "Partial" +notes = """ +Does not ignore `# type: ignore` if it occurs after docstrings in the file. +""" +output = """ +""" diff --git a/conformance/results/pytype/overloads_basic.toml b/conformance/results/pytype/overloads_basic.toml index f8780bdbb..24e7a5708 100644 --- a/conformance/results/pytype/overloads_basic.toml +++ b/conformance/results/pytype/overloads_basic.toml @@ -4,12 +4,12 @@ Does not reject a function with a single @overload signature. Does not reject a function with @overload signature but no implementation. """ output = """ -File "overloads_basic.py", line 30, in __getitem__: bad return type [bad-return-type] +File "overloads_basic.py", line 31, in __getitem__: bad return type [bad-return-type] Expected: int Actually returned: bytes -File "overloads_basic.py", line 35, in : unsupported operand type(s) for item retrieval: Bytes and str [unsupported-operands] +File "overloads_basic.py", line 37, in : unsupported operand type(s) for item retrieval: Bytes and str [unsupported-operands] Function __getitem__ on Bytes expects int -File "overloads_basic.py", line 55, in map: bad return type [bad-return-type] +File "overloads_basic.py", line 58, in map: bad return type [bad-return-type] Expected: Iterator Actually returned: None Attributes of protocol Iterator[S] are not implemented on None: __next__ diff --git a/conformance/results/pytype/protocols_definition.toml b/conformance/results/pytype/protocols_definition.toml index 474dfaf09..aba256390 100644 --- a/conformance/results/pytype/protocols_definition.toml +++ b/conformance/results/pytype/protocols_definition.toml @@ -23,27 +23,27 @@ File "protocols_definition.py", line 30, in : Function close_all was cal File "protocols_definition.py", line 45, in third: bad return type [bad-return-type] Expected: int Actually returned: None -File "protocols_definition.py", line 110, in : Type annotation for v2_bad1 does not match type of assignment [annotation-type-mismatch] +File "protocols_definition.py", line 115, in : Type annotation for v2_bad1 does not match type of assignment [annotation-type-mismatch] Annotation: Template2 Assignment: Concrete2_Bad1 Attributes of protocol Template2 are not implemented on Concrete2_Bad1: val1 -File "protocols_definition.py", line 111, in : Type annotation for v2_bad2 does not match type of assignment [annotation-type-mismatch] +File "protocols_definition.py", line 116, in : Type annotation for v2_bad2 does not match type of assignment [annotation-type-mismatch] Annotation: Template2 Assignment: Concrete2_Bad2 Attribute val1 of protocol Template2 has wrong type in Concrete2_Bad2: expected Sequence[int], got Sequence[float] -File "protocols_definition.py", line 151, in : Type annotation for v3_bad1 does not match type of assignment [annotation-type-mismatch] +File "protocols_definition.py", line 156, in : Type annotation for v3_bad1 does not match type of assignment [annotation-type-mismatch] Annotation: Template3 Assignment: Concrete3_Bad1 Attributes of protocol Template3 are not implemented on Concrete3_Bad1: val1 -File "protocols_definition.py", line 154, in : Type annotation for v3_bad4 does not match type of assignment [annotation-type-mismatch] +File "protocols_definition.py", line 159, in : Type annotation for v3_bad4 does not match type of assignment [annotation-type-mismatch] Annotation: Template3 Assignment: Concrete3_Bad4 Attribute val1 of protocol Template3 has wrong type in Concrete3_Bad4: expected Sequence[int], got Sequence[float] -File "protocols_definition.py", line 213, in : Type annotation for v4_bad1 does not match type of assignment [annotation-type-mismatch] +File "protocols_definition.py", line 218, in : Type annotation for v4_bad1 does not match type of assignment [annotation-type-mismatch] Annotation: Template4 Assignment: Concrete4_Bad1 Attribute val1 of protocol Template4 has wrong type in Concrete4_Bad1: expected Sequence[float], got Callable[[Any], Sequence[int]] -File "protocols_definition.py", line 214, in : Type annotation for v4_bad2 does not match type of assignment [annotation-type-mismatch] +File "protocols_definition.py", line 219, in : Type annotation for v4_bad2 does not match type of assignment [annotation-type-mismatch] Annotation: Template4 Assignment: Concrete4_Bad2 Attributes of protocol Template4 are not implemented on Concrete4_Bad2: val1 diff --git a/conformance/results/pytype/protocols_merging.toml b/conformance/results/pytype/protocols_merging.toml index 1dad4da15..3b58f10d0 100644 --- a/conformance/results/pytype/protocols_merging.toml +++ b/conformance/results/pytype/protocols_merging.toml @@ -16,4 +16,7 @@ File "protocols_merging.py", line 54, in : Type annotation for s8 does n Annotation: SizedAndClosable3 Assignment: SCConcrete2 File "protocols_merging.py", line 83, in : Can't instantiate SizedAndClosable4 with abstract methods close [not-instantiable] +File "protocols_merging.py", line 84, in : Type annotation for y does not match type of assignment [annotation-type-mismatch] + Annotation: SizedAndClosable4 + Assignment: SCConcrete1 """ diff --git a/conformance/results/pytype/qualifiers_final_decorator.toml b/conformance/results/pytype/qualifiers_final_decorator.toml index 9b2ce99b8..852701ff5 100644 --- a/conformance/results/pytype/qualifiers_final_decorator.toml +++ b/conformance/results/pytype/qualifiers_final_decorator.toml @@ -13,9 +13,9 @@ File "qualifiers_final_decorator.py", line 21, in : Cannot subclass fina File "qualifiers_final_decorator.py", line 52, in method4: bad return type [bad-return-type] Expected: str Actually returned: int -File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method2, defined in base class Base2 [final-error] File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method3, defined in base class Base2 [final-error] File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method1, defined in base class Base2 [final-error] +File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method2, defined in base class Base2 [final-error] File "qualifiers_final_decorator.py", line 55, in : Class Derived2 overrides final method method4, defined in base class Base2 [final-error] File "qualifiers_final_decorator.py", line 76, in method4: bad return type [bad-return-type] Expected: str diff --git a/conformance/results/pytype/version.toml b/conformance/results/pytype/version.toml index 6ab250adc..30f7c2a2f 100644 --- a/conformance/results/pytype/version.toml +++ b/conformance/results/pytype/version.toml @@ -1,2 +1,2 @@ version = "pytype 2023.12.18" -test_duration = 24.716844081878662 +test_duration = 26.710652112960815 diff --git a/conformance/results/results.html b/conformance/results/results.html index 187ad938d..2f4ca5a1d 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -127,7 +127,7 @@

Python Type System Conformance Test Results

-
mypy 1.8.0(1.31sec) +
mypy 1.8.0(0.66sec)
@@ -136,7 +136,7 @@

Python Type System Conformance Test Results

- + + +
     annotations_coroutinesPass
     annotations_forward_refsPartialDoes not report error for a forward reference that is not enclosed in quotes.
Does not report error for use of quoted type with "|" operator (runtime error).
Incorrectly generates error for quoted type defined in class scope.
     annotations_generatorsPartialDoes not report incompatible Generator type in `yield from` statement.
     annotations_methodsPass
     annotations_methodsPassType evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
     annotations_typeexprPass
@@ -248,10 +248,12 @@

Python Type System Conformance Test Results

     directives_reveal_typePass
     directives_type_checkingPass
     directives_type_ignorePartialDoes not honor "# type: ignore" comment if comment includes additional text.
     directives_type_ignore_file1Pass
     directives_type_ignore_file2Pass
     directives_version_platformPassDoes not understand three-element form of sys.version checks.
Does not understand os.name checks.
-
pyright 1.1.344(1.27sec) +
pyright 1.1.344(1.24sec)
@@ -260,7 +262,7 @@

Python Type System Conformance Test Results

- + + +
     annotations_coroutinesPass
     annotations_forward_refsPass
     annotations_generatorsPass
     annotations_methodsPass
     annotations_methodsPassType evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
     annotations_typeexprPass
@@ -372,10 +374,12 @@

Python Type System Conformance Test Results

     directives_reveal_typePass
     directives_type_checkingPass
     directives_type_ignorePass
     directives_type_ignore_file1Pass
     directives_type_ignore_file2Pass
     directives_version_platformPass
-
pyre 0.9.19(2.10sec) +
pyre 0.9.19(2.12sec)
@@ -384,7 +388,7 @@

Python Type System Conformance Test Results

- + + +
     annotations_coroutinesPartialDoes not evaluate correct type for async function.
     annotations_forward_refsPartialDoes not report error for a forward reference that is not enclosed in quotes.
Does not report error for use of quoted type with "|" operator (runtime error).
Does not reject f-string in quoted type annotation.
Incorrectly generates error for quoted type defined in class scope.
Does not generate error for unquoted type defined in class scope.
     annotations_generatorsPartialDoes not report invalid return type for generator when function implicitly returns None.
Incorrectly evaluates type of call to async generator.
     annotations_methodsPass
     annotations_methodsPassType evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
     annotations_typeexprPass
@@ -496,10 +500,12 @@

Python Type System Conformance Test Results

     directives_reveal_typeUnsupportedDoes not understand reveal_type call.
     directives_type_checkingPass
     directives_type_ignorePass
     directives_type_ignore_file1UnsupportedDoes not support file-level `#type: ignore` comment.
     directives_type_ignore_file2Pass
     directives_version_platformPartialDoes not support sys.platform checks.
Does not support os.name checks.
-
pytype 2023.12.18(24.72sec) +
pytype 2023.12.18(26.71sec)
@@ -508,7 +514,7 @@

Python Type System Conformance Test Results

- + + +
     annotations_coroutinesPartialDoes not evaluate correct type for async function.
     annotations_forward_refsPartialDoes not reject some illegal type expression forms when quoted.
Incorrectly generates error for quoted type defined in class scope.
Evaluates incorrect type for class variable annotated with quoted type expression.
     annotations_generatorsPartialDoes not report invalid return type for generator when function implicitly returns None.
Reports invalid error when return type of generator is annotated as a compatible protocol.
Does not report type violation in `yield from` statement.
     annotations_methodsPass
     annotations_methodsPassType evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
     annotations_typeexprPartialDoes not reject call expressions in type annotation.
Does not reject call lambda expression in type annotation.
Does not reject list expression in type annotation.
Does not reject ternary expression in type annotation.
Does not reject f-string in type annotation.
Does not reject module in type annotation.
@@ -620,6 +626,8 @@

Python Type System Conformance Test Results

     directives_reveal_typePartialDoes not reject call to reveal_type with zero arguments.
Does not reject call to reveal_type with too many arguments.
     directives_type_checkingPass
     directives_type_ignorePartialDoes not honor "# type: ignore" comment if comment includes additional text.
     directives_type_ignore_file1Pass
     directives_type_ignore_file2PartialDoes not ignore `# type: ignore` if it occurs after docstrings in the file.
     directives_version_platformPassDoes not understand three-element form of sys.version checks.
Does not understand os.name checks.
diff --git a/conformance/tests/annotations_coroutines.py b/conformance/tests/annotations_coroutines.py index 186c3c495..b2200f6fe 100644 --- a/conformance/tests/annotations_coroutines.py +++ b/conformance/tests/annotations_coroutines.py @@ -1,5 +1,5 @@ """ -Tests for annotating generators and coroutines. +Tests for annotating coroutines. """ # Specification: https://typing.readthedocs.io/en/latest/spec/annotations.html#annotating-generator-functions-and-coroutines diff --git a/conformance/tests/annotations_forward_refs.py b/conformance/tests/annotations_forward_refs.py index 0d90a7d56..43f93f48a 100644 --- a/conformance/tests/annotations_forward_refs.py +++ b/conformance/tests/annotations_forward_refs.py @@ -19,8 +19,8 @@ def func1( assert_type(p4, list[ClassA | int]) -bad1: ClassA # Type error: requires quotes -bad2: list[ClassA] # Type error: requires quotes +bad1: ClassA # Runtime error: requires quotes +bad2: list[ClassA] # Runtime error: requires quotes bad3: "ClassA" | int # Runtime error bad4: int | "ClassA" # Runtime error diff --git a/conformance/tests/annotations_generators.py b/conformance/tests/annotations_generators.py index 0803b7d74..9b4373020 100644 --- a/conformance/tests/annotations_generators.py +++ b/conformance/tests/annotations_generators.py @@ -14,10 +14,11 @@ AsyncIterable, AsyncIterator, Awaitable, + Callable, + Coroutine, Generator, Iterable, Iterator, - Literal, Protocol, TypeVar, assert_type, @@ -172,3 +173,18 @@ async def generator28() -> AsyncIterator[str]: v1 = generator26(data) assert_type(v1, AsyncGenerator[str, None]) return v1 + + +async def generator29() -> AsyncIterator[int]: + raise NotImplementedError + + +assert_type(generator29, Callable[[], Coroutine[Any, Any, AsyncIterator[int]]]) + + +async def generator30() -> AsyncIterator[int]: + raise NotImplementedError + yield + + +assert_type(generator30, Callable[[], AsyncIterator[int]]) diff --git a/conformance/tests/annotations_methods.py b/conformance/tests/annotations_methods.py index 49df6b64a..b304cb8e9 100644 --- a/conformance/tests/annotations_methods.py +++ b/conformance/tests/annotations_methods.py @@ -18,6 +18,10 @@ def copy(self: T) -> T: def factory(cls: type[T]) -> T: return cls() + @staticmethod + def static_method(val: type[T]) -> T: + return val() + class B(A): ... @@ -25,6 +29,23 @@ class B(A): assert_type(A().copy(), A) assert_type(A.factory(), A) +assert_type(A.copy(A()), A) +assert_type(B.copy(B()), B) assert_type(B().copy(), B) assert_type(B.factory(), B) + +# This case is ambiguous in the spec, which does not indicate when +# type binding should be performed. Currently, pyright evaluates +# A here, but mypy evaluates B. Since the spec is not clear, both +# of these are currently acceptable answers. +assert_type(A.copy(B()), A) + +# Similarly, this case is ambiguous in the spec. Pyright currently +# generates a type error here, but mypy accepts this. +B.copy(A()) # Type error + +assert_type(A.static_method(A), A) +assert_type(A.static_method(B), B) +assert_type(B.static_method(B), B) +assert_type(B.static_method(A), A) diff --git a/conformance/tests/directives_assert_type.py b/conformance/tests/directives_assert_type.py index 7b9bb6f11..626a6caf8 100644 --- a/conformance/tests/directives_assert_type.py +++ b/conformance/tests/directives_assert_type.py @@ -26,6 +26,7 @@ def func1( assert_type(a, int) # Error: Type mismatch assert_type(c, int) # Error: Type mismatch + assert_type(e, int) # Error: Type mismatch assert_type() # Error: not enough arguments assert_type("", int) # Error: wrong argument type diff --git a/conformance/tests/directives_no_type_check.py b/conformance/tests/directives_no_type_check.py index c42b6b3e8..f62a7a1e7 100644 --- a/conformance/tests/directives_no_type_check.py +++ b/conformance/tests/directives_no_type_check.py @@ -17,3 +17,5 @@ def func1(a: int, b: str) -> None: return 1 # No error should be reported +func1(b"invalid", b"arguments") # No error should be reported +func1() # No error should be reported diff --git a/conformance/tests/directives_type_ignore.py b/conformance/tests/directives_type_ignore.py index e7ba8eb59..b96d23aea 100644 --- a/conformance/tests/directives_type_ignore.py +++ b/conformance/tests/directives_type_ignore.py @@ -12,3 +12,9 @@ # The following type violation should be suppressed. z: int = "" # type: ignore[additional_stuff] + +# > In some cases, linting tools or other comments may be needed on the same +# > line as a type comment. In these cases, the type comment should be before +# > other comments and linting markers. + +a: int = "" # type: ignore # other comment diff --git a/conformance/tests/directives_type_ignore_file1.py b/conformance/tests/directives_type_ignore_file1.py new file mode 100644 index 000000000..e89e97102 --- /dev/null +++ b/conformance/tests/directives_type_ignore_file1.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +# type: ignore + +""" +Tests a file-level type ignore comment. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#type-ignore-comments + +# > A # type: ignore comment on a line by itself at the top of a file, before any +# > docstrings, imports, or other executable code, silences all errors in the file. +# > Blank lines and other comments, such as shebang lines and coding cookies, may +# > precede the # type: ignore comment. + +x: int = "" # No error should be reported diff --git a/conformance/tests/directives_type_ignore_file2.py b/conformance/tests/directives_type_ignore_file2.py new file mode 100644 index 000000000..c3ba86c00 --- /dev/null +++ b/conformance/tests/directives_type_ignore_file2.py @@ -0,0 +1,14 @@ +""" +Tests a file-level type ignore comment. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/directives.html#type-ignore-comments + +# type: ignore + +# > A # type: ignore comment on a line by itself at the top of a file, before any +# > docstrings, imports, or other executable code, silences all errors in the file. +# > Blank lines and other comments, such as shebang lines and coding cookies, may +# > precede the # type: ignore comment. + +x: int = "" # Error should be reported because comment is not at top of file. diff --git a/conformance/tests/overloads_basic.py b/conformance/tests/overloads_basic.py index bf5dbb72b..cfd6a91ca 100644 --- a/conformance/tests/overloads_basic.py +++ b/conformance/tests/overloads_basic.py @@ -5,13 +5,14 @@ # Specification: https://typing.readthedocs.io/en/latest/spec/overload.html#overload # Note: The behavior of @overload is severely under-specified by PEP 484 leading -# to significant convergence in behavior across type checkers. This is something +# to significant divergence in behavior across type checkers. This is something # we will likely want to address in a future update to the typing spec. For now, # this conformance test will cover only the most basic functionality described # in PEP 484. from typing import Any, Callable, Iterable, Iterator, TypeVar, assert_type, overload + class Bytes: ... @@ -29,10 +30,11 @@ def __getitem__(self, __i_or_s: int | slice) -> int | bytes: else: return b"" + b = Bytes() assert_type(b[0], int) -assert_type(b[0: 1], bytes) -b[""] # Type error: no matching overload +assert_type(b[0:1], bytes) +b[""] # Type error: no matching overload T1 = TypeVar("T1") @@ -51,13 +53,16 @@ def map( ) -> Iterator[S]: ... + def map(func: Any, iter1: Any, iter2: Any = ...) -> Any: pass # At least two overload signatures should be provided. @overload -def func1() -> None: ... # Type error: At least two overloads must be present +def func1() -> None: + ... # Type error: At least two overloads must be present + def func1() -> None: pass @@ -67,7 +72,10 @@ def func1() -> None: # > followed by exactly one non-@overload-decorated definition (for the same # > function/method). @overload -def func2(x: int) -> int: ... # Type error: no implementation +def func2(x: int) -> int: + ... # Type error: no implementation + @overload -def func2(x: str) -> str: ... +def func2(x: str) -> str: + ... diff --git a/conformance/tests/protocols_definition.py b/conformance/tests/protocols_definition.py index 1b5b5a6cd..d54ce16fb 100644 --- a/conformance/tests/protocols_definition.py +++ b/conformance/tests/protocols_definition.py @@ -48,6 +48,10 @@ def third() -> int: def fourth(cls) -> int: ... + @property + def fifth(self) -> int: + ... + # > To define a protocol variable, one can use PEP 526 variable annotations # > in the class body. Additional attributes only defined in the body of a @@ -59,6 +63,7 @@ class Template(Protocol): value: int = 0 # This one too (with default) def method(self) -> None: + self.name = "name" # OK self.temp: list[int] = [] # Type error: use of self variables not allowed @@ -252,11 +257,16 @@ def method1(self, a, c) -> int: class Concrete5_Bad2: - def method1(self, *, a: int, b: int) -> float: + def method1(self, a: int, c: int) -> int: return 0 class Concrete5_Bad3: + def method1(self, *, a: int, b: int) -> float: + return 0 + + +class Concrete5_Bad4: def method1(self, a: int, b: int, /) -> float: return 0 @@ -275,6 +285,7 @@ def method1(self, a: int, b: int) -> float: v5_bad1: Template5 = Concrete5_Bad1() # Type error v5_bad2: Template5 = Concrete5_Bad2() # Type error v5_bad3: Template5 = Concrete5_Bad3() # Type error +v5_bad4: Template5 = Concrete5_Bad4() # Type error v5_bad5: Template5 = Concrete5_Bad5() # Type error diff --git a/conformance/tests/protocols_merging.py b/conformance/tests/protocols_merging.py index 25fb635ff..1dc00648f 100644 --- a/conformance/tests/protocols_merging.py +++ b/conformance/tests/protocols_merging.py @@ -81,3 +81,4 @@ def close(self) -> None: x = SizedAndClosable4() # Type error: cannot instantiate abstract class +y: SizedAndClosable4 = SCConcrete1() # Type error