From e69405143a428f11f33ad54900221dafe23a89d0 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 30 Dec 2023 00:31:57 -0700 Subject: [PATCH 1/9] Added link to conformance results. Added tests for `@final` decorator. Added tests for `Final` annotation. Updated pyright test results for latest version (1.1.344). Added tests for Annotated. Added tests for @override decorator. Added tests for "Type checker directives" section of spec. Added minimal tests for `@overload`. Added tests for the "Special types in annotations" section of the typing spec. Added conformance tests for the "Protocols" section of the type specification. Added tests for PEP 695 type parameter functionality. Improved error recovery and reporting for test tool if it cannot decode ".toml" file. Added conformance tests for TypeVarTuple. Added conformance tests for ParamSpec. Added tests for "Variance" section of Generics chapter. --- .../mypy/generics_paramspec_basic.toml | 18 ++ .../mypy/generics_paramspec_components.toml | 23 +++ .../mypy/generics_paramspec_semantics.toml | 14 ++ .../generics_paramspec_specialization.toml | 8 + .../mypy/generics_syntax_autovariance.toml | 2 + .../mypy/generics_syntax_compatibility.toml | 14 ++ .../mypy/generics_syntax_declarations.toml | 34 +++ .../mypy/generics_syntax_infer_variance.toml | 100 +++++++++ .../results/mypy/generics_syntax_scoping.toml | 70 +++++++ .../mypy/generics_typevartuple_args.toml | 14 ++ .../mypy/generics_typevartuple_basic.toml | 21 ++ .../mypy/generics_typevartuple_callable.toml | 4 + .../mypy/generics_typevartuple_concat.toml | 3 + .../mypy/generics_typevartuple_overloads.toml | 3 + .../generics_typevartuple_specialization.toml | 29 +++ .../mypy/generics_typevartuple_unpack.toml | 7 + .../results/mypy/generics_variance.toml | 7 + .../mypy/generics_variance_inference.toml | 102 +++++++++ conformance/results/mypy/version.toml | 2 +- .../pyre/generics_paramspec_basic.toml | 15 ++ .../pyre/generics_paramspec_components.toml | 22 ++ .../pyre/generics_paramspec_semantics.toml | 18 ++ .../generics_paramspec_specialization.toml | 22 ++ .../pyre/generics_syntax_autovariance.toml | 2 + .../pyre/generics_syntax_compatibility.toml | 7 + .../pyre/generics_syntax_declarations.toml | 7 + .../pyre/generics_syntax_infer_variance.toml | 7 + .../results/pyre/generics_syntax_scoping.toml | 7 + .../pyre/generics_typevartuple_args.toml | 18 ++ .../pyre/generics_typevartuple_basic.toml | 49 +++++ .../pyre/generics_typevartuple_callable.toml | 20 ++ .../pyre/generics_typevartuple_concat.toml | 31 +++ .../pyre/generics_typevartuple_overloads.toml | 15 ++ .../generics_typevartuple_specialization.toml | 96 +++++++++ .../pyre/generics_typevartuple_unpack.toml | 31 +++ .../results/pyre/generics_variance.toml | 7 + .../pyre/generics_variance_inference.toml | 7 + conformance/results/pyre/version.toml | 2 +- .../pyright/generics_paramspec_basic.toml | 16 ++ .../generics_paramspec_components.toml | 25 +++ .../pyright/generics_paramspec_semantics.toml | 35 ++++ .../generics_paramspec_specialization.toml | 13 ++ .../pyright/generics_syntax_autovariance.toml | 2 + .../generics_syntax_compatibility.toml | 6 + .../pyright/generics_syntax_declarations.toml | 14 ++ .../generics_syntax_infer_variance.toml | 59 ++++++ .../pyright/generics_syntax_scoping.toml | 19 ++ .../pyright/generics_typevartuple_args.toml | 20 ++ .../pyright/generics_typevartuple_basic.toml | 34 +++ .../generics_typevartuple_callable.toml | 6 + .../pyright/generics_typevartuple_concat.toml | 10 + .../generics_typevartuple_overloads.toml | 3 + .../generics_typevartuple_specialization.toml | 18 ++ .../pyright/generics_typevartuple_unpack.toml | 14 ++ .../results/pyright/generics_variance.toml | 7 + .../pyright/generics_variance_inference.toml | 86 ++++++++ conformance/results/pyright/version.toml | 2 +- .../pytype/aliases_type_statement.toml | 3 +- .../pytype/generics_paramspec_basic.toml | 7 + .../pytype/generics_paramspec_components.toml | 7 + .../pytype/generics_paramspec_semantics.toml | 7 + .../generics_paramspec_specialization.toml | 68 ++++++ .../pytype/generics_syntax_autovariance.toml | 3 + .../pytype/generics_syntax_compatibility.toml | 7 + .../pytype/generics_syntax_declarations.toml | 7 + .../generics_syntax_infer_variance.toml | 7 + .../pytype/generics_syntax_scoping.toml | 7 + .../pytype/generics_typevartuple_args.toml | 55 +++++ .../pytype/generics_typevartuple_basic.toml | 133 ++++++++++++ .../generics_typevartuple_callable.toml | 56 +++++ .../pytype/generics_typevartuple_concat.toml | 57 +++++ .../generics_typevartuple_overloads.toml | 25 +++ .../generics_typevartuple_specialization.toml | 172 ++++++++++++++++ .../pytype/generics_typevartuple_unpack.toml | 50 +++++ .../results/pytype/generics_variance.toml | 14 ++ .../pytype/generics_variance_inference.toml | 7 + .../results/pytype/protocols_generic.toml | 6 +- .../pytype/qualifiers_final_decorator.toml | 2 +- .../results/pytype/typeddicts_required.toml | 3 +- conformance/results/pytype/version.toml | 2 +- conformance/results/results.html | 76 ++++++- conformance/src/main.py | 12 +- conformance/src/reporting.py | 9 +- conformance/src/type_checker.py | 54 +++-- conformance/tests/generics_paramspec_basic.py | 40 ++++ .../tests/generics_paramspec_components.py | 98 +++++++++ .../tests/generics_paramspec_semantics.py | 143 +++++++++++++ .../generics_paramspec_specialization.py | 62 ++++++ .../tests/generics_syntax_compatibility.py | 27 +++ .../tests/generics_syntax_declarations.py | 82 ++++++++ .../tests/generics_syntax_infer_variance.py | 142 +++++++++++++ conformance/tests/generics_syntax_scoping.py | 124 +++++++++++ .../tests/generics_typevartuple_args.py | 81 ++++++++ .../tests/generics_typevartuple_basic.py | 109 ++++++++++ .../tests/generics_typevartuple_callable.py | 46 +++++ .../tests/generics_typevartuple_concat.py | 56 +++++ .../tests/generics_typevartuple_overloads.py | 31 +++ .../generics_typevartuple_specialization.py | 163 +++++++++++++++ .../tests/generics_typevartuple_unpack.py | 68 ++++++ conformance/tests/generics_variance.py | 57 +++++ .../tests/generics_variance_inference.py | 194 ++++++++++++++++++ .../tests/qualifiers_final_decorator.py | 2 +- 102 files changed, 3586 insertions(+), 42 deletions(-) create mode 100644 conformance/results/mypy/generics_paramspec_basic.toml create mode 100644 conformance/results/mypy/generics_paramspec_components.toml create mode 100644 conformance/results/mypy/generics_paramspec_semantics.toml create mode 100644 conformance/results/mypy/generics_paramspec_specialization.toml create mode 100644 conformance/results/mypy/generics_syntax_autovariance.toml create mode 100644 conformance/results/mypy/generics_syntax_compatibility.toml create mode 100644 conformance/results/mypy/generics_syntax_declarations.toml create mode 100644 conformance/results/mypy/generics_syntax_infer_variance.toml create mode 100644 conformance/results/mypy/generics_syntax_scoping.toml create mode 100644 conformance/results/mypy/generics_typevartuple_args.toml create mode 100644 conformance/results/mypy/generics_typevartuple_basic.toml create mode 100644 conformance/results/mypy/generics_typevartuple_callable.toml create mode 100644 conformance/results/mypy/generics_typevartuple_concat.toml create mode 100644 conformance/results/mypy/generics_typevartuple_overloads.toml create mode 100644 conformance/results/mypy/generics_typevartuple_specialization.toml create mode 100644 conformance/results/mypy/generics_typevartuple_unpack.toml create mode 100644 conformance/results/mypy/generics_variance.toml create mode 100644 conformance/results/mypy/generics_variance_inference.toml create mode 100644 conformance/results/pyre/generics_paramspec_basic.toml create mode 100644 conformance/results/pyre/generics_paramspec_components.toml create mode 100644 conformance/results/pyre/generics_paramspec_semantics.toml create mode 100644 conformance/results/pyre/generics_paramspec_specialization.toml create mode 100644 conformance/results/pyre/generics_syntax_autovariance.toml create mode 100644 conformance/results/pyre/generics_syntax_compatibility.toml create mode 100644 conformance/results/pyre/generics_syntax_declarations.toml create mode 100644 conformance/results/pyre/generics_syntax_infer_variance.toml create mode 100644 conformance/results/pyre/generics_syntax_scoping.toml create mode 100644 conformance/results/pyre/generics_typevartuple_args.toml create mode 100644 conformance/results/pyre/generics_typevartuple_basic.toml create mode 100644 conformance/results/pyre/generics_typevartuple_callable.toml create mode 100644 conformance/results/pyre/generics_typevartuple_concat.toml create mode 100644 conformance/results/pyre/generics_typevartuple_overloads.toml create mode 100644 conformance/results/pyre/generics_typevartuple_specialization.toml create mode 100644 conformance/results/pyre/generics_typevartuple_unpack.toml create mode 100644 conformance/results/pyre/generics_variance.toml create mode 100644 conformance/results/pyre/generics_variance_inference.toml create mode 100644 conformance/results/pyright/generics_paramspec_basic.toml create mode 100644 conformance/results/pyright/generics_paramspec_components.toml create mode 100644 conformance/results/pyright/generics_paramspec_semantics.toml create mode 100644 conformance/results/pyright/generics_paramspec_specialization.toml create mode 100644 conformance/results/pyright/generics_syntax_autovariance.toml create mode 100644 conformance/results/pyright/generics_syntax_compatibility.toml create mode 100644 conformance/results/pyright/generics_syntax_declarations.toml create mode 100644 conformance/results/pyright/generics_syntax_infer_variance.toml create mode 100644 conformance/results/pyright/generics_syntax_scoping.toml create mode 100644 conformance/results/pyright/generics_typevartuple_args.toml create mode 100644 conformance/results/pyright/generics_typevartuple_basic.toml create mode 100644 conformance/results/pyright/generics_typevartuple_callable.toml create mode 100644 conformance/results/pyright/generics_typevartuple_concat.toml create mode 100644 conformance/results/pyright/generics_typevartuple_overloads.toml create mode 100644 conformance/results/pyright/generics_typevartuple_specialization.toml create mode 100644 conformance/results/pyright/generics_typevartuple_unpack.toml create mode 100644 conformance/results/pyright/generics_variance.toml create mode 100644 conformance/results/pyright/generics_variance_inference.toml create mode 100644 conformance/results/pytype/generics_paramspec_basic.toml create mode 100644 conformance/results/pytype/generics_paramspec_components.toml create mode 100644 conformance/results/pytype/generics_paramspec_semantics.toml create mode 100644 conformance/results/pytype/generics_paramspec_specialization.toml create mode 100644 conformance/results/pytype/generics_syntax_autovariance.toml create mode 100644 conformance/results/pytype/generics_syntax_compatibility.toml create mode 100644 conformance/results/pytype/generics_syntax_declarations.toml create mode 100644 conformance/results/pytype/generics_syntax_infer_variance.toml create mode 100644 conformance/results/pytype/generics_syntax_scoping.toml create mode 100644 conformance/results/pytype/generics_typevartuple_args.toml create mode 100644 conformance/results/pytype/generics_typevartuple_basic.toml create mode 100644 conformance/results/pytype/generics_typevartuple_callable.toml create mode 100644 conformance/results/pytype/generics_typevartuple_concat.toml create mode 100644 conformance/results/pytype/generics_typevartuple_overloads.toml create mode 100644 conformance/results/pytype/generics_typevartuple_specialization.toml create mode 100644 conformance/results/pytype/generics_typevartuple_unpack.toml create mode 100644 conformance/results/pytype/generics_variance.toml create mode 100644 conformance/results/pytype/generics_variance_inference.toml create mode 100644 conformance/tests/generics_paramspec_basic.py create mode 100644 conformance/tests/generics_paramspec_components.py create mode 100644 conformance/tests/generics_paramspec_semantics.py create mode 100644 conformance/tests/generics_paramspec_specialization.py create mode 100644 conformance/tests/generics_syntax_compatibility.py create mode 100644 conformance/tests/generics_syntax_declarations.py create mode 100644 conformance/tests/generics_syntax_infer_variance.py create mode 100644 conformance/tests/generics_syntax_scoping.py create mode 100644 conformance/tests/generics_typevartuple_args.py create mode 100644 conformance/tests/generics_typevartuple_basic.py create mode 100644 conformance/tests/generics_typevartuple_callable.py create mode 100644 conformance/tests/generics_typevartuple_concat.py create mode 100644 conformance/tests/generics_typevartuple_overloads.py create mode 100644 conformance/tests/generics_typevartuple_specialization.py create mode 100644 conformance/tests/generics_typevartuple_unpack.py create mode 100644 conformance/tests/generics_variance.py create mode 100644 conformance/tests/generics_variance_inference.py diff --git a/conformance/results/mypy/generics_paramspec_basic.toml b/conformance/results/mypy/generics_paramspec_basic.toml new file mode 100644 index 000000000..53244490e --- /dev/null +++ b/conformance/results/mypy/generics_paramspec_basic.toml @@ -0,0 +1,18 @@ +conformant = "Partial" +notes = """ +Does not reject ParamSpec when used "bare" in type alias definition. +""" +output = """ +generics_paramspec_basic.py:10: error: String argument 1 "NotIt" to ParamSpec(...) does not match variable name "WrongName" [misc] +generics_paramspec_basic.py:23: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:23: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' +generics_paramspec_basic.py:27: error: Invalid location for Concatenate [valid-type] +generics_paramspec_basic.py:27: note: You can use Concatenate as the first argument to Callable +generics_paramspec_basic.py:31: error: Invalid location for ParamSpec "P" [misc] +generics_paramspec_basic.py:31: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' +generics_paramspec_basic.py:35: error: Name "func3" already defined on line 31 [no-redef] +generics_paramspec_basic.py:35: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:35: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' +generics_paramspec_basic.py:39: error: Invalid location for ParamSpec "P" [valid-type] +generics_paramspec_basic.py:39: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' +""" diff --git a/conformance/results/mypy/generics_paramspec_components.toml b/conformance/results/mypy/generics_paramspec_components.toml new file mode 100644 index 000000000..3519e2d1f --- /dev/null +++ b/conformance/results/mypy/generics_paramspec_components.toml @@ -0,0 +1,23 @@ +conformant = "Partial" +notes = """ +Does not report illegal use of "P.args" on normal parameter. +Does not report error when P.args is specified but P.kwargs is missing. +Does not report error when P is out of scope and P.args and P.kwargs is used. +Does not report error when keyword argument is specified between P.args and P.kwargs. +Does not report error when calling callable and argument is missing for concatenated parameters. +""" +output = """ +generics_paramspec_components.py:17: error: Use "P.args" for variadic "*" parameter [valid-type] +generics_paramspec_components.py:17: error: Use "P.kwargs" for variadic "**" parameter [valid-type] +generics_paramspec_components.py:23: error: Use "P.kwargs" for variadic "**" parameter [valid-type] +generics_paramspec_components.py:49: error: Argument 1 has incompatible type "*P.kwargs"; expected "P.args" [arg-type] +generics_paramspec_components.py:49: error: Argument 2 has incompatible type "**P.args"; expected "P.kwargs" [arg-type] +generics_paramspec_components.py:51: error: Argument 1 has incompatible type "int"; expected "P.args" [arg-type] +generics_paramspec_components.py:70: error: Argument 1 has incompatible type "*P.args"; expected "int" [arg-type] +generics_paramspec_components.py:70: error: Argument 2 has incompatible type "int"; expected "P.args" [arg-type] +generics_paramspec_components.py:83: error: "foo" gets multiple values for keyword argument "x" [misc] +generics_paramspec_components.py:83: error: Argument 1 to "foo" has incompatible type "*P.args"; expected "int" [arg-type] +generics_paramspec_components.py:83: error: Argument 3 to "foo" has incompatible type "**P.kwargs"; expected "int" [arg-type] +generics_paramspec_components.py:98: error: Argument 2 to "twice" has incompatible type "str"; expected "int" [arg-type] +generics_paramspec_components.py:98: error: Argument 3 to "twice" has incompatible type "int"; expected "str" [arg-type] +""" diff --git a/conformance/results/mypy/generics_paramspec_semantics.toml b/conformance/results/mypy/generics_paramspec_semantics.toml new file mode 100644 index 000000000..a4b903a8c --- /dev/null +++ b/conformance/results/mypy/generics_paramspec_semantics.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +output = """ +generics_paramspec_semantics.py:26: error: Unexpected keyword argument "a" [call-arg] +generics_paramspec_semantics.py:26: error: Unexpected keyword argument "b" [call-arg] +generics_paramspec_semantics.py:27: error: Argument 2 has incompatible type "str"; expected "bool" [arg-type] +generics_paramspec_semantics.py:61: error: Argument 2 to "func1" has incompatible type "Callable[[NamedArg(int, 'y')], int]"; expected "Callable[[NamedArg(int, 'x')], int]" [arg-type] +generics_paramspec_semantics.py:97: error: Argument 1 has incompatible type "int"; expected "str" [arg-type] +generics_paramspec_semantics.py:107: error: Argument 1 has incompatible type "int"; expected "bool" [arg-type] +generics_paramspec_semantics.py:119: error: Argument 1 has incompatible type "int"; expected "str" [arg-type] +generics_paramspec_semantics.py:126: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[str], int]"; expected "Callable[[int], int]" [arg-type] +generics_paramspec_semantics.py:126: note: This is likely because "one" has named arguments: "x". Consider marking them positional-only +generics_paramspec_semantics.py:131: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[NamedArg(int, 'x')], int]"; expected "Callable[[int, NamedArg(int, 'x')], int]" [arg-type] +generics_paramspec_semantics.py:136: error: Argument 1 to "expects_int_first" has incompatible type "Callable[[KwArg(int)], int]"; expected "Callable[[int, KwArg(int)], int]" [arg-type] +""" diff --git a/conformance/results/mypy/generics_paramspec_specialization.toml b/conformance/results/mypy/generics_paramspec_specialization.toml new file mode 100644 index 000000000..fe8e5f6f3 --- /dev/null +++ b/conformance/results/mypy/generics_paramspec_specialization.toml @@ -0,0 +1,8 @@ +conformant = "Pass" +output = """ +generics_paramspec_specialization.py:45: error: Can only replace ParamSpec with a parameter types list or another ParamSpec, got "int" [misc] +generics_paramspec_specialization.py:55: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] +generics_paramspec_specialization.py:56: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] +generics_paramspec_specialization.py:61: error: Argument 1 has incompatible type "str"; expected "int" [arg-type] +generics_paramspec_specialization.py:62: error: Argument 3 has incompatible type "str"; expected "bool" [arg-type] +""" diff --git a/conformance/results/mypy/generics_syntax_autovariance.toml b/conformance/results/mypy/generics_syntax_autovariance.toml new file mode 100644 index 000000000..8f9fb5f9b --- /dev/null +++ b/conformance/results/mypy/generics_syntax_autovariance.toml @@ -0,0 +1,2 @@ +output = """ +""" diff --git a/conformance/results/mypy/generics_syntax_compatibility.toml b/conformance/results/mypy/generics_syntax_compatibility.toml new file mode 100644 index 000000000..e22025fa1 --- /dev/null +++ b/conformance/results/mypy/generics_syntax_compatibility.toml @@ -0,0 +1,14 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_syntax_compatibility.py:14: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_compatibility.py:14: error: Name "V" is not defined [name-defined] +generics_syntax_compatibility.py:18: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_compatibility.py:18: error: Name "V" is not defined [name-defined] +generics_syntax_compatibility.py:22: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_compatibility.py:23: error: Name "V" is not defined [name-defined] +generics_syntax_compatibility.py:26: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_compatibility.py:26: error: Name "M" is not defined [name-defined] +""" diff --git a/conformance/results/mypy/generics_syntax_declarations.toml b/conformance/results/mypy/generics_syntax_declarations.toml new file mode 100644 index 000000000..e37dcf135 --- /dev/null +++ b/conformance/results/mypy/generics_syntax_declarations.toml @@ -0,0 +1,34 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_syntax_declarations.py:13: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:14: error: Expression is of type "Any", not "TypeVar" [assert-type] +generics_syntax_declarations.py:14: error: Name "T" is not defined [name-defined] +generics_syntax_declarations.py:15: error: Expression is of type "Any", not "TypeVarTuple" [assert-type] +generics_syntax_declarations.py:15: error: Name "Ts" is not defined [name-defined] +generics_syntax_declarations.py:16: error: Expression is of type "Any", not "ParamSpec" [assert-type] +generics_syntax_declarations.py:16: error: Name "P" is not defined [name-defined] +generics_syntax_declarations.py:19: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:19: error: Free type variable expected in Generic[...] [misc] +generics_syntax_declarations.py:19: error: Name "T" is not defined [name-defined] +generics_syntax_declarations.py:23: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:23: error: Free type variable expected in Protocol[...] [misc] +generics_syntax_declarations.py:23: error: Name "S" is not defined [name-defined] +generics_syntax_declarations.py:23: error: Name "T" is not defined [name-defined] +generics_syntax_declarations.py:27: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:28: error: Name "T" is not defined [name-defined] +generics_syntax_declarations.py:33: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:37: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:41: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:42: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:46: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:50: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:54: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:58: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:62: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:69: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:73: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:77: error: PEP 695 generics are not yet supported [valid-type] +""" diff --git a/conformance/results/mypy/generics_syntax_infer_variance.toml b/conformance/results/mypy/generics_syntax_infer_variance.toml new file mode 100644 index 000000000..4a45f7ed5 --- /dev/null +++ b/conformance/results/mypy/generics_syntax_infer_variance.toml @@ -0,0 +1,100 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_syntax_infer_variance.py:11: error: Unexpected argument to "TypeVar()": "infer_variance" [misc] +generics_syntax_infer_variance.py:12: error: Unexpected argument to "TypeVar()": "infer_variance" [misc] +generics_syntax_infer_variance.py:13: error: Unexpected argument to "TypeVar()": "infer_variance" [misc] +generics_syntax_infer_variance.py:15: error: Unexpected argument to "TypeVar()": "infer_variance" [misc] +generics_syntax_infer_variance.py:19: error: Unexpected argument to "TypeVar()": "infer_variance" [misc] +generics_syntax_infer_variance.py:24: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:25: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:25: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:28: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:28: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:32: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:32: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:33: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:33: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:36: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:36: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:40: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:40: error: The type "type[ShouldBeCovariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:41: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:41: error: The type "type[ShouldBeCovariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:44: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:45: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:45: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:45: error: "ShouldBeCovariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:49: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:49: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:50: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:50: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:54: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:55: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:55: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:58: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:58: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:59: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:59: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:62: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:63: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:63: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:67: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:67: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:71: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:71: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:72: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:72: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:75: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:76: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:76: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:84: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:84: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:88: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:88: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:89: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:89: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:92: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:93: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:93: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:96: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:96: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:99: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:99: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:103: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:103: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:104: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:104: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:107: error: Variable "generics_syntax_infer_variance.K" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:107: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:107: error: Variable "generics_syntax_infer_variance.V" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:111: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:111: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:112: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:112: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:113: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:113: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:114: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:114: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:118: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_infer_variance.py:119: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:119: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:122: error: "ShouldBeInvariant4" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:122: error: The type "type[ShouldBeInvariant4]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:125: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_infer_variance.py:126: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:126: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:130: error: "ShouldBeInvariant5" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:130: error: The type "type[ShouldBeInvariant5]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:133: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:134: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:134: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:137: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:137: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:141: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:141: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:142: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:142: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +""" diff --git a/conformance/results/mypy/generics_syntax_scoping.toml b/conformance/results/mypy/generics_syntax_scoping.toml new file mode 100644 index 000000000..d22757db5 --- /dev/null +++ b/conformance/results/mypy/generics_syntax_scoping.toml @@ -0,0 +1,70 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_syntax_scoping.py:14: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:18: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:22: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:26: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:27: error: "Foo" expects no type arguments, but 1 given [type-arg] +generics_syntax_scoping.py:27: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:27: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:31: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:31: error: "BaseClassC" expects no type arguments, but 1 given [type-arg] +generics_syntax_scoping.py:31: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:31: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:31: error: The type "type[Foo]" is not generic and not indexable [misc] +generics_syntax_scoping.py:31: error: Cannot determine type of "T" [has-type] +generics_syntax_scoping.py:35: error: Cannot determine type of "T" [has-type] +generics_syntax_scoping.py:35: error: Name "T" is used before definition [used-before-def] +generics_syntax_scoping.py:39: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:40: error: "Foo" expects no type arguments, but 1 given [type-arg] +generics_syntax_scoping.py:40: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:40: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:40: error: The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type] +generics_syntax_scoping.py:40: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas +generics_syntax_scoping.py:40: error: Name "P" is not defined [name-defined] +generics_syntax_scoping.py:40: error: Name "R" is not defined [name-defined] +generics_syntax_scoping.py:44: error: The type "type[Foo]" is not generic and not indexable [misc] +generics_syntax_scoping.py:44: error: Cannot determine type of "T" [has-type] +generics_syntax_scoping.py:45: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:49: error: PEP 695 type aliases are not yet supported [valid-type] +generics_syntax_scoping.py:49: error: Name "K" is not defined [name-defined] +generics_syntax_scoping.py:49: error: Name "V" is not defined [name-defined] +generics_syntax_scoping.py:55: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:56: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] +generics_syntax_scoping.py:57: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] +generics_syntax_scoping.py:59: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:62: error: Expression is of type "Any", not "str" [assert-type] +generics_syntax_scoping.py:62: note: "assert_type" expects everything to be "Any" in unchecked functions +generics_syntax_scoping.py:67: error: Expression is of type "Any", not "int" [assert-type] +generics_syntax_scoping.py:67: note: "assert_type" expects everything to be "Any" in unchecked functions +generics_syntax_scoping.py:74: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:74: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:74: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:77: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:77: error: "Inner" expects no type arguments, but 1 given [type-arg] +generics_syntax_scoping.py:77: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:77: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:81: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:81: error: The first argument to Callable must be a list of types, parameter specification, or "..." [valid-type] +generics_syntax_scoping.py:81: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas +generics_syntax_scoping.py:81: error: Name "P" is not defined [name-defined] +generics_syntax_scoping.py:81: error: Name "R" is not defined [name-defined] +generics_syntax_scoping.py:89: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:89: error: Variable "generics_syntax_scoping.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:89: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:92: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:95: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:98: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:98: error: Variable "generics_syntax_scoping.ClassE.T" is not valid as a type [valid-type] +generics_syntax_scoping.py:98: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_scoping.py:105: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_scoping.py:116: error: Expression is of type "Any", not "TypeVar" [assert-type] +generics_syntax_scoping.py:116: note: "assert_type" expects everything to be "Any" in unchecked functions +generics_syntax_scoping.py:121: error: Expression is of type "Any", not "complex" [assert-type] +generics_syntax_scoping.py:121: note: "assert_type" expects everything to be "Any" in unchecked functions +generics_syntax_scoping.py:124: error: Expression is of type "Any", not "complex" [assert-type] +generics_syntax_scoping.py:124: note: "assert_type" expects everything to be "Any" in unchecked functions +""" diff --git a/conformance/results/mypy/generics_typevartuple_args.toml b/conformance/results/mypy/generics_typevartuple_args.toml new file mode 100644 index 000000000..304cbe608 --- /dev/null +++ b/conformance/results/mypy/generics_typevartuple_args.toml @@ -0,0 +1,14 @@ +conformant = "Partial" +notes = """ +Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?). +""" +output = """ +generics_typevartuple_args.py:33: error: Argument 3 to "exec_le" has incompatible type "str"; expected "Env" [arg-type] +generics_typevartuple_args.py:34: error: Argument 3 to "exec_le" has incompatible type "str"; expected "Env" [arg-type] +generics_typevartuple_args.py:48: error: Argument 2 to "func1" has incompatible type "str"; expected "int" [arg-type] +generics_typevartuple_args.py:57: error: Argument 2 to "func2" has incompatible type "int"; expected "*tuple[*tuple[str, ...], str]" [arg-type] +generics_typevartuple_args.py:58: error: Too few arguments for "func2" [call-arg] +generics_typevartuple_args.py:59: error: Too few arguments for "func2" [call-arg] +generics_typevartuple_args.py:59: error: Argument 1 to "func2" has incompatible type "str"; expected "int" [arg-type] +generics_typevartuple_args.py:67: error: Too few arguments for "func3" [call-arg] +""" diff --git a/conformance/results/mypy/generics_typevartuple_basic.toml b/conformance/results/mypy/generics_typevartuple_basic.toml new file mode 100644 index 000000000..bec76c4eb --- /dev/null +++ b/conformance/results/mypy/generics_typevartuple_basic.toml @@ -0,0 +1,21 @@ +conformant = "Partial" +notes = """ +Does not enforce that tuples captured by TypeVarTuple are same length (spec bug?). +Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?). +Does not enforce that tuples captured by TypeVarTuple are invariant in non-tuple class. +""" +output = """ +generics_typevartuple_basic.py:42: error: Argument 1 to "Array" has incompatible type "Height"; expected "tuple[Height, Width]" [arg-type] +generics_typevartuple_basic.py:43: error: Argument 1 to "Array" has incompatible type "tuple[Batch, Width]"; expected "tuple[Batch, Height, Width]" [arg-type] +generics_typevartuple_basic.py:45: error: Argument 1 to "Array" has incompatible type "tuple[Time, Batch, Width, Height]"; expected "tuple[Time, Batch, Height, Width]" [arg-type] +generics_typevartuple_basic.py:52: error: Free type variable expected in Generic[...] [misc] +generics_typevartuple_basic.py:53: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] +generics_typevartuple_basic.py:56: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] +generics_typevartuple_basic.py:57: error: Incompatible return value type (got "tuple[*Shape]", expected "tuple[Any]") [return-value] +generics_typevartuple_basic.py:59: error: TypeVarTuple "Shape" is only valid with an unpack [valid-type] +generics_typevartuple_basic.py:65: error: Unexpected keyword argument "covariant" for "TypeVarTuple" [misc] +generics_typevartuple_basic.py:66: error: Too many positional arguments for "TypeVarTuple" [misc] +generics_typevartuple_basic.py:67: error: Unexpected keyword argument "bound" for "TypeVarTuple" [misc] +generics_typevartuple_basic.py:87: error: Expression is of type "tuple[tuple[int], tuple[int]]", not "tuple[int]" [assert-type] +generics_typevartuple_basic.py:108: error: Can only use one type var tuple in a class def [misc] +""" diff --git a/conformance/results/mypy/generics_typevartuple_callable.toml b/conformance/results/mypy/generics_typevartuple_callable.toml new file mode 100644 index 000000000..4561f3c4a --- /dev/null +++ b/conformance/results/mypy/generics_typevartuple_callable.toml @@ -0,0 +1,4 @@ +conformant = "Pass" +output = """ +generics_typevartuple_callable.py:26: error: Argument "target" to "Process" has incompatible type "Callable[[int, str], None]"; expected "Callable[[str, int], None]" [arg-type] +""" diff --git a/conformance/results/mypy/generics_typevartuple_concat.toml b/conformance/results/mypy/generics_typevartuple_concat.toml new file mode 100644 index 000000000..2146548eb --- /dev/null +++ b/conformance/results/mypy/generics_typevartuple_concat.toml @@ -0,0 +1,3 @@ +conformant = "Pass" +output = """ +""" diff --git a/conformance/results/mypy/generics_typevartuple_overloads.toml b/conformance/results/mypy/generics_typevartuple_overloads.toml new file mode 100644 index 000000000..2146548eb --- /dev/null +++ b/conformance/results/mypy/generics_typevartuple_overloads.toml @@ -0,0 +1,3 @@ +conformant = "Pass" +output = """ +""" diff --git a/conformance/results/mypy/generics_typevartuple_specialization.toml b/conformance/results/mypy/generics_typevartuple_specialization.toml new file mode 100644 index 000000000..51d73fb77 --- /dev/null +++ b/conformance/results/mypy/generics_typevartuple_specialization.toml @@ -0,0 +1,29 @@ +conformant = "Partial" +notes = """ +Incorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`. +Incorrectly specializes generic alias that includes a TypeVar and TypeVarTuple if no type arguments are provided. +Rejects use of unpacked TypeVarTuple in generic type alias definition. +Rejects specialization of generic type alias defined as a tuple containing a TypeVar. +"More than one Unpack" error message has no line number. +Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar. +""" +output = """ +generics_typevartuple_specialization.py: error: More than one Unpack in a type is not allowed [misc] +generics_typevartuple_specialization.py:85: error: Argument 1 to "takes_float_array_with_specific_shape" has incompatible type "Array2[float, *tuple[Any, ...]]"; expected "Array2[float, Height, Width]" [arg-type] +generics_typevartuple_specialization.py:95: error: Expression is of type "tuple[Any, *tuple[Any, ...]]", not "tuple[Any, ...]" [assert-type] +generics_typevartuple_specialization.py:101: error: "Ts1" cannot be unpacked (must be tuple or TypeVarTuple) [valid-type] +generics_typevartuple_specialization.py:102: error: Unpack is only valid in a variadic position [valid-type] +generics_typevartuple_specialization.py:103: error: Unpack is only valid in a variadic position [valid-type] +generics_typevartuple_specialization.py:108: error: Type application is only supported for generic classes [misc] +generics_typevartuple_specialization.py:109: error: Type application is only supported for generic classes [misc] +generics_typevartuple_specialization.py:109: error: Unpack is only valid in a variadic position [valid-type] +generics_typevartuple_specialization.py:110: error: Type application is only supported for generic classes [misc] +generics_typevartuple_specialization.py:110: error: Unpack is only valid in a variadic position [valid-type] +generics_typevartuple_specialization.py:127: error: Bad number of arguments for type alias, expected: at least 2, given: 1 [type-arg] +generics_typevartuple_specialization.py:159: error: Expression is of type "tuple[str, *tuple[int, ...]]", not "tuple[str, *tuple[int, ...], int]" [assert-type] +generics_typevartuple_specialization.py:162: error: "Ts1" cannot be unpacked (must be tuple or TypeVarTuple) [valid-type] +generics_typevartuple_specialization.py:163: error: Unpack is only valid in a variadic position [valid-type] +generics_typevartuple_specialization.py:163: error: Type variable "generics_typevartuple_specialization.Ts2" is unbound [valid-type] +generics_typevartuple_specialization.py:163: note: (Hint: Use "Generic[Ts2]" or "Protocol[Ts2]" base class to bind "Ts2" inside a class) +generics_typevartuple_specialization.py:163: note: (Hint: Use "Ts2" in function signature to bind "Ts2" inside a function) +""" diff --git a/conformance/results/mypy/generics_typevartuple_unpack.toml b/conformance/results/mypy/generics_typevartuple_unpack.toml new file mode 100644 index 000000000..b67b0b1cc --- /dev/null +++ b/conformance/results/mypy/generics_typevartuple_unpack.toml @@ -0,0 +1,7 @@ +conformant = "Partial" +notes = """ +Does not reject multiple unpack operators in a tuple. +""" +output = """ +generics_typevartuple_unpack.py:46: error: Argument 1 to "process_batch_channels" has incompatible type "Array[Batch]"; expected "Array[Batch, *tuple[Any, ...], Channels]" [arg-type] +""" diff --git a/conformance/results/mypy/generics_variance.toml b/conformance/results/mypy/generics_variance.toml new file mode 100644 index 000000000..97afb4e80 --- /dev/null +++ b/conformance/results/mypy/generics_variance.toml @@ -0,0 +1,7 @@ +conformant = "Partial" +notes = """ +Does not reject a function-scoped TypeVar that is marked as covariant or contravariant. +""" +output = """ +generics_variance.py:14: error: TypeVar cannot be both covariant and contravariant [misc] +""" diff --git a/conformance/results/mypy/generics_variance_inference.toml b/conformance/results/mypy/generics_variance_inference.toml new file mode 100644 index 000000000..ff032080a --- /dev/null +++ b/conformance/results/mypy/generics_variance_inference.toml @@ -0,0 +1,102 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_variance_inference.py:15: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:15: error: Name "T1" is not defined [name-defined] +generics_variance_inference.py:16: error: Name "T2" is not defined [name-defined] +generics_variance_inference.py:19: error: Name "T3" is not defined [name-defined] +generics_variance_inference.py:23: error: "ClassA" expects no type arguments, but 3 given [type-arg] +generics_variance_inference.py:24: error: "ClassA" expects no type arguments, but 3 given [type-arg] +generics_variance_inference.py:25: error: "ClassA" expects no type arguments, but 3 given [type-arg] +generics_variance_inference.py:26: error: "ClassA" expects no type arguments, but 3 given [type-arg] +generics_variance_inference.py:28: error: "ClassA" expects no type arguments, but 3 given [type-arg] +generics_variance_inference.py:29: error: "ClassA" expects no type arguments, but 3 given [type-arg] +generics_variance_inference.py:32: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:33: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] +generics_variance_inference.py:36: error: Name "Iterator" is not defined [name-defined] +generics_variance_inference.py:36: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Iterator") +generics_variance_inference.py:40: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:40: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:41: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:41: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:44: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:48: error: Cannot instantiate abstract class "ShouldBeCovariant2" with abstract attributes "__getitem__" and "__len__" [abstract] +generics_variance_inference.py:48: error: Incompatible types in assignment (expression has type "ShouldBeCovariant2[int]", variable has type "ShouldBeCovariant2[float]") [assignment] +generics_variance_inference.py:49: error: Cannot instantiate abstract class "ShouldBeCovariant2" with abstract attributes "__getitem__" and "__len__" [abstract] +generics_variance_inference.py:49: error: Incompatible types in assignment (expression has type "ShouldBeCovariant2[float]", variable has type "ShouldBeCovariant2[int]") [assignment] +generics_variance_inference.py:52: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:57: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:57: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] +generics_variance_inference.py:58: error: "ShouldBeCovariant3" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:58: error: The type "type[ShouldBeCovariant3]" is not generic and not indexable [misc] +generics_variance_inference.py:62: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:63: error: Type variable "generics_variance_inference.T" is unbound [valid-type] +generics_variance_inference.py:63: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_variance_inference.py:63: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_variance_inference.py:66: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:66: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc] +generics_variance_inference.py:67: error: "ShouldBeCovariant4" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:67: error: The type "type[ShouldBeCovariant4]" is not generic and not indexable [misc] +generics_variance_inference.py:70: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:75: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] +generics_variance_inference.py:79: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:79: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] +generics_variance_inference.py:80: error: "ShouldBeCovariant5" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:80: error: The type "type[ShouldBeCovariant5]" is not generic and not indexable [misc] +generics_variance_inference.py:83: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:96: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:96: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:97: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:97: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:100: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:104: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] +generics_variance_inference.py:111: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:111: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] +generics_variance_inference.py:112: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:112: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] +generics_variance_inference.py:115: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:115: error: Name "K" is not defined [name-defined] +generics_variance_inference.py:115: error: Name "V" is not defined [name-defined] +generics_variance_inference.py:119: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_variance_inference.py:119: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_variance_inference.py:120: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_variance_inference.py:120: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_variance_inference.py:121: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_variance_inference.py:121: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_variance_inference.py:122: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_variance_inference.py:122: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_variance_inference.py:126: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:127: error: Type variable "generics_variance_inference.T" is unbound [valid-type] +generics_variance_inference.py:127: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +generics_variance_inference.py:127: note: (Hint: Use "T" in function signature to bind "T" inside a function) +generics_variance_inference.py:130: error: "ShouldBeInvariant4" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:130: error: The type "type[ShouldBeInvariant4]" is not generic and not indexable [misc] +generics_variance_inference.py:133: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:138: error: "ShouldBeInvariant5" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:138: error: The type "type[ShouldBeInvariant5]" is not generic and not indexable [misc] +generics_variance_inference.py:141: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:149: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:149: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:150: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:150: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:165: error: Name "ShouldBeInvariant1" already defined on line 83 [no-redef] +generics_variance_inference.py:165: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:169: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:169: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:170: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:170: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:177: error: Name "ShouldBeCovariant1" already defined on line 32 [no-redef] +generics_variance_inference.py:177: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:181: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:181: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:182: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:182: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:189: error: Name "ShouldBeContravariant1" already defined on line 141 [no-redef] +generics_variance_inference.py:189: error: PEP 695 generics are not yet supported [valid-type] +generics_variance_inference.py:193: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:193: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:194: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_variance_inference.py:194: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +""" diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index 1842b0d7a..277e06ef3 100644 --- a/conformance/results/mypy/version.toml +++ b/conformance/results/mypy/version.toml @@ -1,2 +1,2 @@ version = "mypy 1.8.0" -test_duration = 0.6594910621643066 +test_duration = 1.248046875 diff --git a/conformance/results/pyre/generics_paramspec_basic.toml b/conformance/results/pyre/generics_paramspec_basic.toml new file mode 100644 index 000000000..b1c685757 --- /dev/null +++ b/conformance/results/pyre/generics_paramspec_basic.toml @@ -0,0 +1,15 @@ +conformant = "Partial" +notes = """ +Does not enforce name consistency for ParamSpec assigned to identifier. +Incorrectly reports error for legitimate use of ParamSpec in generic type alias. +Does not reject ParamSpec when used in various invalid locations. +""" +output = """ +generics_paramspec_basic.py:15:0 Undefined or invalid type [11]: Annotation `P` is not defined as a type. +generics_paramspec_basic.py:17:0 Incompatible variable type [9]: TA2 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`. +generics_paramspec_basic.py:17:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[ParamSpec, None]`. +generics_paramspec_basic.py:18:0 Incompatible variable type [9]: TA3 is declared to have type `TypeAlias` but is used as type `Type[typing.Callable[..., Variable[$synthetic_attribute_resolution_variable]]]`. +generics_paramspec_basic.py:18:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[object, None]`. +generics_paramspec_basic.py:27:13 Invalid type variable [34]: The type variable `P` isn't present in the function's parameters. +generics_paramspec_basic.py:27:13 Undefined or invalid type [11]: Annotation `Concatenate` is not defined as a type. +""" diff --git a/conformance/results/pyre/generics_paramspec_components.toml b/conformance/results/pyre/generics_paramspec_components.toml new file mode 100644 index 000000000..7e2cb81b8 --- /dev/null +++ b/conformance/results/pyre/generics_paramspec_components.toml @@ -0,0 +1,22 @@ +conformant = "Partial" +notes = """ +Does not report illegal use of "P.args" on normal parameter. +Does not report error when P.args is specified but P.kwargs is missing. +Does not report error when P is out of scope and P.args and P.kwargs is used. +Does not report error when calling callback defined with ParamSpec with incorrect arguments. +Does not report error when keyword argument is specified between P.args and P.kwargs. +Does not report error when calling callable and argument is missing for concatenated parameters. +""" +output = """ +generics_paramspec_components.py:17:24 Undefined or invalid type [11]: Annotation `P.kwargs` is not defined as a type. +generics_paramspec_components.py:17:44 Undefined or invalid type [11]: Annotation `P.args` is not defined as a type. +generics_paramspec_components.py:49:8 Call error [29]: `typing.Callable[generics_paramspec_components.P, int]` cannot be safely called because the types and kinds of its parameters depend on a type variable. +generics_paramspec_components.py:56:32 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(str, $local_generics_paramspec_components$P)], None)]` is not a valid type. +generics_paramspec_components.py:66:14 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, $local_generics_paramspec_components$P)], int)]` is not a valid type. +generics_paramspec_components.py:66:14 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, $local_generics_paramspec_components$P)], int)]` is not a valid type. +generics_paramspec_components.py:66:53 Invalid type variable [34]: The type variable `P` isn't present in the function's parameters. +generics_paramspec_components.py:74:4 Incompatible return type [7]: Expected `typing.Callable[generics_paramspec_components.P, None]` but got `typing.Callable($local_generics_paramspec_components?remove$foo)[generics_paramspec_components.P, None]`. +generics_paramspec_components.py:83:8 Unexpected keyword [28]: Unexpected keyword argument `x` to call `foo`. +generics_paramspec_components.py:98:19 Incompatible parameter type [6]: In call `twice`, for 2nd positional argument, expected `int` but got `str`. +generics_paramspec_components.py:98:24 Incompatible parameter type [6]: In call `twice`, for 3rd positional argument, expected `str` but got `int`. +""" diff --git a/conformance/results/pyre/generics_paramspec_semantics.toml b/conformance/results/pyre/generics_paramspec_semantics.toml new file mode 100644 index 000000000..21f95175c --- /dev/null +++ b/conformance/results/pyre/generics_paramspec_semantics.toml @@ -0,0 +1,18 @@ +conformant = "Partial" +notes = """ +Constraint solver doesn't find common type for two signatures captured by a single ParamSpec. +Reports error for legitimate Callable type annotation that uses Concatenate. +Does not evaluate the correct type for call of Callable defined with Concatenate. +""" +output = """ +generics_paramspec_semantics.py:26:0 Unexpected keyword [28]: Unexpected keyword argument `a` to anonymous call. +generics_paramspec_semantics.py:27:8 Incompatible parameter type [6]: In anonymous call, for 2nd positional argument, expected `bool` but got `str`. +generics_paramspec_semantics.py:46:16 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `typing.Callable[generics_paramspec_semantics.P, int]` but got `typing.Callable(y_x)[[Named(y, int), Named(x, str)], int]`. +generics_paramspec_semantics.py:61:22 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `typing.Callable[generics_paramspec_semantics.P, int]` but got `typing.Callable(keyword_only_y)[[KeywordOnly(y, int)], int]`. +generics_paramspec_semantics.py:90:32 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(str, $local_generics_paramspec_semantics$P)], bool)]` is not a valid type. +generics_paramspec_semantics.py:100:14 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, $local_generics_paramspec_semantics$P)], int)]` is not a valid type. +generics_paramspec_semantics.py:100:53 Invalid type variable [34]: The type variable `P` isn't present in the function's parameters. +generics_paramspec_semantics.py:111:7 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, $local_generics_paramspec_semantics$P)], int)]` is not a valid type. +generics_paramspec_semantics.py:112:5 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(str, $local_generics_paramspec_semantics$P)], bool)]` is not a valid type. +generics_paramspec_semantics.py:122:25 Invalid type [31]: Expression `typing.Callable[(typing.Concatenate[(int, $local_generics_paramspec_semantics$P)], int)]` is not a valid type. +""" diff --git a/conformance/results/pyre/generics_paramspec_specialization.toml b/conformance/results/pyre/generics_paramspec_specialization.toml new file mode 100644 index 000000000..18dc721ba --- /dev/null +++ b/conformance/results/pyre/generics_paramspec_specialization.toml @@ -0,0 +1,22 @@ +conformant = "Partial" +notes = """ +Reports error for legitimate use of ParamSpec and Concatenate in function signature. +Reports error for legitimate specialization of generic class parameterized with ParamSpec. +""" +output = """ +generics_paramspec_specialization.py:14:0 Uninitialized attribute [13]: Attribute `f` is declared in class `ClassA` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized. +generics_paramspec_specialization.py:14:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassA` to have type `Variable[T]` but is never initialized. +generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `f1` is declared in class `ClassB` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized. +generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `f2` is declared in class `ClassB` to have type `typing.Callable[generics_paramspec_specialization.P2, int]` but is never initialized. +generics_paramspec_specialization.py:19:0 Uninitialized attribute [13]: Attribute `x` is declared in class `ClassB` to have type `Variable[T]` but is never initialized. +generics_paramspec_specialization.py:29:14 Invalid type variable [34]: The type variable `P2` isn't present in the function's parameters. +generics_paramspec_specialization.py:29:14 Undefined or invalid type [11]: Annotation `Concatenate` is not defined as a type. +generics_paramspec_specialization.py:33:14 Invalid type parameters [24]: Callable parameters expected for parameter specification `P2`, but a single type `...` was given for generic type ClassB. +generics_paramspec_specialization.py:37:14 Invalid type parameters [24]: Callable parameters expected for parameter specification `P1`, but a single type `...` was given for generic type ClassA. +generics_paramspec_specialization.py:45:14 Invalid type parameters [24]: Callable parameters expected for parameter specification `P1`, but a single type `int` was given for generic type ClassA. +generics_paramspec_specialization.py:49:0 Uninitialized attribute [13]: Attribute `f` is declared in class `ClassC` to have type `typing.Callable[generics_paramspec_specialization.P1, int]` but is never initialized. +generics_paramspec_specialization.py:55:8 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `int` but got `str`. +generics_paramspec_specialization.py:56:15 Incompatible parameter type [6]: In anonymous call, for 3rd positional argument, expected `bool` but got `str`. +generics_paramspec_specialization.py:61:8 Incompatible parameter type [6]: In anonymous call, for 1st positional argument, expected `int` but got `str`. +generics_paramspec_specialization.py:62:15 Incompatible parameter type [6]: In anonymous call, for 3rd positional argument, expected `bool` but got `str`. +""" diff --git a/conformance/results/pyre/generics_syntax_autovariance.toml b/conformance/results/pyre/generics_syntax_autovariance.toml new file mode 100644 index 000000000..8f9fb5f9b --- /dev/null +++ b/conformance/results/pyre/generics_syntax_autovariance.toml @@ -0,0 +1,2 @@ +output = """ +""" diff --git a/conformance/results/pyre/generics_syntax_compatibility.toml b/conformance/results/pyre/generics_syntax_compatibility.toml new file mode 100644 index 000000000..4d6fe8223 --- /dev/null +++ b/conformance/results/pyre/generics_syntax_compatibility.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_syntax_compatibility.py:14:13 Parsing failure [404]: invalid syntax +""" diff --git a/conformance/results/pyre/generics_syntax_declarations.toml b/conformance/results/pyre/generics_syntax_declarations.toml new file mode 100644 index 000000000..8753d7012 --- /dev/null +++ b/conformance/results/pyre/generics_syntax_declarations.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_syntax_declarations.py:13:13 Parsing failure [404]: invalid syntax +""" diff --git a/conformance/results/pyre/generics_syntax_infer_variance.toml b/conformance/results/pyre/generics_syntax_infer_variance.toml new file mode 100644 index 000000000..4573868ba --- /dev/null +++ b/conformance/results/pyre/generics_syntax_infer_variance.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_syntax_infer_variance.py:118:25 Parsing failure [404]: invalid syntax +""" diff --git a/conformance/results/pyre/generics_syntax_scoping.toml b/conformance/results/pyre/generics_syntax_scoping.toml new file mode 100644 index 000000000..9a4db655f --- /dev/null +++ b/conformance/results/pyre/generics_syntax_scoping.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_syntax_scoping.py:14:13 Parsing failure [404]: invalid syntax +""" diff --git a/conformance/results/pyre/generics_typevartuple_args.toml b/conformance/results/pyre/generics_typevartuple_args.toml new file mode 100644 index 000000000..741718ebf --- /dev/null +++ b/conformance/results/pyre/generics_typevartuple_args.toml @@ -0,0 +1,18 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +generics_typevartuple_args.py:16:25 Invalid type [31]: Expression `*$local_generics_typevartuple_args$Ts` is not a valid type. +generics_typevartuple_args.py:16:33 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type. +generics_typevartuple_args.py:20:41 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[str]]`. +generics_typevartuple_args.py:27:30 Invalid type [31]: Expression `*tuple[(*$local_generics_typevartuple_args$Ts, generics_typevartuple_args.Env)]` is not a valid type. +generics_typevartuple_args.py:27:76 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type. +generics_typevartuple_args.py:31:38 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[]`. +generics_typevartuple_args.py:32:45 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[str]]`. +generics_typevartuple_args.py:42:17 Invalid type [31]: Expression `*tuple[(int, ...)]` is not a valid type. +generics_typevartuple_args.py:51:17 Invalid type [31]: Expression `*tuple[(int, *tuple[(str, ...)], str)]` is not a valid type. +generics_typevartuple_args.py:62:17 Invalid type [31]: Expression `*tuple[(int, str)]` is not a valid type. +generics_typevartuple_args.py:70:17 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_args$Ts)]` is not a valid type. +generics_typevartuple_args.py:75:12 Incompatible parameter type [6]: In call `func4`, for 2nd positional argument, expected `Tuple[]` but got `Tuple[int, int]`. Expected has length 1, but actual has length 2. +""" diff --git a/conformance/results/pyre/generics_typevartuple_basic.toml b/conformance/results/pyre/generics_typevartuple_basic.toml new file mode 100644 index 000000000..a68f9f2de --- /dev/null +++ b/conformance/results/pyre/generics_typevartuple_basic.toml @@ -0,0 +1,49 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +generics_typevartuple_basic.py:12:13 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. +generics_typevartuple_basic.py:16:17 Invalid type [31]: Expression `*$local_generics_typevartuple_basic$Ts` is not a valid type. +generics_typevartuple_basic.py:16:25 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. +generics_typevartuple_basic.py:23:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. +generics_typevartuple_basic.py:24:30 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. +generics_typevartuple_basic.py:25:21 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. +generics_typevartuple_basic.py:27:27 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. +generics_typevartuple_basic.py:36:0 Incompatible variable type [9]: v1 is declared to have type `Array[]` but is used as type `Array`. +generics_typevartuple_basic.py:36:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:36:33 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Height, Width]`. Expected has length 1, but actual has length 2. +generics_typevartuple_basic.py:37:0 Incompatible variable type [9]: v2 is declared to have type `Array[]` but is used as type `Array`. +generics_typevartuple_basic.py:37:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:37:40 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Batch, Height, Width]`. Expected has length 1, but actual has length 3. +generics_typevartuple_basic.py:38:0 Incompatible variable type [9]: v3 is declared to have type `Array[]` but is used as type `Array`. +generics_typevartuple_basic.py:38:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:39:4 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Time, Batch, Height, Width]`. Expected has length 1, but actual has length 4. +generics_typevartuple_basic.py:42:0 Incompatible variable type [9]: v4 is declared to have type `Array[]` but is used as type `Array`. +generics_typevartuple_basic.py:42:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:42:33 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Height`. +generics_typevartuple_basic.py:43:0 Incompatible variable type [9]: v5 is declared to have type `Array[]` but is used as type `Array`. +generics_typevartuple_basic.py:43:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:43:40 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Batch, Width]`. Expected has length 1, but actual has length 2. +generics_typevartuple_basic.py:44:0 Incompatible variable type [9]: v6 is declared to have type `Array[]` but is used as type `Array`. +generics_typevartuple_basic.py:44:4 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:45:4 Incompatible parameter type [6]: In call `Array.__init__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Time, Batch, Width, Height]`. Expected has length 1, but actual has length 4. +generics_typevartuple_basic.py:52:13 Undefined or invalid type [11]: Annotation `Shape` is not defined as a type. +generics_typevartuple_basic.py:54:21 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. +generics_typevartuple_basic.py:65:6 Unexpected keyword [28]: Unexpected keyword argument `covariant` to call `TypeVarTuple.__init__`. +generics_typevartuple_basic.py:66:6 Too many arguments [19]: Call `TypeVarTuple.__init__` expects 1 positional argument, 3 were provided. +generics_typevartuple_basic.py:67:6 Unexpected keyword [28]: Unexpected keyword argument `bound` to call `TypeVarTuple.__init__`. +generics_typevartuple_basic.py:75:16 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. +generics_typevartuple_basic.py:75:34 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. +generics_typevartuple_basic.py:75:49 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_basic$Ts)]` is not a valid type. +generics_typevartuple_basic.py:95:16 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. +generics_typevartuple_basic.py:95:16 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:95:34 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. +generics_typevartuple_basic.py:95:34 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:95:52 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_basic$Shape)]` is not a valid type. +generics_typevartuple_basic.py:95:52 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:99:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:99:31 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:99:48 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_basic.py:108:13 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_basic$Ts1, *$local_generics_typevartuple_basic$Ts2)]` is not a valid type. +""" diff --git a/conformance/results/pyre/generics_typevartuple_callable.toml b/conformance/results/pyre/generics_typevartuple_callable.toml new file mode 100644 index 000000000..29d49450c --- /dev/null +++ b/conformance/results/pyre/generics_typevartuple_callable.toml @@ -0,0 +1,20 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +generics_typevartuple_callable.py:17:31 Invalid type [31]: Expression `typing.Callable[([*$local_generics_typevartuple_callable$Ts], None)]` is not a valid type. +generics_typevartuple_callable.py:17:60 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_callable$Ts)]` is not a valid type. +generics_typevartuple_callable.py:25:8 Incompatible parameter type [6]: In call `Process.__init__`, for argument `target`, expected `typing.Callable[[unknown], None]` but got `typing.Callable(func1)[[Named(arg1, int), Named(arg2, str)], None]`. +generics_typevartuple_callable.py:25:22 Incompatible parameter type [6]: In call `Process.__init__`, for argument `args`, expected `Tuple[]` but got `Tuple[int, str]`. Expected has length 1, but actual has length 2. +generics_typevartuple_callable.py:26:8 Incompatible parameter type [6]: In call `Process.__init__`, for argument `target`, expected `typing.Callable[[unknown], None]` but got `typing.Callable(func1)[[Named(arg1, int), Named(arg2, str)], None]`. +generics_typevartuple_callable.py:26:22 Incompatible parameter type [6]: In call `Process.__init__`, for argument `args`, expected `Tuple[]` but got `Tuple[str, int]`. Expected has length 1, but actual has length 2. +generics_typevartuple_callable.py:29:13 Invalid type [31]: Expression `typing.Callable[([int, *$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T], tuple[($local_generics_typevartuple_callable$T, *$local_generics_typevartuple_callable$Ts)])]` is not a valid type. +generics_typevartuple_callable.py:29:56 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T)]` is not a valid type. +generics_typevartuple_callable.py:41:18 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `typing.Callable[[int, unknown, Variable[T]], Tuple[Variable[T], unknown]]` but got `typing.Callable(callback1)[[Named(a, int), Named(b, str), Named(c, int), Named(d, complex)], Tuple[complex, str, int]]`. +generics_typevartuple_callable.py:41:36 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[str], Type[int], Type[complex]]`. +generics_typevartuple_callable.py:42:18 Incompatible parameter type [6]: In call `func2`, for 1st positional argument, expected `typing.Callable[[int, unknown, Variable[T]], Tuple[Variable[T], unknown]]` but got `typing.Callable(callback2)[[Named(a, int), Named(d, str)], Tuple[str]]`. +generics_typevartuple_callable.py:45:17 Invalid type [31]: Expression `*tuple[(int, *$local_generics_typevartuple_callable$Ts, $local_generics_typevartuple_callable$T)]` is not a valid type. +generics_typevartuple_callable.py:45:42 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_callable$T, *$local_generics_typevartuple_callable$Ts)]` is not a valid type. +generics_typevartuple_callable.py:45:42 Invalid type variable [34]: The type variable `Variable[T]` isn't present in the function's parameters. +""" diff --git a/conformance/results/pyre/generics_typevartuple_concat.toml b/conformance/results/pyre/generics_typevartuple_concat.toml new file mode 100644 index 000000000..654d09802 --- /dev/null +++ b/conformance/results/pyre/generics_typevartuple_concat.toml @@ -0,0 +1,31 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +generics_typevartuple_concat.py:22:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_concat$Ts)]` is not a valid type. +generics_typevartuple_concat.py:26:22 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type. +generics_typevartuple_concat.py:26:22 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_concat.py:26:40 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape)]` is not a valid type. +generics_typevartuple_concat.py:26:40 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_concat.py:30:22 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape)]` is not a valid type. +generics_typevartuple_concat.py:30:22 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_concat.py:30:47 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type. +generics_typevartuple_concat.py:30:47 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_concat.py:34:26 Invalid type [31]: Expression `Array[(*$local_generics_typevartuple_concat$Shape)]` is not a valid type. +generics_typevartuple_concat.py:34:26 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_concat.py:34:44 Invalid type [31]: Expression `Array[(generics_typevartuple_concat.Batch, *$local_generics_typevartuple_concat$Shape, generics_typevartuple_concat.Channels)]` is not a valid type. +generics_typevartuple_concat.py:34:44 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_concat.py:38:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_concat.py:40:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[Batch], Type[Height], Type[Width]]`. Expected has length 0, but actual has length 3. +generics_typevartuple_concat.py:42:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[Height], Type[Width]]`. Expected has length 0, but actual has length 2. +generics_typevartuple_concat.py:44:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[Batch], Type[Height], Type[Width], Type[Channels]]`. Expected has length 0, but actual has length 4. +generics_typevartuple_concat.py:47:26 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_concat$Ts)]` is not a valid type. +generics_typevartuple_concat.py:47:41 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_concat$T, *$local_generics_typevartuple_concat$Ts)]` is not a valid type. +generics_typevartuple_concat.py:51:22 Incompatible parameter type [6]: In call `prefix_tuple`, for argument `y`, expected `Tuple[]` but got `Tuple[bool, str]`. Expected has length 1, but actual has length 2. +generics_typevartuple_concat.py:52:21 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[bool], Type[str]]`. +generics_typevartuple_concat.py:55:36 Invalid type [31]: Expression `tuple[($local_generics_typevartuple_concat$T, *$local_generics_typevartuple_concat$Ts)]` is not a valid type. +generics_typevartuple_concat.py:55:54 Invalid type [31]: Expression `tuple[(*$local_generics_typevartuple_concat$Ts, $local_generics_typevartuple_concat$T)]` is not a valid type. +generics_typevartuple_concat.py:56:11 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `Variable[generics_typevartuple_concat.T]`. +generics_typevartuple_concat.py:56:17 Incompatible parameter type [6]: In call `tuple.__getitem__`, for 1st positional argument, expected `typing_extensions.Literal[0]` but got `slice`. +""" diff --git a/conformance/results/pyre/generics_typevartuple_overloads.toml b/conformance/results/pyre/generics_typevartuple_overloads.toml new file mode 100644 index 000000000..faa028c5e --- /dev/null +++ b/conformance/results/pyre/generics_typevartuple_overloads.toml @@ -0,0 +1,15 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +generics_typevartuple_overloads.py:16:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_overloads$Shape)]` is not a valid type. +generics_typevartuple_overloads.py:18:24 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_overloads.py:18:50 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_overloads.py:22:24 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_overloads.py:22:57 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_overloads.py:29:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_overloads.py:29:37 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_overloads.py:30:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[TypeVar, TypeVar]`. Expected has length 0, but actual has length 2. +generics_typevartuple_overloads.py:31:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[TypeVar, TypeVar, TypeVar]`. Expected has length 0, but actual has length 3. +""" diff --git a/conformance/results/pyre/generics_typevartuple_specialization.toml b/conformance/results/pyre/generics_typevartuple_specialization.toml new file mode 100644 index 000000000..5ed025486 --- /dev/null +++ b/conformance/results/pyre/generics_typevartuple_specialization.toml @@ -0,0 +1,96 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +generics_typevartuple_specialization.py:16:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_specialization$Ts)]` is not a valid type. +generics_typevartuple_specialization.py:24:26 Invalid type [31]: Expression `Array[(*tuple[(typing.Any, ...)])]` is not a valid type. +generics_typevartuple_specialization.py:24:26 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_specialization.py:28:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_specialization.py:33:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_specialization.py:41:17 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[int], *Tuple[typing.Any, ...]]`. +generics_typevartuple_specialization.py:42:0 Incompatible variable type [9]: NamedArray is declared to have type `Type[Tuple[str, Array[]]]` but is used as type `Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:42:19 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[str], Type[Array[]]]`. +generics_typevartuple_specialization.py:45:13 Undefined or invalid type [11]: Annotation `IntTuple` is not defined as a type. +generics_typevartuple_specialization.py:45:39 Undefined or invalid type [11]: Annotation `NamedArray` is not defined as a type. +generics_typevartuple_specialization.py:46:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[float], Type[bool]]`. +generics_typevartuple_specialization.py:47:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[str], Type[Array[]]]`. +generics_typevartuple_specialization.py:47:36 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Type[Height]`. +generics_typevartuple_specialization.py:52:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[str], Type[Array[]]]`. +generics_typevartuple_specialization.py:59:13 Invalid type [31]: Expression `typing.Generic[($local_generics_typevartuple_specialization$DType, *$local_generics_typevartuple_specialization$Shape)]` is not a valid type. +generics_typevartuple_specialization.py:59:13 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[DType]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[DType]`. +generics_typevartuple_specialization.py:63:20 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `typing.Tuple[Type[float], *Tuple[typing.Any, ...]]`. +generics_typevartuple_specialization.py:64:0 Invalid type parameters [24]: Non-generic type `Array2` cannot take parameters. +generics_typevartuple_specialization.py:68:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[object, object]`. Expected has length 0, but actual has length 2. +generics_typevartuple_specialization.py:69:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[]` but got `Tuple[Type[int], object]`. Expected has length 0, but actual has length 2. +generics_typevartuple_specialization.py:72:38 Undefined or invalid type [11]: Annotation `FloatArray` is not defined as a type. +generics_typevartuple_specialization.py:89:22 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[TypeVar, *Tuple[typing.Any, ...]]`. +generics_typevartuple_specialization.py:92:13 Undefined or invalid type [11]: Annotation `VariadicTuple` is not defined as a type. +generics_typevartuple_specialization.py:93:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[str], Type[int]]`. +generics_typevartuple_specialization.py:95:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[object, typing.Any]`. +generics_typevartuple_specialization.py:101:20 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[int], *Tuple[typing.Any, ...]]`. +generics_typevartuple_specialization.py:101:20 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.TypeVar`. +generics_typevartuple_specialization.py:102:31 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.TypeVar`. +generics_typevartuple_specialization.py:103:32 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:103:39 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[float], typing.Any]`. +generics_typevartuple_specialization.py:110:16 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:110:23 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[float], typing.Any]`. +generics_typevartuple_specialization.py:117:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[*Tuple[typing.Any, ...], TypeVar, TypeVar]`. +generics_typevartuple_specialization.py:118:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[TypeVar, TypeVar, *Tuple[typing.Any, ...]]`. +generics_typevartuple_specialization.py:119:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[TypeVar, *Tuple[typing.Any, ...], TypeVar, TypeVar]`. +generics_typevartuple_specialization.py:120:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[TypeVar, TypeVar, *Tuple[typing.Any, ...]]`. +generics_typevartuple_specialization.py:120:12 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:120:27 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], typing.Any]`. +generics_typevartuple_specialization.py:121:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[typing.Any, ...]`. +generics_typevartuple_specialization.py:121:12 Unable to concatenate tuple [60]: Concatenation not yet support for multiple variadic tuples: `*Ts, *Ts`. +generics_typevartuple_specialization.py:122:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[typing.Any, ...]`. +generics_typevartuple_specialization.py:122:12 Unable to concatenate tuple [60]: Concatenation not yet support for multiple variadic tuples: `*Ts, *tuple[(int, ...)]`. +generics_typevartuple_specialization.py:122:12 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:122:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], typing.Any]`. +generics_typevartuple_specialization.py:125:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[*Tuple[typing.Any, ...], TypeVar, TypeVar]`. +generics_typevartuple_specialization.py:127:4 Undefined or invalid type [11]: Annotation `TA7` is not defined as a type. +generics_typevartuple_specialization.py:130:13 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA7[(*$local_generics_typevartuple_specialization$Ts, $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2)]` is not a valid type. +generics_typevartuple_specialization.py:130:13 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:130:13 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:130:34 Invalid type [31]: Expression `tuple[(tuple[(*$local_generics_typevartuple_specialization$Ts)], $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2)]` is not a valid type. +generics_typevartuple_specialization.py:130:34 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:130:34 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:135:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[tuple[Variable[_T_co](covariant)]], Type[str], Type[bool]]`. +generics_typevartuple_specialization.py:135:38 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[]`. +generics_typevartuple_specialization.py:136:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[tuple[str]], Type[bool], Type[float]]`. +generics_typevartuple_specialization.py:137:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[tuple[Variable[_T_co](covariant)]], Type[float], Type[int]]`. +generics_typevartuple_specialization.py:137:38 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[str], Type[bool]]`. +generics_typevartuple_specialization.py:140:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[TypeVar, *Tuple[typing.Any, ...], TypeVar, TypeVar]`. +generics_typevartuple_specialization.py:143:13 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA8[($local_generics_typevartuple_specialization$T1, *$local_generics_typevartuple_specialization$Ts, $local_generics_typevartuple_specialization$T2, $local_generics_typevartuple_specialization$T3)]` is not a valid type. +generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:143:13 Invalid type variable [34]: The type variable `Variable[T3]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:143:13 Undefined or invalid type [11]: Annotation `TA8` is not defined as a type. +generics_typevartuple_specialization.py:143:38 Invalid type [31]: Expression `tuple[(tuple[(*$local_generics_typevartuple_specialization$Ts)], $local_generics_typevartuple_specialization$T1, $local_generics_typevartuple_specialization$T2, $local_generics_typevartuple_specialization$T3)]` is not a valid type. +generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T1]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T2]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:143:38 Invalid type variable [34]: The type variable `Variable[T3]` isn't present in the function's parameters. +generics_typevartuple_specialization.py:148:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[tuple[Variable[_T_co](covariant)]], Type[str], Type[bool], Type[float]]`. +generics_typevartuple_specialization.py:148:38 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[]`. +generics_typevartuple_specialization.py:149:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[tuple[bool]], Type[str], Type[float], Type[int]]`. +generics_typevartuple_specialization.py:152:12 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[*Tuple[typing.Any, ...], TypeVar]`. +generics_typevartuple_specialization.py:153:11 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:153:18 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], typing.Any]`. +generics_typevartuple_specialization.py:156:14 Undefined or invalid type [11]: Annotation `TA10` is not defined as a type. +generics_typevartuple_specialization.py:156:23 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA9[(*tuple[(int, ...)], str)]` is not a valid type. +generics_typevartuple_specialization.py:156:23 Undefined or invalid type [11]: Annotation `TA9` is not defined as a type. +generics_typevartuple_specialization.py:156:54 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA9[(str, *tuple[(int, ...)])]` is not a valid type. +generics_typevartuple_specialization.py:157:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[*Tuple[typing.Any, ...], Type[int]]`. +generics_typevartuple_specialization.py:157:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:157:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], typing.Any]`. +generics_typevartuple_specialization.py:158:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[*Tuple[typing.Any, ...], Type[str]]`. +generics_typevartuple_specialization.py:158:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:158:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], typing.Any]`. +generics_typevartuple_specialization.py:159:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[str], *Tuple[typing.Any, ...], Type[int]]`. +generics_typevartuple_specialization.py:159:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_specialization.py:159:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], typing.Any]`. +generics_typevartuple_specialization.py:162:13 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[TypeVar, *Tuple[typing.Any, ...]]`. +generics_typevartuple_specialization.py:162:13 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.TypeVar`. +generics_typevartuple_specialization.py:163:4 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA11[(*$local_generics_typevartuple_specialization$Ts2)]` is not a valid type. +generics_typevartuple_specialization.py:163:4 Undefined or invalid type [11]: Annotation `TA11` is not defined as a type. +""" diff --git a/conformance/results/pyre/generics_typevartuple_unpack.toml b/conformance/results/pyre/generics_typevartuple_unpack.toml new file mode 100644 index 000000000..a1edd778f --- /dev/null +++ b/conformance/results/pyre/generics_typevartuple_unpack.toml @@ -0,0 +1,31 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +generics_typevartuple_unpack.py:12:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool, bool)], str)]` is not a valid type. +generics_typevartuple_unpack.py:13:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[bool], Type[bool], Type[str]]`. +generics_typevartuple_unpack.py:14:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[*Tuple[typing.Any, ...], Type[bool], Type[str]]`. +generics_typevartuple_unpack.py:14:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_unpack.py:14:32 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], Type[bool]]`. +generics_typevartuple_unpack.py:15:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[int], Type[bool], *Tuple[typing.Any, ...]]`. +generics_typevartuple_unpack.py:15:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_unpack.py:15:43 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[bool], Type[str]]`. +generics_typevartuple_unpack.py:21:13 Invalid type [31]: Expression `tuple[(int, *tuple[(bool, ...)], str)]` is not a valid type. +generics_typevartuple_unpack.py:22:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[int], *Tuple[typing.Any, ...], Type[str]]`. +generics_typevartuple_unpack.py:22:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. +generics_typevartuple_unpack.py:22:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[bool], typing.Any]`. +generics_typevartuple_unpack.py:33:12 Invalid type [31]: Expression `typing.Generic[(*$local_generics_typevartuple_unpack$Ts)]` is not a valid type. +generics_typevartuple_unpack.py:37:30 Invalid type [31]: Expression `Array[(generics_typevartuple_unpack.Batch, *tuple[(typing.Any, ...)], generics_typevartuple_unpack.Channels)]` is not a valid type. +generics_typevartuple_unpack.py:37:30 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_unpack.py:42:7 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_unpack.py:42:49 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_unpack.py:42:76 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_unpack.py:52:29 Invalid type [31]: Expression `Array[(generics_typevartuple_unpack.Batch, *$local_generics_typevartuple_unpack$Shape)]` is not a valid type. +generics_typevartuple_unpack.py:52:29 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_unpack.py:56:28 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_unpack.py:60:13 Invalid type [31]: Expression `Array[(*tuple[(typing.Any, ...)])]` is not a valid type. +generics_typevartuple_unpack.py:60:13 Invalid type parameters [24]: Non-generic type `Array` cannot take parameters. +generics_typevartuple_unpack.py:67:6 Invalid type [31]: Expression `tuple[(*tuple[int], *tuple[int])]` is not a valid type. +generics_typevartuple_unpack.py:68:6 Invalid type [31]: Expression `tuple[(*tuple[(int, ...)], *tuple[int])]` is not a valid type. +""" diff --git a/conformance/results/pyre/generics_variance.toml b/conformance/results/pyre/generics_variance.toml new file mode 100644 index 000000000..ad32809b3 --- /dev/null +++ b/conformance/results/pyre/generics_variance.toml @@ -0,0 +1,7 @@ +conformant = "Partial" +notes = """ +Does not reject a TypeVar that is defined as both covariant and contravariant. +Does not reject a function-scoped TypeVar that is marked as covariant or contravariant. +""" +output = """ +""" diff --git a/conformance/results/pyre/generics_variance_inference.toml b/conformance/results/pyre/generics_variance_inference.toml new file mode 100644 index 000000000..71f27f7a6 --- /dev/null +++ b/conformance/results/pyre/generics_variance_inference.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +generics_variance_inference.py:15:13 Parsing failure [404]: invalid syntax +""" diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml index 1045fff1a..e5c2ca0f6 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.1209452152252197 +test_duration = 2.2906670570373535 diff --git a/conformance/results/pyright/generics_paramspec_basic.toml b/conformance/results/pyright/generics_paramspec_basic.toml new file mode 100644 index 000000000..23e6b60ce --- /dev/null +++ b/conformance/results/pyright/generics_paramspec_basic.toml @@ -0,0 +1,16 @@ +conformant = "Partial" +notes = """ +Does not reject the use of Concatenate outside of a Callable annotation. +""" +output = """ +generics_paramspec_basic.py:10:1 - error: ParamSpec must be assigned to a variable named "NotIt" +generics_paramspec_basic.py:15:18 - error: ParamSpec is not allowed in this context +generics_paramspec_basic.py:23:14 - error: ParamSpec is not allowed in this context +generics_paramspec_basic.py:23:20 - error: ParamSpec is not allowed in this context +generics_paramspec_basic.py:31:19 - error: Type "P@func3" cannot be assigned to type variable "_T@list" +  ParamSpec is not allowed in this context (reportGeneralTypeIssues) +generics_paramspec_basic.py:35:35 - error: ParamSpec is not allowed in this context +generics_paramspec_basic.py:39:18 - error: ParamSpec is not allowed in this context +generics_paramspec_basic.py:39:31 - error: ParamSpec is not allowed in this context +generics_paramspec_basic.py:31:5 - error: Function declaration "func3" is obscured by a declaration of the same name (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_paramspec_components.toml b/conformance/results/pyright/generics_paramspec_components.toml new file mode 100644 index 000000000..713ab1165 --- /dev/null +++ b/conformance/results/pyright/generics_paramspec_components.toml @@ -0,0 +1,25 @@ +conformant = "Pass" +output = """ +generics_paramspec_components.py:17:25 - error: "kwargs" member of ParamSpec is valid only when used with **kwargs parameter +generics_paramspec_components.py:17:45 - error: "args" member of ParamSpec is valid only when used with *args parameter +generics_paramspec_components.py:20:23 - error: "args" member of ParamSpec is valid only when used with *args parameter +generics_paramspec_components.py:23:46 - error: "args" member of ParamSpec is valid only when used with *args parameter +generics_paramspec_components.py:23:28 - error: "args" and "kwargs" members of ParamSpec must both appear within a function signature +generics_paramspec_components.py:26:28 - error: "args" and "kwargs" members of ParamSpec must both appear within a function signature +generics_paramspec_components.py:30:25 - error: ParamSpec "P" has no meaning in this context (reportGeneralTypeIssues) +generics_paramspec_components.py:30:43 - error: ParamSpec "P" has no meaning in this context (reportGeneralTypeIssues) +generics_paramspec_components.py:35:18 - error: "args" member of ParamSpec is valid only when used with *args parameter +generics_paramspec_components.py:36:20 - error: "kwargs" member of ParamSpec is valid only when used with **kwargs parameter +generics_paramspec_components.py:38:26 - error: "args" and "kwargs" members of ParamSpec must both appear within a function signature +generics_paramspec_components.py:41:31 - error: "args" and "kwargs" members of ParamSpec must both appear within a function signature +generics_paramspec_components.py:49:9 - error: Arguments for ParamSpec "P@decorator" are missing (reportGeneralTypeIssues) +generics_paramspec_components.py:51:11 - error: Expected 0 positional arguments (reportGeneralTypeIssues) +generics_paramspec_components.py:60:28 - error: Keyword parameter "s" cannot appear in signature after ParamSpec args parameter (reportGeneralTypeIssues) +generics_paramspec_components.py:70:12 - error: Expected 1 positional argument (reportGeneralTypeIssues) +generics_paramspec_components.py:72:12 - error: Expected 1 positional argument (reportGeneralTypeIssues) +generics_paramspec_components.py:83:19 - error: Expected 2 positional arguments (reportGeneralTypeIssues) +generics_paramspec_components.py:98:20 - error: Argument of type "Literal['A']" cannot be assigned to parameter "a" of type "int" +  "Literal['A']" is incompatible with "int" (reportGeneralTypeIssues) +generics_paramspec_components.py:98:25 - error: Argument of type "Literal[1]" cannot be assigned to parameter "b" of type "str" +  "Literal[1]" is incompatible with "str" (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_paramspec_semantics.toml b/conformance/results/pyright/generics_paramspec_semantics.toml new file mode 100644 index 000000000..6df1f52a8 --- /dev/null +++ b/conformance/results/pyright/generics_paramspec_semantics.toml @@ -0,0 +1,35 @@ +conformant = "Partial" +notes = """ +Constraint solver doesn't find common type for two signatures captured by a single ParamSpec. +Evaluates incorrect type when evaluating constructor call for generic class parameterized by ParamSpec. +""" +output = """ +generics_paramspec_semantics.py:26:6 - error: Expected 2 more positional arguments (reportGeneralTypeIssues) +generics_paramspec_semantics.py:27:9 - error: Argument of type "Literal['A']" cannot be assigned to parameter "b" of type "bool" +  "Literal['A']" is incompatible with "bool" (reportGeneralTypeIssues) +generics_paramspec_semantics.py:46:17 - error: Argument of type "(y: int, x: str) -> int" cannot be assigned to parameter "y" of type "(**P@func1) -> int" in function "func1" +  Type "(y: int, x: str) -> int" cannot be assigned to type "(x: int, y: str) -> int" +    Parameter name mismatch: "x" versus "y" +    Parameter name mismatch: "y" versus "x" (reportGeneralTypeIssues) +generics_paramspec_semantics.py:61:23 - error: Argument of type "(*, y: int) -> int" cannot be assigned to parameter "y" of type "(**P@func1) -> int" in function "func1" +  Type "(*, y: int) -> int" cannot be assigned to type "(*, x: int) -> int" +    Keyword parameter "y" is missing in destination +    Keyword parameter "x" is missing in source (reportGeneralTypeIssues) +generics_paramspec_semantics.py:81:13 - error: "assert_type" mismatch: expected "Y[int, (int)]" but received "Y[int, (q: int, /)]" (reportGeneralTypeIssues) +generics_paramspec_semantics.py:97:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str" +  "Literal[1]" is incompatible with "str" (reportGeneralTypeIssues) +generics_paramspec_semantics.py:107:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter "args" of type "bool" +  "Literal[1]" is incompatible with "bool" (reportGeneralTypeIssues) +generics_paramspec_semantics.py:119:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str" +  "Literal[1]" is incompatible with "str" (reportGeneralTypeIssues) +generics_paramspec_semantics.py:126:2 - error: Argument of type "(x: str) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" +  Type "(x: str) -> int" cannot be assigned to type "(int, **P@expects_int_first) -> int" +    Parameter 1: type "int" cannot be assigned to type "str" +      "int" is incompatible with "str" (reportGeneralTypeIssues) +generics_paramspec_semantics.py:131:2 - error: Argument of type "(*, x: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" +  Type "(*, x: int) -> int" cannot be assigned to type "(int, **P@expects_int_first) -> int" +    Function accepts too many positional parameters; expected 0 but received 1 (reportGeneralTypeIssues) +generics_paramspec_semantics.py:136:2 - error: Argument of type "(**kwargs: int) -> int" cannot be assigned to parameter "x" of type "(int, **P@expects_int_first) -> int" in function "expects_int_first" +  Type "(**kwargs: int) -> int" cannot be assigned to type "(int, **P@expects_int_first) -> int" +    Function accepts too many positional parameters; expected 0 but received 1 (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_paramspec_specialization.toml b/conformance/results/pyright/generics_paramspec_specialization.toml new file mode 100644 index 000000000..10ab9ed9b --- /dev/null +++ b/conformance/results/pyright/generics_paramspec_specialization.toml @@ -0,0 +1,13 @@ +conformant = "Pass" +output = """ +generics_paramspec_specialization.py:45:27 - error: Type "int" cannot be assigned to type variable "P1@ClassA" +  Type "int" is incompatible with ParamSpec "P1@ClassA" (reportGeneralTypeIssues) +generics_paramspec_specialization.py:55:9 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "int" +  "Literal['']" is incompatible with "int" (reportGeneralTypeIssues) +generics_paramspec_specialization.py:56:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "bool" +  "Literal['']" is incompatible with "bool" (reportGeneralTypeIssues) +generics_paramspec_specialization.py:61:9 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "int" +  "Literal['']" is incompatible with "int" (reportGeneralTypeIssues) +generics_paramspec_specialization.py:62:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "bool" +  "Literal['']" is incompatible with "bool" (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_syntax_autovariance.toml b/conformance/results/pyright/generics_syntax_autovariance.toml new file mode 100644 index 000000000..8f9fb5f9b --- /dev/null +++ b/conformance/results/pyright/generics_syntax_autovariance.toml @@ -0,0 +1,2 @@ +output = """ +""" diff --git a/conformance/results/pyright/generics_syntax_compatibility.toml b/conformance/results/pyright/generics_syntax_compatibility.toml new file mode 100644 index 000000000..533aef8ae --- /dev/null +++ b/conformance/results/pyright/generics_syntax_compatibility.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +output = """ +generics_syntax_compatibility.py:14:22 - error: Type parameter "K" is not included in the type parameter list for "ClassA" (reportGeneralTypeIssues) +generics_syntax_compatibility.py:26:35 - error: Type parameter "K" is not included in the type parameter list for "method2" (reportGeneralTypeIssues) +generics_syntax_compatibility.py:26:45 - error: Type parameter "K" is not included in the type parameter list for "method2" (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_syntax_declarations.toml b/conformance/results/pyright/generics_syntax_declarations.toml new file mode 100644 index 000000000..b176885d4 --- /dev/null +++ b/conformance/results/pyright/generics_syntax_declarations.toml @@ -0,0 +1,14 @@ +conformant = "Pass" +output = """ +generics_syntax_declarations.py:19:17 - error: "Generic" base class cannot be used with type parameter syntax (reportGeneralTypeIssues) +generics_syntax_declarations.py:23:20 - error: Type arguments are not allowed with Protocol class when using type parameter syntax (reportGeneralTypeIssues) +generics_syntax_declarations.py:30:11 - error: Cannot access member "is_integer" for type "str*" +  Member "is_integer" is unknown (reportGeneralTypeIssues) +generics_syntax_declarations.py:42:21 - error: TypeVar constraint type cannot be generic +generics_syntax_declarations.py:46:17 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) +generics_syntax_declarations.py:58:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) +generics_syntax_declarations.py:62:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) +generics_syntax_declarations.py:69:17 - error: Expected type expression but received "tuple[type[bytes], type[str]]" (reportGeneralTypeIssues) +generics_syntax_declarations.py:73:18 - error: Expected type expression but received "Literal[3]" (reportGeneralTypeIssues) +generics_syntax_declarations.py:77:23 - error: "S" is not defined (reportUndefinedVariable) +""" diff --git a/conformance/results/pyright/generics_syntax_infer_variance.toml b/conformance/results/pyright/generics_syntax_infer_variance.toml new file mode 100644 index 000000000..abb315d07 --- /dev/null +++ b/conformance/results/pyright/generics_syntax_infer_variance.toml @@ -0,0 +1,59 @@ +conformant = "Pass" +output = """ +generics_syntax_infer_variance.py:16:42 - error: TypeVar cannot be both covariant and contravariant +generics_syntax_infer_variance.py:20:46 - error: TypeVar cannot be both covariant and contravariant +generics_syntax_infer_variance.py:33:35 - error: Expression of type "ShouldBeCovariant1[float]" cannot be assigned to declared type "ShouldBeCovariant1[int]" +  "ShouldBeCovariant1[float]" is incompatible with "ShouldBeCovariant1[int]" +    Type parameter "T@ShouldBeCovariant1" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:41:35 - error: Expression of type "ShouldBeCovariant2[float]" cannot be assigned to declared type "ShouldBeCovariant2[int]" +  "ShouldBeCovariant2[float]" is incompatible with "ShouldBeCovariant2[int]" +    Type parameter "T@ShouldBeCovariant2" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:50:35 - error: Expression of type "ShouldBeCovariant3[float]" cannot be assigned to declared type "ShouldBeCovariant3[int]" +  "ShouldBeCovariant3[float]" is incompatible with "ShouldBeCovariant3[int]" +    Type parameter "T@ShouldBeCovariant3" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:59:34 - error: Expression of type "ShouldBeCovariant4[float]" cannot be assigned to declared type "ShouldBeCovariant4[int]" +  "ShouldBeCovariant4[float]" is incompatible with "ShouldBeCovariant4[int]" +    Type parameter "T@ShouldBeCovariant4" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:72:34 - error: Expression of type "ShouldBeCovariant5[float]" cannot be assigned to declared type "ShouldBeCovariant5[int]" +  "ShouldBeCovariant5[float]" is incompatible with "ShouldBeCovariant5[int]" +    Type parameter "T@ShouldBeCovariant5" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:88:38 - error: Expression of type "ShouldBeInvariant1[int]" cannot be assigned to declared type "ShouldBeInvariant1[float]" +  "ShouldBeInvariant1[int]" is incompatible with "ShouldBeInvariant1[float]" +    Type parameter "T@ShouldBeInvariant1" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:89:36 - error: Expression of type "ShouldBeInvariant1[float]" cannot be assigned to declared type "ShouldBeInvariant1[int]" +  "ShouldBeInvariant1[float]" is incompatible with "ShouldBeInvariant1[int]" +    Type parameter "T@ShouldBeInvariant1" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:103:38 - error: Expression of type "ShouldBeInvariant2[int]" cannot be assigned to declared type "ShouldBeInvariant2[float]" +  "ShouldBeInvariant2[int]" is incompatible with "ShouldBeInvariant2[float]" +    Type parameter "T@ShouldBeInvariant2" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:104:36 - error: Expression of type "ShouldBeInvariant2[float]" cannot be assigned to declared type "ShouldBeInvariant2[int]" +  "ShouldBeInvariant2[float]" is incompatible with "ShouldBeInvariant2[int]" +    Type parameter "T@ShouldBeInvariant2" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:111:43 - error: Expression of type "ShouldBeInvariant3[int, str]" cannot be assigned to declared type "ShouldBeInvariant3[float, str]" +  "ShouldBeInvariant3[int, str]" is incompatible with "ShouldBeInvariant3[float, str]" +    Type parameter "K@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:112:41 - error: Expression of type "ShouldBeInvariant3[float, str]" cannot be assigned to declared type "ShouldBeInvariant3[int, str]" +  "ShouldBeInvariant3[float, str]" is incompatible with "ShouldBeInvariant3[int, str]" +    Type parameter "K@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:113:43 - error: Expression of type "ShouldBeInvariant3[str, int]" cannot be assigned to declared type "ShouldBeInvariant3[str, float]" +  "ShouldBeInvariant3[str, int]" is incompatible with "ShouldBeInvariant3[str, float]" +    Type parameter "V@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:114:41 - error: Expression of type "ShouldBeInvariant3[str, float]" cannot be assigned to declared type "ShouldBeInvariant3[str, int]" +  "ShouldBeInvariant3[str, float]" is incompatible with "ShouldBeInvariant3[str, int]" +    Type parameter "V@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:122:38 - error: Expression of type "ShouldBeInvariant4[int]" cannot be assigned to declared type "ShouldBeInvariant4[float]" +  "ShouldBeInvariant4[int]" is incompatible with "ShouldBeInvariant4[float]" +    Type parameter "T@ShouldBeInvariant4" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:130:38 - error: Expression of type "ShouldBeInvariant5[int]" cannot be assigned to declared type "ShouldBeInvariant5[float]" +  "ShouldBeInvariant5[int]" is incompatible with "ShouldBeInvariant5[float]" +    Type parameter "T@ShouldBeInvariant5" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:141:45 - error: Expression of type "ShouldBeContravariant1[int]" cannot be assigned to declared type "ShouldBeContravariant1[float]" +  "ShouldBeContravariant1[int]" is incompatible with "ShouldBeContravariant1[float]" +    Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_syntax_scoping.toml b/conformance/results/pyright/generics_syntax_scoping.toml new file mode 100644 index 000000000..abd6e08b9 --- /dev/null +++ b/conformance/results/pyright/generics_syntax_scoping.toml @@ -0,0 +1,19 @@ +conformant = "Partial" +notes = """ +Does not evaluate correct type for variables that shadow type parameters. +""" +output = """ +generics_syntax_scoping.py:92:17 - error: Type parameter "T" is already in use +generics_syntax_scoping.py:95:17 - error: Type parameter "T" is already in use +generics_syntax_scoping.py:98:17 - error: Type parameter "T" is already in use +generics_syntax_scoping.py:14:29 - error: "S" is not defined (reportUndefinedVariable) +generics_syntax_scoping.py:18:26 - error: "T" is not defined (reportUndefinedVariable) +generics_syntax_scoping.py:35:7 - error: "T" is not defined (reportUndefinedVariable) +generics_syntax_scoping.py:44:17 - error: "T" is not defined (reportUndefinedVariable) +generics_syntax_scoping.py:62:25 - error: "assert_type" mismatch: expected "str" but received "TypeVar" (reportGeneralTypeIssues) +generics_syntax_scoping.py:67:25 - error: "assert_type" mismatch: expected "int" but received "TypeVar" (reportGeneralTypeIssues) +generics_syntax_scoping.py:108:17 - error: "assert_type" mismatch: expected "int" but received "TypeVar" (reportGeneralTypeIssues) +generics_syntax_scoping.py:113:21 - error: "assert_type" mismatch: expected "str" but received "TypeVar" (reportGeneralTypeIssues) +generics_syntax_scoping.py:121:21 - error: "assert_type" mismatch: expected "complex" but received "TypeVar" (reportGeneralTypeIssues) +generics_syntax_scoping.py:124:25 - error: "assert_type" mismatch: expected "complex" but received "TypeVar" (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_typevartuple_args.toml b/conformance/results/pyright/generics_typevartuple_args.toml new file mode 100644 index 000000000..a138ad422 --- /dev/null +++ b/conformance/results/pyright/generics_typevartuple_args.toml @@ -0,0 +1,20 @@ +conformant = "Partial" +notes = """ +Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?). +""" +output = """ +generics_typevartuple_args.py:33:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "Env" in function "exec_le" +  "Literal['']" is incompatible with "Env" (reportGeneralTypeIssues) +generics_typevartuple_args.py:34:16 - error: Argument of type "Literal['']" cannot be assigned to parameter of type "Env" in function "exec_le" +  "Literal['']" is incompatible with "Env" (reportGeneralTypeIssues) +generics_typevartuple_args.py:48:10 - error: Argument of type "Literal['2']" cannot be assigned to parameter of type "int" in function "func1" +  "Literal['2']" is incompatible with "int" (reportGeneralTypeIssues) +generics_typevartuple_args.py:57:10 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str" in function "func2" +  "Literal[1]" is incompatible with "str" (reportGeneralTypeIssues) +generics_typevartuple_args.py:58:1 - error: Argument missing for parameter "args[2]" (reportGeneralTypeIssues) +generics_typevartuple_args.py:59:1 - error: Argument missing for parameter "args[2]" (reportGeneralTypeIssues) +generics_typevartuple_args.py:67:1 - error: Argument missing for parameter "args[1]" (reportGeneralTypeIssues) +generics_typevartuple_args.py:75:13 - error: Argument of type "tuple[Literal[1], Literal[2]]" cannot be assigned to parameter "args" of type "tuple[*Ts@func4]" in function "func4" +  "tuple[Literal[1], Literal[2]]" is incompatible with "tuple[int]" +    Tuple size mismatch; expected 1 but received 2 (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_typevartuple_basic.toml b/conformance/results/pyright/generics_typevartuple_basic.toml new file mode 100644 index 000000000..cfc00fa4a --- /dev/null +++ b/conformance/results/pyright/generics_typevartuple_basic.toml @@ -0,0 +1,34 @@ +conformant = "Partial" +notes = """ +Does not reject value constraints when constructing TypeVarTuple. +Does not enforce that tuples captured by TypeVarTuple are same length (spec bug?). +Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?). +""" +output = """ +generics_typevartuple_basic.py:42:34 - error: Argument of type "Height" cannot be assigned to parameter "shape" of type "tuple[*Shape@Array]" in function "__init__" +  "Height" is incompatible with "tuple[*Shape@Array]" (reportGeneralTypeIssues) +generics_typevartuple_basic.py:43:35 - error: Expression of type "Array[Batch, Width]" cannot be assigned to declared type "Array[Batch, Height, Width]" +  "Array[Batch, Width]" is incompatible with "Array[Batch, Height, Width]" +    Type parameter "Shape@Array" is invariant, but "*tuple[Batch, Width]" is not the same as "*tuple[Batch, Height, Width]" (reportGeneralTypeIssues) +generics_typevartuple_basic.py:44:41 - error: Expression of type "Array[Time, Batch, Width, Height]" cannot be assigned to declared type "Array[Time, Batch, Height, Width]" +  "Array[Time, Batch, Width, Height]" is incompatible with "Array[Time, Batch, Height, Width]" +    Type parameter "Shape@Array" is invariant, but "*tuple[Time, Batch, Width, Height]" is not the same as "*tuple[Time, Batch, Height, Width]" (reportGeneralTypeIssues) +generics_typevartuple_basic.py:52:22 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape +generics_typevartuple_basic.py:53:37 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape +generics_typevartuple_basic.py:56:34 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape +generics_typevartuple_basic.py:59:24 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape +generics_typevartuple_basic.py:65:27 - error: "covariant" is unknown parameter to TypeVarTuple +generics_typevartuple_basic.py:67:27 - error: "bound" is unknown parameter to TypeVarTuple +generics_typevartuple_basic.py:87:13 - error: "assert_type" mismatch: expected "tuple[int]" but received "tuple[tuple[Literal[0]], tuple[Literal[1]]]" (reportGeneralTypeIssues) +generics_typevartuple_basic.py:101:14 - error: Argument of type "Array[Height]" cannot be assigned to parameter "x" of type "Array[*Shape@multiply]" in function "multiply" +  "Array[Height]" is incompatible with "Array[Height | Width]" +    Type parameter "Shape@Array" is invariant, but "*tuple[Height]" is not the same as "*tuple[Height | Width]" (reportGeneralTypeIssues) +generics_typevartuple_basic.py:101:17 - error: Argument of type "Array[Width]" cannot be assigned to parameter "y" of type "Array[*Shape@multiply]" in function "multiply" +  "Array[Width]" is incompatible with "Array[Height | Width]" +    Type parameter "Shape@Array" is invariant, but "*tuple[Width]" is not the same as "*tuple[Height | Width]" (reportGeneralTypeIssues) +generics_typevartuple_basic.py:102:17 - error: Argument of type "Array[Height, Width]" cannot be assigned to parameter "y" of type "Array[*Shape@multiply]" in function "multiply" +  "Array[Height, Width]" is incompatible with "Array[Height]" +    Type parameter "Shape@Array" is invariant, but "*tuple[Height, Width]" is not the same as "*tuple[Height]" (reportGeneralTypeIssues) +generics_typevartuple_basic.py:108:29 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple +generics_typevartuple_basic.py:108:14 - error: Generic class can have at most one TypeVarTuple type parameter but received multiple ("Ts1", "Ts2") +""" diff --git a/conformance/results/pyright/generics_typevartuple_callable.toml b/conformance/results/pyright/generics_typevartuple_callable.toml new file mode 100644 index 000000000..088acbfa9 --- /dev/null +++ b/conformance/results/pyright/generics_typevartuple_callable.toml @@ -0,0 +1,6 @@ +conformant = "Pass" +output = """ +generics_typevartuple_callable.py:26:28 - error: Argument of type "tuple[Literal[''], Literal[0]]" cannot be assigned to parameter "args" of type "tuple[*Ts@__init__]" in function "__init__" +  "Literal['']" is incompatible with "int" +  "Literal[0]" is incompatible with "str" (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_typevartuple_concat.toml b/conformance/results/pyright/generics_typevartuple_concat.toml new file mode 100644 index 000000000..932125cda --- /dev/null +++ b/conformance/results/pyright/generics_typevartuple_concat.toml @@ -0,0 +1,10 @@ +conformant = "Partial" +notes = """ +Does not support tuple slicing when tuple type includes TypeVarTuple. +""" +output = """ +generics_typevartuple_concat.py:56:12 - error: Expression of type "tuple[*tuple[T@move_first_element_to_last | Union[*Ts@move_first_element_to_last], ...], T@move_first_element_to_last]" cannot be assigned to return type "tuple[*Ts@move_first_element_to_last, T@move_first_element_to_last]" +  "tuple[*tuple[T@move_first_element_to_last | Union[*Ts@move_first_element_to_last], ...], T@move_first_element_to_last]" is incompatible with "tuple[*Ts@move_first_element_to_last, T@move_first_element_to_last]" +    Tuple entry 1 is incorrect type +      Type "*tuple[T@move_first_element_to_last | Union[*Ts@move_first_element_to_last], ...]" cannot be assigned to type "*Ts@move_first_element_to_last" (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/generics_typevartuple_overloads.toml b/conformance/results/pyright/generics_typevartuple_overloads.toml new file mode 100644 index 000000000..2146548eb --- /dev/null +++ b/conformance/results/pyright/generics_typevartuple_overloads.toml @@ -0,0 +1,3 @@ +conformant = "Pass" +output = """ +""" diff --git a/conformance/results/pyright/generics_typevartuple_specialization.toml b/conformance/results/pyright/generics_typevartuple_specialization.toml new file mode 100644 index 000000000..e429b7001 --- /dev/null +++ b/conformance/results/pyright/generics_typevartuple_specialization.toml @@ -0,0 +1,18 @@ +conformant = "Partial" +notes = """ +Incorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`. +Does not reject specialization of TypeVar in generic type alias when unpacked tuple is specified as type argument. +Does not reject specialization of generic type alias when number of type arguments is too few. +Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar. +""" +output = """ +generics_typevartuple_specialization.py:95:17 - error: "assert_type" mismatch: expected "tuple[Any, ...]" but received "tuple[Unknown, Unknown]" (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:102:40 - error: Too many type arguments provided for "IntTupleVar[Ts1@IntTupleVar]"; expected 1 but received 2 +generics_typevartuple_specialization.py:109:18 - error: Type variable "Ts" has no meaning in this context (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:121:27 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple +generics_typevartuple_specialization.py:122:27 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple +generics_typevartuple_specialization.py:157:17 - error: "assert_type" mismatch: expected "tuple[*tuple[int, ...], int]" but received "tuple[*tuple[int, ...]]" (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:159:17 - error: "assert_type" mismatch: expected "tuple[str, *tuple[int, ...], int]" but received "tuple[str, *tuple[int, ...]]" (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:163:11 - error: Type variable "Ts2" has no meaning in this context (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:163:10 - error: Too few type arguments provided for "TA11[T@TA11, Ts1@TA11]"; expected 2 but received 1 +""" diff --git a/conformance/results/pyright/generics_typevartuple_unpack.toml b/conformance/results/pyright/generics_typevartuple_unpack.toml new file mode 100644 index 000000000..4e0cf668f --- /dev/null +++ b/conformance/results/pyright/generics_typevartuple_unpack.toml @@ -0,0 +1,14 @@ +conformant = "Partial" +notes = """ +Does not treat `tuple[Any, ...]` as having an arbitrary length. +""" +output = """ +generics_typevartuple_unpack.py:46:28 - error: Argument of type "Array[Batch]" cannot be assigned to parameter "x" of type "Array[Batch, *tuple[Any, ...], Channels]" in function "process_batch_channels" +  "Array[Batch]" is incompatible with "Array[Batch, *tuple[Any, ...], Channels]" +    Type parameter "Ts@Array" is invariant, but "*tuple[Batch]" is not the same as "*tuple[Batch, *tuple[Any, ...], Channels]" (reportGeneralTypeIssues) +generics_typevartuple_unpack.py:62:26 - error: Argument of type "Array[*tuple[Any, ...]]" cannot be assigned to parameter "x" of type "Array[Batch, Height, Width, Channels]" in function "expect_precise_array" +  "Array[*tuple[Any, ...]]" is incompatible with "Array[Batch, Height, Width, Channels]" +    Type parameter "Ts@Array" is invariant, but "*tuple[Any, ...]" is not the same as "*tuple[Batch, Height, Width, Channels]" (reportGeneralTypeIssues) +generics_typevartuple_unpack.py:67:27 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple +generics_typevartuple_unpack.py:68:32 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple +""" diff --git a/conformance/results/pyright/generics_variance.toml b/conformance/results/pyright/generics_variance.toml new file mode 100644 index 000000000..2539080d0 --- /dev/null +++ b/conformance/results/pyright/generics_variance.toml @@ -0,0 +1,7 @@ +conformant = "Partial" +notes = """ +Does not reject a function-scoped TypeVar that is marked as covariant or contravariant. +""" +output = """ +generics_variance.py:14:50 - error: TypeVar cannot be both covariant and contravariant +""" diff --git a/conformance/results/pyright/generics_variance_inference.toml b/conformance/results/pyright/generics_variance_inference.toml new file mode 100644 index 000000000..475bf2c9a --- /dev/null +++ b/conformance/results/pyright/generics_variance_inference.toml @@ -0,0 +1,86 @@ +conformant = "Pass" +output = """ +generics_variance_inference.py:24:33 - error: Expression of type "ClassA[float, int, int]" cannot be assigned to declared type "ClassA[int, int, int]" +  "ClassA[float, int, int]" is incompatible with "ClassA[int, int, int]" +    Type parameter "T1@ClassA" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_variance_inference.py:25:37 - error: Expression of type "ClassA[float, int, int]" cannot be assigned to declared type "ClassA[float, float, int]" +  "ClassA[float, int, int]" is incompatible with "ClassA[float, float, int]" +    Type parameter "T2@ClassA" is contravariant, but "int" is not a supertype of "float" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:28:33 - error: Expression of type "ClassA[int, float, float]" cannot be assigned to declared type "ClassA[int, int, int]" +  "ClassA[int, float, float]" is incompatible with "ClassA[int, int, int]" +    Type parameter "T3@ClassA" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:36:27 - error: "Iterator" is not defined (reportUndefinedVariable) +generics_variance_inference.py:41:35 - error: Expression of type "ShouldBeCovariant1[float]" cannot be assigned to declared type "ShouldBeCovariant1[int]" +  "ShouldBeCovariant1[float]" is incompatible with "ShouldBeCovariant1[int]" +    Type parameter "T@ShouldBeCovariant1" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:49:35 - error: Expression of type "ShouldBeCovariant2[float]" cannot be assigned to declared type "ShouldBeCovariant2[int]" +  "ShouldBeCovariant2[float]" is incompatible with "ShouldBeCovariant2[int]" +    Type parameter "T@ShouldBeCovariant2" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:58:35 - error: Expression of type "ShouldBeCovariant3[float]" cannot be assigned to declared type "ShouldBeCovariant3[int]" +  "ShouldBeCovariant3[float]" is incompatible with "ShouldBeCovariant3[int]" +    Type parameter "T@ShouldBeCovariant3" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:67:34 - error: Expression of type "ShouldBeCovariant4[float]" cannot be assigned to declared type "ShouldBeCovariant4[int]" +  "ShouldBeCovariant4[float]" is incompatible with "ShouldBeCovariant4[int]" +    Type parameter "T@ShouldBeCovariant4" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:80:34 - error: Expression of type "ShouldBeCovariant5[float]" cannot be assigned to declared type "ShouldBeCovariant5[int]" +  "ShouldBeCovariant5[float]" is incompatible with "ShouldBeCovariant5[int]" +    Type parameter "T@ShouldBeCovariant5" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:96:38 - error: Expression of type "ShouldBeInvariant1[int]" cannot be assigned to declared type "ShouldBeInvariant1[float]" +  "ShouldBeInvariant1[int]" is incompatible with "ShouldBeInvariant1[float]" +    Type parameter "T@ShouldBeInvariant1" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_variance_inference.py:97:36 - error: Expression of type "ShouldBeInvariant1[float]" cannot be assigned to declared type "ShouldBeInvariant1[int]" +  "ShouldBeInvariant1[float]" is incompatible with "ShouldBeInvariant1[int]" +    Type parameter "T@ShouldBeInvariant1" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_variance_inference.py:111:38 - error: Expression of type "ShouldBeInvariant2[int]" cannot be assigned to declared type "ShouldBeInvariant2[float]" +  "ShouldBeInvariant2[int]" is incompatible with "ShouldBeInvariant2[float]" +    Type parameter "T@ShouldBeInvariant2" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_variance_inference.py:112:36 - error: Expression of type "ShouldBeInvariant2[float]" cannot be assigned to declared type "ShouldBeInvariant2[int]" +  "ShouldBeInvariant2[float]" is incompatible with "ShouldBeInvariant2[int]" +    Type parameter "T@ShouldBeInvariant2" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_variance_inference.py:119:43 - error: Expression of type "ShouldBeInvariant3[int, str]" cannot be assigned to declared type "ShouldBeInvariant3[float, str]" +  "ShouldBeInvariant3[int, str]" is incompatible with "ShouldBeInvariant3[float, str]" +    Type parameter "K@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_variance_inference.py:120:41 - error: Expression of type "ShouldBeInvariant3[float, str]" cannot be assigned to declared type "ShouldBeInvariant3[int, str]" +  "ShouldBeInvariant3[float, str]" is incompatible with "ShouldBeInvariant3[int, str]" +    Type parameter "K@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_variance_inference.py:121:43 - error: Expression of type "ShouldBeInvariant3[str, int]" cannot be assigned to declared type "ShouldBeInvariant3[str, float]" +  "ShouldBeInvariant3[str, int]" is incompatible with "ShouldBeInvariant3[str, float]" +    Type parameter "V@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_variance_inference.py:122:41 - error: Expression of type "ShouldBeInvariant3[str, float]" cannot be assigned to declared type "ShouldBeInvariant3[str, int]" +  "ShouldBeInvariant3[str, float]" is incompatible with "ShouldBeInvariant3[str, int]" +    Type parameter "V@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_variance_inference.py:130:38 - error: Expression of type "ShouldBeInvariant4[int]" cannot be assigned to declared type "ShouldBeInvariant4[float]" +  "ShouldBeInvariant4[int]" is incompatible with "ShouldBeInvariant4[float]" +    Type parameter "T@ShouldBeInvariant4" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_variance_inference.py:138:38 - error: Expression of type "ShouldBeInvariant5[int]" cannot be assigned to declared type "ShouldBeInvariant5[float]" +  "ShouldBeInvariant5[int]" is incompatible with "ShouldBeInvariant5[float]" +    Type parameter "T@ShouldBeInvariant5" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_variance_inference.py:149:45 - error: Expression of type "ShouldBeContravariant1[int]" cannot be assigned to declared type "ShouldBeContravariant1[float]" +  "ShouldBeContravariant1[int]" is incompatible with "ShouldBeContravariant1[float]" +    Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:169:31 - error: Expression of type "ShouldBeInvariant1[float]" cannot be assigned to declared type "ShouldBeInvariant1[int]" +  "ShouldBeInvariant1[float]" is incompatible with "ShouldBeInvariant1[int]" +    Type parameter "T@ShouldBeInvariant1" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_variance_inference.py:170:33 - error: Expression of type "ShouldBeInvariant1[int]" cannot be assigned to declared type "ShouldBeInvariant1[float]" +  "ShouldBeInvariant1[int]" is incompatible with "ShouldBeInvariant1[float]" +    Type parameter "T@ShouldBeInvariant1" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_variance_inference.py:181:31 - error: Expression of type "ShouldBeCovariant1[float]" cannot be assigned to declared type "ShouldBeCovariant1[int]" +  "ShouldBeCovariant1[float]" is incompatible with "ShouldBeCovariant1[int]" +    Type parameter "T@ShouldBeCovariant1" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:194:37 - error: Expression of type "ShouldBeContravariant1[int]" cannot be assigned to declared type "ShouldBeContravariant1[float]" +  "ShouldBeContravariant1[int]" is incompatible with "ShouldBeContravariant1[float]" +    Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_variance_inference.py:32:7 - error: Class declaration "ShouldBeCovariant1" is obscured by a declaration of the same name (reportGeneralTypeIssues) +generics_variance_inference.py:83:7 - error: Class declaration "ShouldBeInvariant1" is obscured by a declaration of the same name (reportGeneralTypeIssues) +generics_variance_inference.py:141:7 - error: Class declaration "ShouldBeContravariant1" is obscured by a declaration of the same name (reportGeneralTypeIssues) +""" diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index 60b29ec76..79bcf2850 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.2410261631011963 +test_duration = 1.43935227394104 diff --git a/conformance/results/pytype/aliases_type_statement.toml b/conformance/results/pytype/aliases_type_statement.toml index b3f2d97da..1b16e7f18 100644 --- a/conformance/results/pytype/aliases_type_statement.toml +++ b/conformance/results/pytype/aliases_type_statement.toml @@ -3,4 +3,5 @@ notes = """ Does not support `type` statement. """ output = """ -SyntaxError: Type statement is only supported in Python 3.12 and greater (, line 8)""" +SyntaxError: Type statement is only supported in Python 3.12 and greater (, line 8) +""" diff --git a/conformance/results/pytype/generics_paramspec_basic.toml b/conformance/results/pytype/generics_paramspec_basic.toml new file mode 100644 index 000000000..89b0272ae --- /dev/null +++ b/conformance/results/pytype/generics_paramspec_basic.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Does not support ParamSpec. +""" +output = """ +AssertionError: +""" diff --git a/conformance/results/pytype/generics_paramspec_components.toml b/conformance/results/pytype/generics_paramspec_components.toml new file mode 100644 index 000000000..a9cd70809 --- /dev/null +++ b/conformance/results/pytype/generics_paramspec_components.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Does not support ParamSpec. +""" +output = """ +NotImplementedError: ParamSpecArgs +""" diff --git a/conformance/results/pytype/generics_paramspec_semantics.toml b/conformance/results/pytype/generics_paramspec_semantics.toml new file mode 100644 index 000000000..89b0272ae --- /dev/null +++ b/conformance/results/pytype/generics_paramspec_semantics.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Does not support ParamSpec. +""" +output = """ +AssertionError: +""" diff --git a/conformance/results/pytype/generics_paramspec_specialization.toml b/conformance/results/pytype/generics_paramspec_specialization.toml new file mode 100644 index 000000000..241a70f38 --- /dev/null +++ b/conformance/results/pytype/generics_paramspec_specialization.toml @@ -0,0 +1,68 @@ +conformant = "Unsupported" +notes = """ +Does not support ParamSpec. +""" +output = """ +File "generics_paramspec_specialization.py", line 14, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_paramspec_specialization.py", line 19, in : Invalid type annotation 'ClassA[T, P1]' [invalid-annotation] + ClassA[T] expected 1 parameter, got 2 +File "generics_paramspec_specialization.py", line 19, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_paramspec_specialization.py", line 25, in : Invalid type annotation 'ClassA[int, P2]' [invalid-annotation] + ClassA[T] expected 1 parameter, got 2 +File "generics_paramspec_specialization.py", line 26, in func20: bad return type [bad-return-type] + Expected: str + Actually returned: None +File "generics_paramspec_specialization.py", line 29, in : Invalid type annotation 'ClassA[int, Concatenate]' [invalid-annotation] + ClassA[T] expected 1 parameter, got 2 +File "generics_paramspec_specialization.py", line 30, in func21: bad return type [bad-return-type] + Expected: str + Actually returned: None +File "generics_paramspec_specialization.py", line 33, in : Invalid type annotation 'Ellipsis' [invalid-annotation] + Not allowed at index 2 in ClassB +File "generics_paramspec_specialization.py", line 33, in : Invalid type annotation 'ClassB[int, [int, bool], Any]' [invalid-annotation] + ClassB[T] expected 1 parameter, got 3 +File "generics_paramspec_specialization.py", line 34, in func22: bad return type [bad-return-type] + Expected: str + Actually returned: None +File "generics_paramspec_specialization.py", line 37, in : Invalid type annotation 'Ellipsis' [invalid-annotation] + Not allowed at index 1 in ClassA +File "generics_paramspec_specialization.py", line 38, in func23: bad return type [bad-return-type] + Expected: str + Actually returned: None +File "generics_paramspec_specialization.py", line 41, in : Invalid type annotation 'ClassB[int, [], []]' [invalid-annotation] + ClassB[T] expected 1 parameter, got 3 +File "generics_paramspec_specialization.py", line 42, in func24: bad return type [bad-return-type] + Expected: str + Actually returned: None +File "generics_paramspec_specialization.py", line 45, in : Invalid type annotation 'ClassA[int, int]' [invalid-annotation] + ClassA[T] expected 1 parameter, got 2 +File "generics_paramspec_specialization.py", line 46, in func25: bad return type [bad-return-type] + Expected: str + Actually returned: None +File "generics_paramspec_specialization.py", line 49, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_paramspec_specialization.py", line 53, in : class ClassC is not indexable [not-indexable] + ('ClassC' does not subclass Generic) +File "generics_paramspec_specialization.py", line 54, in func30: Function expects 1 arg(s), got 3 [wrong-arg-count] + Expected: (_) + Actually passed: (_, _, _) +File "generics_paramspec_specialization.py", line 55, in func30: Function expects 1 arg(s), got 3 [wrong-arg-count] + Expected: (_) + Actually passed: (_, _, _) +File "generics_paramspec_specialization.py", line 56, in func30: Function expects 1 arg(s), got 3 [wrong-arg-count] + Expected: (_) + Actually passed: (_, _, _) +File "generics_paramspec_specialization.py", line 59, in : class ClassC is not indexable [not-indexable] + ('ClassC' does not subclass Generic) +File "generics_paramspec_specialization.py", line 60, in func31: Function expects 1 arg(s), got 3 [wrong-arg-count] + Expected: (_) + Actually passed: (_, _, _) +File "generics_paramspec_specialization.py", line 61, in func31: Function expects 1 arg(s), got 3 [wrong-arg-count] + Expected: (_) + Actually passed: (_, _, _) +File "generics_paramspec_specialization.py", line 62, in func31: Function expects 1 arg(s), got 3 [wrong-arg-count] + Expected: (_) + Actually passed: (_, _, _) +""" diff --git a/conformance/results/pytype/generics_syntax_autovariance.toml b/conformance/results/pytype/generics_syntax_autovariance.toml new file mode 100644 index 000000000..74af826e3 --- /dev/null +++ b/conformance/results/pytype/generics_syntax_autovariance.toml @@ -0,0 +1,3 @@ +output = """ + +""" diff --git a/conformance/results/pytype/generics_syntax_compatibility.toml b/conformance/results/pytype/generics_syntax_compatibility.toml new file mode 100644 index 000000000..632ab2dde --- /dev/null +++ b/conformance/results/pytype/generics_syntax_compatibility.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 14) +""" diff --git a/conformance/results/pytype/generics_syntax_declarations.toml b/conformance/results/pytype/generics_syntax_declarations.toml new file mode 100644 index 000000000..a0111998f --- /dev/null +++ b/conformance/results/pytype/generics_syntax_declarations.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 13) +""" diff --git a/conformance/results/pytype/generics_syntax_infer_variance.toml b/conformance/results/pytype/generics_syntax_infer_variance.toml new file mode 100644 index 000000000..bbeac025a --- /dev/null +++ b/conformance/results/pytype/generics_syntax_infer_variance.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 118) +""" diff --git a/conformance/results/pytype/generics_syntax_scoping.toml b/conformance/results/pytype/generics_syntax_scoping.toml new file mode 100644 index 000000000..632ab2dde --- /dev/null +++ b/conformance/results/pytype/generics_syntax_scoping.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 14) +""" diff --git a/conformance/results/pytype/generics_typevartuple_args.toml b/conformance/results/pytype/generics_typevartuple_args.toml new file mode 100644 index 000000000..e4a95c186 --- /dev/null +++ b/conformance/results/pytype/generics_typevartuple_args.toml @@ -0,0 +1,55 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +File "generics_typevartuple_args.py", line 10, in : typing.TypeVarTuple not supported yet [not-supported-yet] +File "generics_typevartuple_args.py", line 13, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_args.py", line 16, in : No attribute '__iter__' on TypeVarTuple [attribute-error] +File "generics_typevartuple_args.py", line 16, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_args.py", line 17, in args_to_tuple: bad return type [bad-return-type] + Expected: Tuple[Any] + Actually returned: None +Called from (traceback): + line 20, in current file +File "generics_typevartuple_args.py", line 20, in : Tuple[Any] [assert-type] + Expected: Tuple[int, str] + Actual: Tuple[Any] +File "generics_typevartuple_args.py", line 27, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_args.py", line 27, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] + Expected: (self) + Actually passed: () +File "generics_typevartuple_args.py", line 27, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_args.py", line 28, in exec_le: bad return type [bad-return-type] + Expected: Tuple[Any] + Actually returned: None +Called from (traceback): + line 31, in current file +File "generics_typevartuple_args.py", line 31, in : Tuple[Any] [assert-type] + Expected: Tuple[()] + Actual: Tuple[Any] +File "generics_typevartuple_args.py", line 32, in : Tuple[Any] [assert-type] + Expected: Tuple[int, str] + Actual: Tuple[Any] +File "generics_typevartuple_args.py", line 42, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] + Expected: (self) + Actually passed: () +File "generics_typevartuple_args.py", line 51, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_args.py", line 51, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] + Expected: (self) + Actually passed: () +File "generics_typevartuple_args.py", line 62, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] + Expected: (self) + Actually passed: () +File "generics_typevartuple_args.py", line 70, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_args.py", line 75, in : Function func4 was called with the wrong arguments [wrong-arg-types] + Expected: (_, _1: Tuple[Any], ...) + Actually passed: (_, _1: Tuple[int, int]) +""" diff --git a/conformance/results/pytype/generics_typevartuple_basic.toml b/conformance/results/pytype/generics_typevartuple_basic.toml new file mode 100644 index 000000000..df0caec93 --- /dev/null +++ b/conformance/results/pytype/generics_typevartuple_basic.toml @@ -0,0 +1,133 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +File "generics_typevartuple_basic.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] +File "generics_typevartuple_basic.py", line 9, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_basic.py", line 12, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_typevartuple_basic.py", line 16, in : No attribute '__iter__' on TypeVarTuple [attribute-error] +File "generics_typevartuple_basic.py", line 16, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_basic.py", line 17, in func1: bad return type [bad-return-type] + Expected: Tuple[Any] + Actually returned: None +Called from (traceback): + line 87, in current file +File "generics_typevartuple_basic.py", line 20, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_basic.py", line 23, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_typevartuple_basic.py", line 24, in Array: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_basic.py", line 25, in __init__: Invalid type annotation 'tuple[*Shape,]' [invalid-annotation] + Invalid type annotation '' + Not a type + Invalid type annotation '' + Not a type + Invalid type annotation '' + Not a type + Invalid type annotation '' + Not a type +File "generics_typevartuple_basic.py", line 27, in Array: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_basic.py", line 36, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] + Expected: (self, shape: Tuple[Any]) + Actually passed: (self, shape: Tuple[Height, Width]) +File "generics_typevartuple_basic.py", line 36, in : Invalid type annotation 'Array[Height, Width]' [invalid-annotation] + class Array is not indexable + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 36, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 37, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] + Expected: (self, shape: Tuple[Any]) + Actually passed: (self, shape: Tuple[Batch, Height, Width]) +File "generics_typevartuple_basic.py", line 37, in : Invalid type annotation 'Array[Batch, Height, Width]' [invalid-annotation] + class Array is not indexable + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 37, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 38, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] + Expected: (self, shape: Tuple[Any]) + Actually passed: (self, shape: Tuple[Time, Batch, Height, Width]) +File "generics_typevartuple_basic.py", line 38, in : Invalid type annotation 'Array[Time, Batch, Height, Width]' [invalid-annotation] + class Array is not indexable + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 38, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 42, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] + Expected: (self, shape: Tuple[Any]) + Actually passed: (self, shape: Height) +File "generics_typevartuple_basic.py", line 42, in : Invalid type annotation 'Array[Height, Width]' [invalid-annotation] + class Array is not indexable + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 42, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 43, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] + Expected: (self, shape: Tuple[Any]) + Actually passed: (self, shape: Tuple[Batch, Width]) +File "generics_typevartuple_basic.py", line 43, in : Invalid type annotation 'Array[Batch, Height, Width]' [invalid-annotation] + class Array is not indexable + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 43, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 44, in : Function Array.__init__ was called with the wrong arguments [wrong-arg-types] + Expected: (self, shape: Tuple[Any]) + Actually passed: (self, shape: Tuple[Time, Batch, Width, Height]) +File "generics_typevartuple_basic.py", line 44, in : Invalid type annotation 'Array[Time, Batch, Height, Width]' [invalid-annotation] + class Array is not indexable + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 44, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 52, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_typevartuple_basic.py", line 53, in ClassA: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_basic.py", line 54, in __init__: Invalid type annotation 'tuple[*Shape,]' [invalid-annotation] + Invalid type annotation '' + Not a type + Invalid type annotation '' + Not a type + Invalid type annotation '' + Not a type + Invalid type annotation '' + Not a type +File "generics_typevartuple_basic.py", line 56, in ClassA: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_basic.py", line 59, in ClassA: Invalid type annotation '' for args [invalid-annotation] + Not a type +File "generics_typevartuple_basic.py", line 65, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 3 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _, covariant) +File "generics_typevartuple_basic.py", line 66, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 4 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _, _, _) +File "generics_typevartuple_basic.py", line 67, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 3 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _, bound) +File "generics_typevartuple_basic.py", line 75, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_basic.py", line 76, in func2: bad return type [bad-return-type] + Expected: Tuple[Any] + Actually returned: None +File "generics_typevartuple_basic.py", line 87, in : Tuple[Any] [assert-type] + Expected: Tuple[int] + Actual: Tuple[Any] +File "generics_typevartuple_basic.py", line 95, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 96, in multiply: bad return type [bad-return-type] + Expected: Array + Actually returned: None +File "generics_typevartuple_basic.py", line 99, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_basic.py", line 108, in : Function list.extend was called with the wrong arguments [wrong-arg-types] + Expected: (self, i: Iterable) + Actually passed: (self, i: TypeVarTuple) + Attributes of protocol Iterable[_T2] are not implemented on TypeVarTuple: __iter__ +File "generics_typevartuple_basic.py", line 108, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +""" diff --git a/conformance/results/pytype/generics_typevartuple_callable.toml b/conformance/results/pytype/generics_typevartuple_callable.toml new file mode 100644 index 000000000..46e49f156 --- /dev/null +++ b/conformance/results/pytype/generics_typevartuple_callable.toml @@ -0,0 +1,56 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +File "generics_typevartuple_callable.py", line 10, in : typing.TypeVarTuple not supported yet [not-supported-yet] +File "generics_typevartuple_callable.py", line 12, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_callable.py", line 17, in Process: Invalid type annotation '' [invalid-annotation] + Must be constant +File "generics_typevartuple_callable.py", line 17, in Process: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_callable.py", line 25, in : Function Process.__init__ was called with the wrong arguments [wrong-arg-types] + Expected: (self, target, args: Tuple[Any]) + Actually passed: (self, target, args: Tuple[int, str]) +File "generics_typevartuple_callable.py", line 26, in : Function Process.__init__ was called with the wrong arguments [wrong-arg-types] + Expected: (self, target, args: Tuple[Any]) + Actually passed: (self, target, args: Tuple[str, int]) +File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation '' [invalid-annotation] + Must be constant +File "generics_typevartuple_callable.py", line 29, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_callable.py", line 30, in func2: bad return type [bad-return-type] + Expected: Tuple[Any] + Actually returned: None +Called from (traceback): + line 42, in current file +File "generics_typevartuple_callable.py", line 34, in callback1: bad return type [bad-return-type] + Expected: Tuple[complex, str, int] + Actually returned: None +File "generics_typevartuple_callable.py", line 38, in callback2: bad return type [bad-return-type] + Expected: Tuple[str] + Actually returned: None +File "generics_typevartuple_callable.py", line 41, in : Function func2 was called with the wrong arguments [wrong-arg-types] + Expected: (f: Callable[..., Tuple[Any]]) + Actually passed: (f: Callable[[int, str, int, complex], Tuple[complex, str, int]]) +File "generics_typevartuple_callable.py", line 41, in : Any [assert-type] + Expected: Tuple[str, int, complex] + Actual: Any +File "generics_typevartuple_callable.py", line 42, in : Tuple[Any] [assert-type] + Expected: Tuple[str] + Actual: Tuple[Any] +File "generics_typevartuple_callable.py", line 45, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_callable.py", line 45, in : Missing parameter 'self' in call to function tuple.__iter__ [missing-parameter] + Expected: (self) + Actually passed: () +File "generics_typevartuple_callable.py", line 45, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_callable.py", line 46, in func3: bad return type [bad-return-type] + Expected: Tuple[Any] + Actually returned: None +""" diff --git a/conformance/results/pytype/generics_typevartuple_concat.toml b/conformance/results/pytype/generics_typevartuple_concat.toml new file mode 100644 index 000000000..ca71cddee --- /dev/null +++ b/conformance/results/pytype/generics_typevartuple_concat.toml @@ -0,0 +1,57 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +File "generics_typevartuple_concat.py", line 9, in : typing.TypeVarTuple not supported yet [not-supported-yet] +File "generics_typevartuple_concat.py", line 17, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_concat.py", line 18, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_concat.py", line 22, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_typevartuple_concat.py", line 26, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_concat.py", line 27, in add_batch_axis: bad return type [bad-return-type] + Expected: Array + Actually returned: None +File "generics_typevartuple_concat.py", line 30, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_concat.py", line 31, in del_batch_axis: bad return type [bad-return-type] + Expected: Array + Actually returned: None +File "generics_typevartuple_concat.py", line 34, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_concat.py", line 35, in add_batch_channels: bad return type [bad-return-type] + Expected: Array + Actually returned: None +File "generics_typevartuple_concat.py", line 38, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_concat.py", line 40, in func1: class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_concat.py", line 42, in func1: class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_concat.py", line 44, in func1: class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_concat.py", line 47, in : Invalid type annotation 'T' [invalid-annotation] + TypeVar 'T' appears only once in the function signature +File "generics_typevartuple_concat.py", line 48, in prefix_tuple: bad return type [bad-return-type] + Expected: Tuple[Any] + Actually returned: None +File "generics_typevartuple_concat.py", line 51, in : Function prefix_tuple was called with the wrong arguments [wrong-arg-types] + Expected: (x, y: Tuple[Any]) + Actually passed: (x, y: Tuple[bool, str]) +File "generics_typevartuple_concat.py", line 52, in : Any [assert-type] + Expected: Tuple[int, bool, str] + Actual: Any +File "generics_typevartuple_concat.py", line 55, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_concat.py", line 55, in : Invalid type annotation '' [invalid-annotation] + Not a type +""" diff --git a/conformance/results/pytype/generics_typevartuple_overloads.toml b/conformance/results/pytype/generics_typevartuple_overloads.toml new file mode 100644 index 000000000..31a9b3712 --- /dev/null +++ b/conformance/results/pytype/generics_typevartuple_overloads.toml @@ -0,0 +1,25 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +File "generics_typevartuple_overloads.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] +File "generics_typevartuple_overloads.py", line 10, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_overloads.py", line 16, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_typevartuple_overloads.py", line 18, in Array: class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_overloads.py", line 22, in Array: class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_overloads.py", line 26, in transpose: bad return type [bad-return-type] + Expected: Array + Actually returned: None +File "generics_typevartuple_overloads.py", line 29, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_overloads.py", line 30, in func1: class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_overloads.py", line 31, in func1: class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +""" diff --git a/conformance/results/pytype/generics_typevartuple_specialization.toml b/conformance/results/pytype/generics_typevartuple_specialization.toml new file mode 100644 index 000000000..4f831a3c6 --- /dev/null +++ b/conformance/results/pytype/generics_typevartuple_specialization.toml @@ -0,0 +1,172 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +File "generics_typevartuple_specialization.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] +File "generics_typevartuple_specialization.py", line 10, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_specialization.py", line 16, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_typevartuple_specialization.py", line 24, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 28, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 33, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 41, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 42, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 45, in : Invalid type annotation 'Tuple[Any][float, bool]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 2 +File "generics_typevartuple_specialization.py", line 45, in : Invalid type annotation 'Tuple[str, Array][Height]' [invalid-annotation] + Tuple[str, Array] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 46, in func3: Tuple[Any] [assert-type] + Expected: Tuple[int, float, bool] + Actual: Tuple[Any] +File "generics_typevartuple_specialization.py", line 47, in func3: class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 51, in func4: Tuple[Any] [assert-type] + Expected: Tuple[int] + Actual: Tuple[Any] +File "generics_typevartuple_specialization.py", line 55, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_specialization.py", line 59, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_typevartuple_specialization.py", line 63, in : class Array2 is not indexable [not-indexable] + ('Array2' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 64, in : class Array2 is not indexable [not-indexable] + ('Array2' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 67, in : class Array2 is not indexable [not-indexable] + ('Array2' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 68, in func5: class Array2 is not indexable [not-indexable] + ('Array2' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 69, in func5: class Array2 is not indexable [not-indexable] + ('Array2' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 76, in : Invalid type annotation 'FloatArray[Height, Width]' [invalid-annotation] + class Array2 is not indexable + ('Array2' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 76, in : class Array2 is not indexable [not-indexable] + ('Array2' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 80, in : class Array2 is not indexable [not-indexable] + ('Array2' does not subclass Generic) +File "generics_typevartuple_specialization.py", line 89, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 92, in : Invalid type annotation 'Tuple[Any][str, int]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 2 +File "generics_typevartuple_specialization.py", line 92, in : Invalid type annotation 'Tuple[Any][float]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 93, in func6: Tuple[Any] [assert-type] + Expected: Tuple[str, int] + Actual: Tuple[Any] +File "generics_typevartuple_specialization.py", line 94, in func6: Tuple[Any] [assert-type] + Expected: Tuple[float] + Actual: Tuple[Any] +File "generics_typevartuple_specialization.py", line 95, in func6: Tuple[Any] [assert-type] + Expected: tuple + Actual: Tuple[Any] +File "generics_typevartuple_specialization.py", line 101, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 102, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 103, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 109, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 110, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 117, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 118, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 119, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 120, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 121, in : Function list.extend was called with the wrong arguments [wrong-arg-types] + Expected: (self, i: Iterable) + Actually passed: (self, i: TypeVarTuple) + Attributes of protocol Iterable[_T2] are not implemented on TypeVarTuple: __iter__ +File "generics_typevartuple_specialization.py", line 121, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 122, in : Function list.extend was called with the wrong arguments [wrong-arg-types] + Expected: (self, i: Iterable) + Actually passed: (self, i: Type[Tuple[int, ...]]) + Attributes of protocol Iterable[_T2] are not implemented on type: __iter__ +File "generics_typevartuple_specialization.py", line 122, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 125, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 127, in : Invalid type annotation 'Tuple[Any][int]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation 'T1' [invalid-annotation] + TypeVar 'T1' appears only once in the function signature +File "generics_typevartuple_specialization.py", line 130, in : Invalid type annotation 'T2' [invalid-annotation] + TypeVar 'T2' appears only once in the function signature +File "generics_typevartuple_specialization.py", line 131, in func7: bad return type [bad-return-type] + Expected: Tuple[Tuple[Any], Any, Any] + Actually returned: None +File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation 'Tuple[Any][str, bool]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 2 +File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation 'Tuple[Any][str, bool, float]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 3 +File "generics_typevartuple_specialization.py", line 134, in : Invalid type annotation 'Tuple[Any][str, bool, float, int]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 4 +File "generics_typevartuple_specialization.py", line 135, in func8: Tuple[Tuple[Any], Any, Any] [assert-type] + Expected: Tuple[Tuple[()], str, bool] + Actual: Tuple[Tuple[Any], Any, Any] +File "generics_typevartuple_specialization.py", line 136, in func8: Tuple[Tuple[Any], Any, Any] [assert-type] + Expected: Tuple[Tuple[str], bool, float] + Actual: Tuple[Tuple[Any], Any, Any] +File "generics_typevartuple_specialization.py", line 137, in func8: Tuple[Tuple[Any], Any, Any] [assert-type] + Expected: Tuple[Tuple[str, bool], float, int] + Actual: Tuple[Tuple[Any], Any, Any] +File "generics_typevartuple_specialization.py", line 140, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation 'T1' [invalid-annotation] + TypeVar 'T1' appears only once in the function signature +File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation 'T2' [invalid-annotation] + TypeVar 'T2' appears only once in the function signature +File "generics_typevartuple_specialization.py", line 143, in : Invalid type annotation 'T3' [invalid-annotation] + TypeVar 'T3' appears only once in the function signature +File "generics_typevartuple_specialization.py", line 144, in func9: bad return type [bad-return-type] + Expected: Tuple[Tuple[Any], Any, Any, Any] + Actually returned: None +File "generics_typevartuple_specialization.py", line 147, in : Invalid type annotation 'Tuple[Any][str, bool, float]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 3 +File "generics_typevartuple_specialization.py", line 147, in : Invalid type annotation 'Tuple[Any][str, bool, float, int]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 4 +File "generics_typevartuple_specialization.py", line 148, in func10: Tuple[Tuple[Any], Any, Any, Any] [assert-type] + Expected: Tuple[Tuple[()], str, bool, float] + Actual: Tuple[Tuple[Any], Any, Any, Any] +File "generics_typevartuple_specialization.py", line 149, in func10: Tuple[Tuple[Any], Any, Any, Any] [assert-type] + Expected: Tuple[Tuple[bool], str, float, int] + Actual: Tuple[Tuple[Any], Any, Any, Any] +File "generics_typevartuple_specialization.py", line 152, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 153, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 156, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +File "generics_typevartuple_specialization.py", line 157, in func11: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 158, in func11: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 159, in func11: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 162, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_specialization.py", line 163, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] + Tuple[Any] expected 0 parameters, got 1 +""" diff --git a/conformance/results/pytype/generics_typevartuple_unpack.toml b/conformance/results/pytype/generics_typevartuple_unpack.toml new file mode 100644 index 000000000..45ddf7a00 --- /dev/null +++ b/conformance/results/pytype/generics_typevartuple_unpack.toml @@ -0,0 +1,50 @@ +conformant = "Unsupported" +notes = """ +Does not support TypeVarTuple. +""" +output = """ +File "generics_typevartuple_unpack.py", line 7, in : typing.TypeVarTuple not supported yet [not-supported-yet] +File "generics_typevartuple_unpack.py", line 12, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_unpack.py", line 13, in func1: Tuple[Any] [assert-type] + Expected: Tuple[int, bool, bool, str] + Actual: Tuple[Any] +File "generics_typevartuple_unpack.py", line 14, in func1: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_unpack.py", line 15, in func1: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_unpack.py", line 21, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_unpack.py", line 22, in func2: Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_unpack.py", line 30, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_unpack.py", line 33, in : Invalid type annotation 'Generic' [invalid-annotation] + Parameters to Generic[...] must all be type variables +File "generics_typevartuple_unpack.py", line 37, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_unpack.py", line 42, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_unpack.py", line 49, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_unpack.py", line 52, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_unpack.py", line 56, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_unpack.py", line 60, in : class Array is not indexable [not-indexable] + ('Array' does not subclass Generic) +File "generics_typevartuple_unpack.py", line 67, in : Function list.extend was called with the wrong arguments [wrong-arg-types] + Expected: (self, i: Iterable) + Actually passed: (self, i: Type[Tuple[int]]) + Attributes of protocol Iterable[_T2] are not implemented on type: __iter__ +File "generics_typevartuple_unpack.py", line 67, in : Invalid type annotation '' [invalid-annotation] + Not a type +File "generics_typevartuple_unpack.py", line 68, in : Function list.extend was called with the wrong arguments [wrong-arg-types] + Expected: (self, i: Iterable) + Actually passed: (self, i: Type[Tuple[int]]) + Attributes of protocol Iterable[_T2] are not implemented on type: __iter__ +File "generics_typevartuple_unpack.py", line 68, in : Invalid type annotation '' [invalid-annotation] + Not a type +""" diff --git a/conformance/results/pytype/generics_variance.toml b/conformance/results/pytype/generics_variance.toml new file mode 100644 index 000000000..6b40b44b2 --- /dev/null +++ b/conformance/results/pytype/generics_variance.toml @@ -0,0 +1,14 @@ +conformant = "Unsupported" +notes = """ +Does not support covariant or contravariant TypeVars. +""" +output = """ +File "generics_variance.py", line 14, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] +File "generics_variance.py", line 14, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] +File "generics_variance.py", line 17, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] +File "generics_variance.py", line 25, in __iter__: bad return type [bad-return-type] + Expected: Iterator + Actually returned: None + Attributes of protocol Iterator[T_co] are not implemented on None: __next__ +File "generics_variance.py", line 50, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] +""" diff --git a/conformance/results/pytype/generics_variance_inference.toml b/conformance/results/pytype/generics_variance_inference.toml new file mode 100644 index 000000000..8de7a556d --- /dev/null +++ b/conformance/results/pytype/generics_variance_inference.toml @@ -0,0 +1,7 @@ +conformant = "Unsupported" +notes = """ +Type parameter syntax not yet support. +""" +output = """ +SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 15) +""" diff --git a/conformance/results/pytype/protocols_generic.toml b/conformance/results/pytype/protocols_generic.toml index cfc64f916..5ce4b02a5 100644 --- a/conformance/results/pytype/protocols_generic.toml +++ b/conformance/results/pytype/protocols_generic.toml @@ -11,13 +11,13 @@ File "protocols_generic.py", line 40, in : Type annotation for p2 does n Annotation: Proto1[int, str] Assignment: Concrete1 - Method __iter__ of protocol Proto1[int, str] has the wrong signature in Concrete1: + Method method1 of protocol Proto1[int, str] has the wrong signature in Concrete1: >> Proto1[int, str] expects: - def __iter__(self) -> Iterator[T_co]: ... + def method1(self, x: S) -> S: ... >> Concrete1 defines: - def __iter__(self) -> Iterator[int]: ... + def method1(self, x: str) -> str: ... File "protocols_generic.py", line 44, in : Invalid type annotation 'Proto2' [invalid-annotation] Cannot inherit from Generic[...] multiple times File "protocols_generic.py", line 56, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] diff --git a/conformance/results/pytype/qualifiers_final_decorator.toml b/conformance/results/pytype/qualifiers_final_decorator.toml index 852701ff5..161b08dc3 100644 --- a/conformance/results/pytype/qualifiers_final_decorator.toml +++ b/conformance/results/pytype/qualifiers_final_decorator.toml @@ -14,9 +14,9 @@ File "qualifiers_final_decorator.py", line 52, in method4: bad return type [bad- Expected: str Actually returned: int 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 method4, 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 Actually returned: int diff --git a/conformance/results/pytype/typeddicts_required.toml b/conformance/results/pytype/typeddicts_required.toml index 4bdf74100..382e2bd2c 100644 --- a/conformance/results/pytype/typeddicts_required.toml +++ b/conformance/results/pytype/typeddicts_required.toml @@ -5,4 +5,5 @@ Does not reject use of `Required` in function parameter annotation. Does not reject nested use of `Required` in type annotation. """ output = """ -RecursionError: maximum recursion depth exceeded""" +RecursionError: maximum recursion depth exceeded +""" diff --git a/conformance/results/pytype/version.toml b/conformance/results/pytype/version.toml index 30f7c2a2f..1df6cb201 100644 --- a/conformance/results/pytype/version.toml +++ b/conformance/results/pytype/version.toml @@ -1,2 +1,2 @@ version = "pytype 2023.12.18" -test_duration = 26.710652112960815 +test_duration = 26.562921047210693 diff --git a/conformance/results/results.html b/conformance/results/results.html index 2f4ca5a1d..a24a30c44 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(0.66sec) +
mypy 1.8.0(1.25sec)
@@ -151,11 +151,28 @@

Python Type System Conformance Test Results

+ + + + + + + + + + + + + + + + + @@ -253,7 +270,7 @@

Python Type System Conformance Test Results

Generics
     generics_paramspec_basicPartialDoes not reject ParamSpec when used "bare" in type alias definition.
     generics_paramspec_componentsPartialDoes not report illegal use of "P.args" on normal parameter.
Does not report error when P.args is specified but P.kwargs is missing.
Does not report error when P is out of scope and P.args and P.kwargs is used.
Does not report error when keyword argument is specified between P.args and P.kwargs.
Does not report error when calling callable and argument is missing for concatenated parameters.
     generics_paramspec_semanticsPass
     generics_paramspec_specializationPass
     generics_self_advancedPartialDoes not infer the type of an unannotated `self` parameter to be type `Self`.
Does not retain `Self` when calling method that returns `Self`.
Does not infer the type of an unannotated `cls` parameter to be type `type[Self]`.
Does not retain `Self` when accessing attribute through `type[Self]`.
     generics_self_attributesPass
     generics_self_basicPartialDoes not properly handle constructor call through `cls` parameter.
     generics_self_protocolsPass
     generics_self_usagePass
     generics_syntax_compatibilityUnsupportedType parameter syntax not yet support.
     generics_syntax_declarationsUnsupportedType parameter syntax not yet support.
     generics_syntax_infer_varianceUnsupportedType parameter syntax not yet support.
     generics_syntax_scopingUnsupportedType parameter syntax not yet support.
     generics_typevartuple_argsPartialDoes not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_basicPartialDoes not enforce that tuples captured by TypeVarTuple are same length (spec bug?).
Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
Does not enforce that tuples captured by TypeVarTuple are invariant in non-tuple class.
     generics_typevartuple_callablePass
     generics_typevartuple_concatPass
     generics_typevartuple_overloadsPass
     generics_typevartuple_specializationPartialIncorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.
Incorrectly specializes generic alias that includes a TypeVar and TypeVarTuple if no type arguments are provided.
Rejects use of unpacked TypeVarTuple in generic type alias definition.
Rejects specialization of generic type alias defined as a tuple containing a TypeVar.
"More than one Unpack" error message has no line number.
Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.
     generics_typevartuple_unpackPartialDoes not reject multiple unpack operators in a tuple.
     generics_variancePartialDoes not reject a function-scoped TypeVar that is marked as covariant or contravariant.
     generics_variance_inferenceUnsupportedType parameter syntax not yet support.
Type qualifiers
     directives_version_platformPassDoes not understand three-element form of sys.version checks.
Does not understand os.name checks.
-
pyright 1.1.344(1.24sec) +
pyright 1.1.344(1.44sec)
@@ -277,11 +294,28 @@

Python Type System Conformance Test Results

+ + + + + + + + + + + + + + + + + @@ -379,7 +413,7 @@

Python Type System Conformance Test Results

Generics
     generics_paramspec_basicPartialDoes not reject the use of Concatenate outside of a Callable annotation.
     generics_paramspec_componentsPass
     generics_paramspec_semanticsPartialConstraint solver doesn't find common type for two signatures captured by a single ParamSpec.
Evaluates incorrect type when evaluating constructor call for generic class parameterized by ParamSpec.
     generics_paramspec_specializationPass
     generics_self_advancedPass
     generics_self_attributesPass
     generics_self_basicPass
     generics_self_protocolsPass
     generics_self_usagePass
     generics_syntax_compatibilityPass
     generics_syntax_declarationsPass
     generics_syntax_infer_variancePass
     generics_syntax_scopingPartialDoes not evaluate correct type for variables that shadow type parameters.
     generics_typevartuple_argsPartialDoes not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_basicPartialDoes not reject value constraints when constructing TypeVarTuple.
Does not enforce that tuples captured by TypeVarTuple are same length (spec bug?).
Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_callablePass
     generics_typevartuple_concatPartialDoes not support tuple slicing when tuple type includes TypeVarTuple.
     generics_typevartuple_overloadsPass
     generics_typevartuple_specializationPartialIncorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.
Does not reject specialization of TypeVar in generic type alias when unpacked tuple is specified as type argument.
Does not reject specialization of generic type alias when number of type arguments is too few.
Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.
     generics_typevartuple_unpackPartialDoes not treat `tuple[Any, ...]` as having an arbitrary length.
     generics_variancePartialDoes not reject a function-scoped TypeVar that is marked as covariant or contravariant.
     generics_variance_inferencePass
Type qualifiers
     directives_version_platformPass
-
pyre 0.9.19(2.12sec) +
pyre 0.9.19(2.29sec)
@@ -403,11 +437,28 @@

Python Type System Conformance Test Results

+ + + + + + + + + + + + + + + + + @@ -505,7 +556,7 @@

Python Type System Conformance Test Results

Generics
     generics_paramspec_basicPartialDoes not enforce name consistency for ParamSpec assigned to identifier.
Incorrectly reports error for legitimate use of ParamSpec in generic type alias.
Does not reject ParamSpec when used in various invalid locations.
     generics_paramspec_componentsPartialDoes not report illegal use of "P.args" on normal parameter.
Does not report error when P.args is specified but P.kwargs is missing.
Does not report error when P is out of scope and P.args and P.kwargs is used.
Does not report error when calling callback defined with ParamSpec with incorrect arguments.
Does not report error when keyword argument is specified between P.args and P.kwargs.
Does not report error when calling callable and argument is missing for concatenated parameters.
     generics_paramspec_semanticsPartialConstraint solver doesn't find common type for two signatures captured by a single ParamSpec.
Reports error for legitimate Callable type annotation that uses Concatenate.
Does not evaluate the correct type for call of Callable defined with Concatenate.
     generics_paramspec_specializationPartialReports error for legitimate use of ParamSpec and Concatenate in function signature.
Reports error for legitimate specialization of generic class parameterized with ParamSpec.
     generics_self_advancedUnsupportedDoes not understand `Self` type.
     generics_self_attributesUnsupportedDoes not understand `Self` type.
     generics_self_basicUnsupportedDoes not understand `Self` type.
     generics_self_protocolsPartialDoes not reject protocol compatibility due to method `Self` return type.
     generics_self_usageUnsupportedDoes not understand `Self` type.
     generics_syntax_compatibilityUnsupportedType parameter syntax not yet support.
     generics_syntax_declarationsUnsupportedType parameter syntax not yet support.
     generics_syntax_infer_varianceUnsupportedType parameter syntax not yet support.
     generics_syntax_scopingUnsupportedType parameter syntax not yet support.
     generics_typevartuple_argsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_basicUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_callableUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_concatUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_overloadsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_specializationUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_unpackUnsupportedDoes not support TypeVarTuple.
     generics_variancePartialDoes not reject a TypeVar that is defined as both covariant and contravariant.
Does not reject a function-scoped TypeVar that is marked as covariant or contravariant.
     generics_variance_inferenceUnsupportedType parameter syntax not yet support.
Type qualifiers
     directives_version_platformPartialDoes not support sys.platform checks.
Does not support os.name checks.
-
pytype 2023.12.18(26.71sec) +
pytype 2023.12.18(26.56sec)
@@ -529,11 +580,28 @@

Python Type System Conformance Test Results

+ + + + + + + + + + + + + + + + + diff --git a/conformance/src/main.py b/conformance/src/main.py index be474bac0..ca3b57af9 100644 --- a/conformance/src/main.py +++ b/conformance/src/main.py @@ -55,6 +55,9 @@ def update_output_for_test( existing_results = tomli.load(f) except FileNotFoundError: existing_results = {} + except tomli.TOMLDecodeError: + print(f"Error decoding {results_file}") + existing_results = {} old_output = existing_results.get("output", None) old_output = f"\n{old_output}" @@ -79,7 +82,9 @@ def update_output_for_test( tomlkit.dump(existing_results, f) -def update_type_checker_info(type_checker: TypeChecker, root_dir: Path, test_duration: float): +def update_type_checker_info( + type_checker: TypeChecker, root_dir: Path, test_duration: float +): # Record the version of the type checker used for the latest run. version_file = root_dir / "results" / type_checker.name / "version.toml" @@ -89,6 +94,9 @@ def update_type_checker_info(type_checker: TypeChecker, root_dir: Path, test_dur existing_info = tomli.load(f) except FileNotFoundError: existing_info = {} + except tomli.TOMLDecodeError: + print(f"Error decoding {version_file}") + existing_info = {} existing_info["version"] = type_checker.get_version() existing_info["test_duration"] = test_duration @@ -117,7 +125,7 @@ def main(): # Run each test case with each type checker. for type_checker in TYPE_CHECKERS: if not type_checker.install(): - print(f'Skipping tests for {type_checker.name}') + print(f"Skipping tests for {type_checker.name}") else: run_tests(root_dir, type_checker, test_cases) diff --git a/conformance/src/reporting.py b/conformance/src/reporting.py index 95c9c14c3..d4a90ee3a 100644 --- a/conformance/src/reporting.py +++ b/conformance/src/reporting.py @@ -11,7 +11,7 @@ def generate_summary(root_dir: Path): - print('Generating summary report') + print("Generating summary report") template_file = root_dir / "src" / "results_template.html" with open(template_file, "r") as f: template = f.read() @@ -39,6 +39,9 @@ def generate_summary_html(root_dir: Path): existing_info = tomli.load(f) except FileNotFoundError: existing_info = {} + except tomli.TOMLDecodeError: + print(f"Error decoding {version_file}") + existing_info = {} version = existing_info["version"] or "Unknown version" test_duration = existing_info.get("test_duration") @@ -46,7 +49,7 @@ def generate_summary_html(root_dir: Path): summary_html += f"
{version}" if test_duration is not None: summary_html += f"({test_duration:.2f}sec)\n" - summary_html += '
\n' + summary_html += "\n" summary_html += '
Generics
     generics_paramspec_basicUnsupportedDoes not support ParamSpec.
     generics_paramspec_componentsUnsupportedDoes not support ParamSpec.
     generics_paramspec_semanticsUnsupportedDoes not support ParamSpec.
     generics_paramspec_specializationUnsupportedDoes not support ParamSpec.
     generics_self_advancedUnsupportedDoes not understand `Self` type.
     generics_self_attributesUnsupportedDoes not understand `Self` type.
     generics_self_basicUnsupportedDoes not understand `Self` type.
     generics_self_protocolsPartialDoes not reject protocol compatibility due to method `Self` return type.
     generics_self_usageUnsupportedDoes not understand `Self` type.
     generics_syntax_compatibilityUnsupportedType parameter syntax not yet support.
     generics_syntax_declarationsUnsupportedType parameter syntax not yet support.
     generics_syntax_infer_varianceUnsupportedType parameter syntax not yet support.
     generics_syntax_scopingUnsupportedType parameter syntax not yet support.
     generics_typevartuple_argsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_basicUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_callableUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_concatUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_overloadsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_specializationUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_unpackUnsupportedDoes not support TypeVarTuple.
     generics_varianceUnsupportedDoes not support covariant or contravariant TypeVars.
     generics_variance_inferenceUnsupportedType parameter syntax not yet support.
Type qualifiers
\n' summary_html += '\n' @@ -56,7 +59,7 @@ def generate_summary_html(root_dir: Path): for case in test_cases if case.name.startswith(f"{test_group_name}_") ] - + tests_in_group.sort(key=lambda x: x.name) # Are there any test cases in this group? diff --git a/conformance/src/type_checker.py b/conformance/src/type_checker.py index 272a64b6e..2f53421a6 100644 --- a/conformance/src/type_checker.py +++ b/conformance/src/type_checker.py @@ -9,7 +9,6 @@ from pytype import config as pytype_config from pytype import io as pytype_io from pytype import load_pytd as pytype_loader -import re from subprocess import PIPE, run import sys from tqdm import tqdm @@ -56,10 +55,14 @@ def name(self) -> str: def install(self) -> bool: try: - run(f"{sys.executable} -m pip install mypy --upgrade", check=True, shell=True) + run( + f"{sys.executable} -m pip install mypy --upgrade", + check=True, + shell=True, + ) return True except: - print('Unable to install mypy') + print("Unable to install mypy") return False def get_version(self) -> str: @@ -94,14 +97,18 @@ def name(self) -> str: def install(self) -> bool: try: # Install the Python wrapper if it's not installed. - run(f"{sys.executable} -m pip install pyright --upgrade", check=True, shell=True) + run( + f"{sys.executable} -m pip install pyright --upgrade", + check=True, + shell=True, + ) # Force the Python wrapper to install node if needed # and download the latest version of pyright. self.get_version() return True except: - print('Unable to install pyright') + print("Unable to install pyright") return False def get_version(self) -> str: @@ -140,18 +147,20 @@ def name(self) -> str: def install(self) -> bool: try: - run(f"{sys.executable} -m pip install pyre-check --upgrade", check=True, shell=True) + run( + f"{sys.executable} -m pip install pyre-check --upgrade", + check=True, + shell=True, + ) # Generate a default config file. - pyre_config = ( - '{"site_package_search_strategy": "pep561", "source_directories": ["."]}\n' - ) + pyre_config = '{"site_package_search_strategy": "pep561", "source_directories": ["."]}\n' with open(".pyre_configuration", "w") as f: f.write(pyre_config) return True except: - print('Unable to install pyre') + print("Unable to install pyre") return False def get_version(self) -> str: @@ -180,10 +189,14 @@ def name(self) -> str: def install(self) -> bool: try: - run(f"{sys.executable} -m pip install pytype --upgrade", check=True, shell=True) + run( + f"{sys.executable} -m pip install pytype --upgrade", + check=True, + shell=True, + ) return True except: - print('Unable to install pytype on this platform') + print("Unable to install pytype on this platform") return False def get_version(self) -> str: @@ -197,27 +210,24 @@ def run_tests(self, test_files: Sequence[str]) -> dict[str, str]: # Specify 3.11 for now to work around the fact that pytype # currently doesn't support 3.12 and emits an error when # running on 3.12. - options = pytype_config.Options.create( - python_version=(3, 11), - quick=True) + options = pytype_config.Options.create(python_version=(3, 11), quick=True) loader = pytype_loader.create_loader(options) # Add results to a dictionary keyed by the file name. results_dict: dict[str, str] = {} - for fi in tqdm(os.listdir('.')): - if not fi.endswith('.py'): + for fi in tqdm(os.listdir(".")): + if not fi.endswith(".py"): continue options.tweak(input=fi) - with open(fi, 'r') as test_file: + with open(fi, "r") as test_file: src = test_file.read() try: - errorlog = pytype_io.check_py( - src, options=options, loader=loader) + errorlog = pytype_io.check_py(src, options=options, loader=loader) except Exception as e: - results_dict[fi] = f'{e.__class__.__name__}: {e}' + results_dict[fi] = f"{e.__class__.__name__}: {e}\n" else: - results_dict[fi] = str(errorlog) + results_dict[fi] = f"{str(errorlog)}" return results_dict diff --git a/conformance/tests/generics_paramspec_basic.py b/conformance/tests/generics_paramspec_basic.py new file mode 100644 index 000000000..19718a82b --- /dev/null +++ b/conformance/tests/generics_paramspec_basic.py @@ -0,0 +1,40 @@ +""" +Tests basic usage of ParamSpec. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#paramspec-variables + +from typing import Any, Callable, Concatenate, ParamSpec, TypeAlias + +P = ParamSpec("P") # OK +WrongName = ParamSpec("NotIt") # Type error: name inconsistency + + +# > Valid use locations + +TA1: TypeAlias = P # Type error + +TA2: TypeAlias = Callable[P, None] # OK +TA3: TypeAlias = Callable[Concatenate[int, P], None] # OK +TA4: TypeAlias = Callable[..., None] # OK +TA5: TypeAlias = Callable[..., None] # OK + + +def func1(x: P) -> P: # Type error + ... + + +def func2(x: Concatenate[int, P]) -> int: # Type error + ... + + +def func3(x: list[P]) -> None: # Type error + ... + + +def func3(x: Callable[[int, str], P]) -> None: # Type error + ... + + +def func4(*args: P, **kwargs: P) -> None: # Type error + ... diff --git a/conformance/tests/generics_paramspec_components.py b/conformance/tests/generics_paramspec_components.py new file mode 100644 index 000000000..70a7eeb8e --- /dev/null +++ b/conformance/tests/generics_paramspec_components.py @@ -0,0 +1,98 @@ +""" +Tests the usage of a ParamSpec and its components (P.args, P.kwargs). +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#the-components-of-a-paramspec + + +from typing import Any, Callable, Concatenate, ParamSpec, assert_type + +P = ParamSpec("P") + + +def puts_p_into_scope1(f: Callable[P, int]) -> None: + def inner(*args: P.args, **kwargs: P.kwargs) -> None: # OK + pass + + def mixed_up(*args: P.kwargs, **kwargs: P.args) -> None: # Type error + pass + + def misplaced1(x: P.args) -> None: # Type error + pass + + def bad_kwargs1(*args: P.args, **kwargs: P.args) -> None: # Type error + pass + + def bad_kwargs2(*args: P.args, **kwargs: Any) -> None: # Type error + pass + + +def out_of_scope(*args: P.args, **kwargs: P.kwargs) -> None: # Type error + pass + + +def puts_p_into_scope2(f: Callable[P, int]) -> None: + stored_args: P.args # Type error + stored_kwargs: P.kwargs # Type error + + def just_args(*args: P.args) -> None: # Type error + pass + + def just_kwargs(**kwargs: P.kwargs) -> None: # Type error + pass + + +def decorator(f: Callable[P, int]) -> Callable[P, None]: + def foo(*args: P.args, **kwargs: P.kwargs) -> None: + assert_type(f(*args, **kwargs), int) # OK + + f(*kwargs, **args) # Type error + + f(1, *args, **kwargs) # Type error + + return foo # OK + + +def add(f: Callable[P, int]) -> Callable[Concatenate[str, P], None]: + def foo(s: str, *args: P.args, **kwargs: P.kwargs) -> None: # OK + pass + + def bar(*args: P.args, s: str, **kwargs: P.kwargs) -> None: # Type error + pass + + return foo # OK + + +def remove(f: Callable[Concatenate[int, P], int]) -> Callable[P, None]: + def foo(*args: P.args, **kwargs: P.kwargs) -> None: + f(1, *args, **kwargs) # OK + + f(*args, 1, **kwargs) # Type error + + f(*args, **kwargs) # Type error + + return foo # OK + + +def outer(f: Callable[P, None]) -> Callable[P, None]: + def foo(x: int, *args: P.args, **kwargs: P.kwargs) -> None: + f(*args, **kwargs) + + def bar(*args: P.args, **kwargs: P.kwargs) -> None: + foo(1, *args, **kwargs) # OK + foo(x=1, *args, **kwargs) # Type error + + return bar + + +def twice(f: Callable[P, int], *args: P.args, **kwargs: P.kwargs) -> int: + return f(*args, **kwargs) + f(*args, **kwargs) + + +def a_int_b_str(a: int, b: str) -> int: + return 0 + + +twice(a_int_b_str, 1, "A") # OK +twice(a_int_b_str, b="A", a=1) # OK +twice(a_int_b_str, "A", 1) # Type error diff --git a/conformance/tests/generics_paramspec_semantics.py b/conformance/tests/generics_paramspec_semantics.py new file mode 100644 index 000000000..a76a70f5d --- /dev/null +++ b/conformance/tests/generics_paramspec_semantics.py @@ -0,0 +1,143 @@ +""" +Tests semantics of ParamSpec. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#semantics + + +from typing import Callable, Concatenate, Generic, ParamSpec, TypeVar, assert_type + +P = ParamSpec("P") + + +def changes_return_type_to_str(x: Callable[P, int]) -> Callable[P, str]: + ... + + +def returns_int(a: str, b: bool, /) -> int: + ... + + +f1 = changes_return_type_to_str(returns_int) +assert_type(f1, Callable[[str, bool], str]) + +v1 = f1("A", True) # OK +assert_type(v1, str) +f1(a="A", b=True) # Type error: position-only +f1("A", "A") # Type error: wrong type + + +def func1(x: Callable[P, int], y: Callable[P, int]) -> Callable[P, bool]: + ... + + +def x_y(x: int, y: str) -> int: + ... + + +def y_x(y: int, x: str) -> int: + ... + + +f2 = func1(x_y, x_y) +assert_type(f2(1, ""), bool) +assert_type(f2(y="", x=1), bool) + +f3 = func1(x_y, y_x) # Could return (a: int, b: str, /) -> bool +# (a callable with two positional-only parameters) +# This works because both callables have types that are +# behavioral subtypes of Callable[[int, str], int] +# Also OK for type checkers to reject this. + + +def keyword_only_x(*, x: int) -> int: + ... + + +def keyword_only_y(*, y: int) -> int: + ... + + +func1(keyword_only_x, keyword_only_y) # Type error + + +U = TypeVar("U") + + +class Y(Generic[U, P]): + f: Callable[P, str] + prop: U + + def __init__(self, f: Callable[P, str], prop: U) -> None: + self.f = f + self.prop = prop + + +def callback_a(q: int, /) -> str: + ... + + +y1 = Y(callback_a, 1) +assert_type(y1, Y[int, [int]]) +y2 = y1.f +assert_type(y2, Callable[[int], str]) + + +def bar(x: int, *args: bool) -> int: + ... + + +def add(x: Callable[P, int]) -> Callable[Concatenate[str, P], bool]: + ... + + +a1 = add(bar) # Should return (a: str, /, x: int, *args: bool) -> bool +assert_type(a1("", 1, False, True), bool) +assert_type(a1("", x=1), bool) +a1(1, x=1) # Type error + + +def remove(x: Callable[Concatenate[int, P], int]) -> Callable[P, bool]: + ... + + +r1 = remove(bar) # Should return (*args: bool) -> bool +assert_type(r1(False, True, True), bool) +assert_type(r1(), bool) +r1(1) # Type error + + +def transform( + x: Callable[Concatenate[int, P], int] +) -> Callable[Concatenate[str, P], bool]: + ... + + +t1 = transform(bar) # Should return (a: str, /, *args: bool) -> bool +assert_type(t1("", True, False, True), bool) +assert_type(t1(""), bool) +t1(1) # Type error + + +def expects_int_first(x: Callable[Concatenate[int, P], int]) -> None: + ... + + +@expects_int_first # Type error +def one(x: str) -> int: + ... + + +@expects_int_first # Type error +def two(*, x: int) -> int: + ... + + +@expects_int_first # Type error +def three(**kwargs: int) -> int: + ... + + +@expects_int_first # OK +def four(*args: int) -> int: + ... diff --git a/conformance/tests/generics_paramspec_specialization.py b/conformance/tests/generics_paramspec_specialization.py new file mode 100644 index 000000000..12ebf180e --- /dev/null +++ b/conformance/tests/generics_paramspec_specialization.py @@ -0,0 +1,62 @@ +""" +Tests the handling of a ParamSpec specialization. +""" + + +from typing import Callable, Concatenate, Generic, ParamSpec, TypeVar + + +T = TypeVar("T") +P1 = ParamSpec("P1") +P2 = ParamSpec("P2") + + +class ClassA(Generic[T, P1]): + f: Callable[P1, int] + x: T + + +class ClassB(ClassA[T, P1], Generic[T, P1, P2]): + f1: Callable[P1, int] + f2: Callable[P2, int] + x: T + + +def func20(x: ClassA[int, P2]) -> str: # OK + ... + + +def func21(x: ClassA[int, Concatenate[int, P2]]) -> str: # OK + ... + + +def func22(x: ClassB[int, [int, bool], ...]) -> str: # OK + ... + + +def func23(x: ClassA[int, ...]) -> str: # OK + ... + + +def func24(x: ClassB[int, [], []]) -> str: # OK + ... + + +def func25(x: ClassA[int, int]) -> str: # Type error + ... + + +class ClassC(Generic[P1]): + f: Callable[P1, int] + + +def func30(x: ClassC[[int, str, bool]]) -> None: # OK + x.f(0, "", True) # OK + x.f("", "", True) # Type error + x.f(0, "", "") # Type error + + +def func31(x: ClassC[int, str, bool]) -> None: # OK + x.f(0, "", True) # OK + x.f("", "", True) # Type error + x.f(0, "", "") # Type error diff --git a/conformance/tests/generics_syntax_compatibility.py b/conformance/tests/generics_syntax_compatibility.py new file mode 100644 index 000000000..d40353437 --- /dev/null +++ b/conformance/tests/generics_syntax_compatibility.py @@ -0,0 +1,27 @@ +""" +Tests the compatibility rules between type parameter syntax (introduced in PEP 695) +and traditional TypeVars. +""" + +# Specification: https://peps.python.org/pep-0695/#compatibility-with-traditional-typevars + +from typing import TypeVar + + +K = TypeVar("K") + + +class ClassA[V](dict[K, V]): # Type error: traditional TypeVar not allowed here + ... + + +class ClassB[K, V](dict[K, V]): # OK + ... + + +class ClassC[V]: + def method1(self, a: V, b: K) -> V | K: # OK + ... + + def method2[M](self, a: M, b: K) -> M | K: # Type error + ... diff --git a/conformance/tests/generics_syntax_declarations.py b/conformance/tests/generics_syntax_declarations.py new file mode 100644 index 000000000..a1500fbe6 --- /dev/null +++ b/conformance/tests/generics_syntax_declarations.py @@ -0,0 +1,82 @@ +""" +Validates the type parameter syntax introduced in PEP 695. +""" + +# Specification: https://peps.python.org/pep-0695/#type-parameter-declarations + + +# This generic class is parameterized by a TypeVar T, a +# TypeVarTuple Ts, and a ParamSpec P. +from typing import Generic, ParamSpec, Protocol, TypeVar, TypeVarTuple, assert_type + + +class ClassA[T, *Ts, **P]: + assert_type(T, TypeVar) + assert_type(Ts, TypeVarTuple) + assert_type(P, ParamSpec) + + +class ClassB[T](Generic[T]): # Runtime error + ... + + +class ClassC[S, T](Protocol[S, T]): # Type error + ... + + +class ClassD[T: str]: + def method1(self, x: T): + x.capitalize() # OK + x.is_integer() # Type error + + +class ClassE[T: dict[str, int]]: # OK + pass + + +class ClassF[T: "ForwardReference"]: # OK + ... + + +class ClassG[V]: + class ClassD[T: dict[str, V]]: # Type error: generic type not allowed + ... + + +class ClassH[T: [str, int]]: # Type error: illegal expression form + ... + + +class ClassI[AnyStr: (str, bytes)]: # OK + ... + + +class ClassJ[T: ("ForwardReference", bytes)]: # OK + ... + + +class ClassK[T: ()]: # Type error: two or more types required + ... + + +class ClassL[T: (str,)]: # Type error: two or more types required + ... + + +t1 = (bytes, str) + + +class ClassM[T: t1]: # Type error: literal tuple expression required + ... + + +class ClassN[T: (3, bytes)]: # Type error: invalid expression form + ... + + +class ClassO[T: (list[S], str)]: # Type error: generic type + ... + + +class ForwardReference: + ... diff --git a/conformance/tests/generics_syntax_infer_variance.py b/conformance/tests/generics_syntax_infer_variance.py new file mode 100644 index 000000000..1acc5234f --- /dev/null +++ b/conformance/tests/generics_syntax_infer_variance.py @@ -0,0 +1,142 @@ +""" +Tests the handling of "infer_variance" parameter for TypeVar. +""" + +# Specification: https://peps.python.org/pep-0695/#auto-variance-for-typevar + +from typing import Generic, Iterator, Sequence, TypeVar +from dataclasses import dataclass + + +T = TypeVar("T", infer_variance=True) +K = TypeVar("K", infer_variance=True) +V = TypeVar("V", infer_variance=True) + +S1 = TypeVar( + "S1", covariant=True, infer_variance=True +) # Type error: cannot use covariant with infer_variance + +S2 = TypeVar( + "S2", contravariant=True, infer_variance=True +) # Type error: cannot use contravariant with infer_variance + + +class ShouldBeCovariant1(Generic[T]): + def __getitem__(self, index: int) -> T: + ... + + def __iter__(self) -> Iterator[T]: + ... + + +vco1_1: ShouldBeCovariant1[float] = ShouldBeCovariant1[int]() # OK +vco1_2: ShouldBeCovariant1[int] = ShouldBeCovariant1[float]() # Type error + + +class ShouldBeCovariant2(Sequence[T]): + pass + + +vco2_1: ShouldBeCovariant2[float] = ShouldBeCovariant2[int]() # OK +vco2_2: ShouldBeCovariant2[int] = ShouldBeCovariant2[float]() # Type error + + +class ShouldBeCovariant3(Generic[T]): + def method1(self) -> "ShouldBeCovariant2[T]": + ... + + +vco3_1: ShouldBeCovariant3[float] = ShouldBeCovariant3[int]() # OK +vco3_2: ShouldBeCovariant3[int] = ShouldBeCovariant3[float]() # Type error + + +@dataclass(frozen=True) +class ShouldBeCovariant4(Generic[T]): + x: T + + +vo4_1: ShouldBeCovariant4[float] = ShouldBeCovariant4[int](1) # OK +vo4_4: ShouldBeCovariant4[int] = ShouldBeCovariant4[float](1.0) # Type error + + +class ShouldBeCovariant5(Generic[T]): + def __init__(self, x: T) -> None: + self._x = x + + @property + def x(self) -> T: + return self._x + + +vo5_1: ShouldBeCovariant5[float] = ShouldBeCovariant5[int](1) # OK +vo5_2: ShouldBeCovariant5[int] = ShouldBeCovariant5[float](1.0) # Type error + + +class ShouldBeInvariant1(Generic[T]): + def __init__(self, value: T) -> None: + self._value = value + + @property + def value(self): + return self._value + + @value.setter + def value(self, value: T): + self._value = value + + +vinv1_1: ShouldBeInvariant1[float] = ShouldBeInvariant1[int](1) # Type error +vinv1_2: ShouldBeInvariant1[int] = ShouldBeInvariant1[float](1.1) # Type error + + +class ShouldBeInvariant2(Generic[T]): + def __init__(self, value: T) -> None: + self._value = value + + def get_value(self) -> T: + return self._value + + def set_value(self, value: T): + self._value = value + + +vinv2_1: ShouldBeInvariant2[float] = ShouldBeInvariant2[int](1) # Type error +vinv2_2: ShouldBeInvariant2[int] = ShouldBeInvariant2[float](1.1) # Type error + + +class ShouldBeInvariant3(dict[K, V]): + pass + + +vinv3_1: ShouldBeInvariant3[float, str] = ShouldBeInvariant3[int, str]() # Type error +vinv3_2: ShouldBeInvariant3[int, str] = ShouldBeInvariant3[float, str]() # Type error +vinv3_3: ShouldBeInvariant3[str, float] = ShouldBeInvariant3[str, int]() # Type error +vinv3_4: ShouldBeInvariant3[str, int] = ShouldBeInvariant3[str, float]() # Type error + + +@dataclass +class ShouldBeInvariant4[T]: + x: T + + +vinv4_1: ShouldBeInvariant4[float] = ShouldBeInvariant4[int](1) # Type error + + +class ShouldBeInvariant5[T]: + def __init__(self, x: T) -> None: + self.x = x + + +vinv5_1: ShouldBeInvariant5[float] = ShouldBeInvariant5[int](1) # Type error + + +class ShouldBeContravariant1(Generic[T]): + def __init__(self, value: T) -> None: + pass + + def set_value(self, value: T): + pass + + +vcontra1_1: ShouldBeContravariant1[float] = ShouldBeContravariant1[int](1) # Type error +vcontra1_2: ShouldBeContravariant1[int] = ShouldBeContravariant1[float](1.2) # OK diff --git a/conformance/tests/generics_syntax_scoping.py b/conformance/tests/generics_syntax_scoping.py new file mode 100644 index 000000000..49c3602f3 --- /dev/null +++ b/conformance/tests/generics_syntax_scoping.py @@ -0,0 +1,124 @@ +""" +Tests the scoping rules for type parameter syntax introduced in PEP 695. +""" + +# Specification: https://peps.python.org/pep-0695/#type-parameter-scopes + +from typing import Any, Callable, Mapping, Sequence, TypeVar, assert_type + +# > A compiler error or runtime exception is generated if the definition +# > of an earlier type parameter references a later type parameter even +# > if the name is defined in an outer scope. + + +class ClassA[S, T: Sequence[S]]: # Type error + ... + + +class ClassB[S: Sequence[T], T]: # Type error + ... + + +class Foo[T]: + ... + + +class BaseClassC[T]: + def __init_subclass__(cls, param: type[Foo[T]]) -> None: + ... + + +class ClassC[T](BaseClassC[T], param=Foo[T]): # OK + ... + + +print(T) # Runtime error: 'T' is not defined + + +def decorator1[ + T, **P, R +](x: type[Foo[T]]) -> Callable[[Callable[P, R]], Callable[P, R]]: + ... + + +@decorator1(Foo[T]) # Runtime error: 'T' is not defined +class ClassD[T]: + ... + + +type Alias1[K, V] = Mapping[K, V] | Sequence[K] + + +S: int = 0 + + +def outer1[S](): + S: str = "" + T: int = 1 + + def outer2[T](): + def inner1(): + nonlocal S # OK + assert_type(S, str) + # nonlocal T # Syntax error + + def inner2(): + global S # OK + assert_type(S, int) + + +class Outer1: + class Private: + pass + + class Inner[T](Private, Sequence[T]): # OK + pass + + def method1[T](self, a: Inner[T]) -> Inner[T]: # OK + return a + + +def decorator2[**P, R](x: int) -> Callable[[Callable[P, R]], Callable[P, R]]: + ... + + +T = int(0) + + +@decorator2(T) # OK +class ClassE[T](Sequence[T]): + T = int(1) + + def method1[T](self): # Type error + ... + + def method2[T](self, x=T): # Type error + ... + + def method3[T](self, x: T): # Type error + ... + + +T = int(0) + + +class Outer2[T]: + T = int(1) + + assert_type(T, int) + + class Inner1: + T = str("") + + assert_type(T, str) + + def inner_method(self): + assert_type(T, TypeVar) + + def outer_method(self): + T = 3j + + assert_type(T, complex) + + def inner_func(): + assert_type(T, complex) diff --git a/conformance/tests/generics_typevartuple_args.py b/conformance/tests/generics_typevartuple_args.py new file mode 100644 index 000000000..db85e29e3 --- /dev/null +++ b/conformance/tests/generics_typevartuple_args.py @@ -0,0 +1,81 @@ +""" +Tests for the use of TypeVarTuple with "*args" parameter. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#args-as-a-type-variable-tuple + +# > If *args is annotated as a type variable tuple, the types of the individual +# > arguments become the types in the type variable tuple. + +from typing import TypeVarTuple, assert_type + + +Ts = TypeVarTuple("Ts") + + +def args_to_tuple(*args: *Ts) -> tuple[*Ts]: + ... + + +assert_type(args_to_tuple(1, "a"), tuple[int, str]) + + +class Env: + ... + + +def exec_le(path: str, *args: * tuple[*Ts, Env], env: Env | None = None) -> tuple[*Ts]: + ... + + +assert_type(exec_le("", Env()), tuple[()]) # OK +assert_type(exec_le("", 0, "", Env()), tuple[int, str]) # OK +exec_le("", 0, "") # Type error +exec_le("", 0, "", env=Env()) # Type error + + +# > Using an unpacked unbounded tuple is equivalent to the +# > PEP 484#arbitrary-argument-lists-and-default-argument-values behavior of +# > *args: int, which accepts zero or more values of type int. + + +def func1(*args: * tuple[int, ...]) -> None: + ... + + +func1() # OK +func1(1, 2, 3, 4, 5) # OK +func1(1, "2", 3) # Type error + + +def func2(*args: * tuple[int, *tuple[str, ...], str]) -> None: + ... + + +func2(1, "") # OK +func2(1, "", "", "", "") # OK +func2(1, 1, "") # Type error +func2(1) # Type error +func2("") # Type error + + +def func3(*args: * tuple[int, str]) -> None: + ... + + +func3(1, "hello") # OK +func3(1) # Type error + + +def func4(*args: tuple[*Ts]): + ... + + +func4((0,), (1,)) # OK +func4((0,), (1, 2)) # Type error +func4((0,), ("1",)) # Type error + + +# This is a syntax error, so leave it commented out. +# def func5(**kwargs: *Ts): # Type error +# ... diff --git a/conformance/tests/generics_typevartuple_basic.py b/conformance/tests/generics_typevartuple_basic.py new file mode 100644 index 000000000..17ce7cdef --- /dev/null +++ b/conformance/tests/generics_typevartuple_basic.py @@ -0,0 +1,109 @@ +""" +Tests basic usage of TypeVarTuple. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#typevartuple + +from typing import Generic, NewType, TypeVarTuple, assert_type + +Ts = TypeVarTuple("Ts") + + +class Array1(Generic[*Ts]): + ... + + +def func1(*args: *Ts) -> tuple[*Ts]: + ... + + +Shape = TypeVarTuple("Shape") + + +class Array(Generic[*Shape]): + def __init__(self, shape: tuple[*Shape]): + self._shape: tuple[*Shape] = shape + + def get_shape(self) -> tuple[*Shape]: + return self._shape + + +Height = NewType("Height", int) +Width = NewType("Width", int) +Time = NewType("Time", int) +Batch = NewType("Batch", int) + +v1: Array[Height, Width] = Array((Height(1), Width(2))) # OK +v2: Array[Batch, Height, Width] = Array((Batch(1), Height(1), Width(1))) # OK +v3: Array[Time, Batch, Height, Width] = Array( + (Time(1), Batch(1), Height(1), Width(1)) +) # OK + +v4: Array[Height, Width] = Array(Height(1)) # Type error +v5: Array[Batch, Height, Width] = Array((Batch(1), Width(1))) # Type error +v6: Array[Time, Batch, Height, Width] = Array( + (Time(1), Batch(1), Width(1), Height(1)) +) # Type error + + +# > Type Variable Tuples Must Always be Unpacked + + +class ClassA(Generic[Shape]): # Type error: not unpacked + def __init__(self, shape: tuple[Shape]): # Type error: not unpacked + self._shape: tuple[*Shape] = shape + + def get_shape(self) -> tuple[Shape]: # Type error: not unpacked + return self._shape + + def method1(*args: Shape) -> None: # Type error: not unpacked + ... + + +# > TypeVarTuple does not yet support specification of variance, bounds, constraints. + +Ts1 = TypeVarTuple("Ts1", covariant=True) # Type error +Ts2 = TypeVarTuple("Ts2", int, float) # Type error +Ts3 = TypeVarTuple("Ts3", bound=int) # Type error + + +# > If the same TypeVarTuple instance is used in multiple places in a signature +# > or class, a valid type inference might be to bind the TypeVarTuple to a +# > tuple of a union of types. + + +def func2(arg1: tuple[*Ts], arg2: tuple[*Ts]) -> tuple[*Ts]: + ... + + +# > We do not allow this; type unions may not appear within the tuple. +# > If a type variable tuple appears in multiple places in a signature, +# > the types must match exactly (the list of type parameters must be the +# > same length, and the type parameters themselves must be identical) + +# Note from Eric Traut: The above provision in the spec is very problematic +# and will likely need to be changed. + +assert_type(func1((0,), (1,)), tuple[int]) # OK +func1((0,), ("0",)) # Type error? +func1((0,), (0.0,)) # Type error? +func1((0.0,), (0,)) # Type error? +func1((0,), (1,)) # Type error? +func1((0, 0), (0,)) # Type error + + +def multiply(x: Array[*Shape], y: Array[*Shape]) -> Array[*Shape]: + ... + + +def func3(x: Array[Height], y: Array[Width], z: Array[Height, Width]): + multiply(x, x) # OK + multiply(x, y) # Type error + multiply(x, z) # Type error + + +# > Only a single type variable tuple may appear in a type parameter list. + + +class Array3(Generic[*Ts1, *Ts2]): # Type error + ... diff --git a/conformance/tests/generics_typevartuple_callable.py b/conformance/tests/generics_typevartuple_callable.py new file mode 100644 index 000000000..5cfbc30e8 --- /dev/null +++ b/conformance/tests/generics_typevartuple_callable.py @@ -0,0 +1,46 @@ +""" +Tests the use of TypeVarTuple within a Callable. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#type-variable-tuples-with-callable + +# > Type variable tuples can also be used in the arguments section of a Callable. + + +from typing import Callable, TypeVar, TypeVarTuple, assert_type + +Ts = TypeVarTuple("Ts") +T = TypeVar("T") + + +class Process: + def __init__(self, target: Callable[[*Ts], None], args: tuple[*Ts]) -> None: + ... + + +def func1(arg1: int, arg2: str) -> None: + ... + + +Process(target=func1, args=(0, "")) # OK +Process(target=func1, args=("", 0)) # Type error + + +def func2(f: Callable[[int, *Ts, T], tuple[T, *Ts]]) -> tuple[*Ts, T]: + ... + + +def callback1(a: int, b: str, c: int, d: complex) -> tuple[complex, str, int]: + ... + + +def callback2(a: int, d: str) -> tuple[str]: + ... + + +assert_type(func2(callback1), tuple[str, int, complex]) +assert_type(func2(callback2), tuple[str]) + + +def func3(*args: * tuple[int, *Ts, T]) -> tuple[T, *Ts]: + ... diff --git a/conformance/tests/generics_typevartuple_concat.py b/conformance/tests/generics_typevartuple_concat.py new file mode 100644 index 000000000..3f24821bf --- /dev/null +++ b/conformance/tests/generics_typevartuple_concat.py @@ -0,0 +1,56 @@ +""" +Tests type concatenation using TypeVarTuples. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#type-concatenation + +# > Type variable tuples don’t have to be alone; normal types can be prefixed and/or suffixed. + +from typing import Generic, NewType, TypeVar, TypeVarTuple, assert_type + + +Height = NewType("Height", int) +Width = NewType("Width", int) +Batch = NewType("Batch", int) +Channels = NewType("Channels", int) + +Shape = TypeVarTuple("Shape") +Ts = TypeVarTuple("Ts") +T = TypeVar("T") + + +class Array(Generic[*Ts]): + ... + + +def add_batch_axis(x: Array[*Shape]) -> Array[Batch, *Shape]: + ... + + +def del_batch_axis(x: Array[Batch, *Shape]) -> Array[*Shape]: + ... + + +def add_batch_channels(x: Array[*Shape]) -> Array[Batch, *Shape, Channels]: + ... + + +def func1(a: Array[Height, Width]): + b = add_batch_axis(a) # OK + assert_type(b, Array[Batch, Height, Width]) + c = del_batch_axis(b) # OK + assert_type(c, Array[Height, Width]) + d = add_batch_channels(a) # OK + assert_type(d, Array[Batch, Height, Width, Channels]) + + +def prefix_tuple(x: T, y: tuple[*Ts]) -> tuple[T, *Ts]: + ... + + +z = prefix_tuple(x=0, y=(True, "a")) +assert_type(z, tuple[int, bool, str]) + + +def move_first_element_to_last(tup: tuple[T, *Ts]) -> tuple[*Ts, T]: + return (*tup[1:], tup[0]) diff --git a/conformance/tests/generics_typevartuple_overloads.py b/conformance/tests/generics_typevartuple_overloads.py new file mode 100644 index 000000000..26c38a674 --- /dev/null +++ b/conformance/tests/generics_typevartuple_overloads.py @@ -0,0 +1,31 @@ +""" +Tests the use of TypeVarTuple in function overloads. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#overloads-for-accessing-individual-types + +from typing import Any, Generic, TypeVar, TypeVarTuple, assert_type, overload + + +Shape = TypeVarTuple("Shape") +Axis1 = TypeVar("Axis1") +Axis2 = TypeVar("Axis2") +Axis3 = TypeVar("Axis3") + + +class Array(Generic[*Shape]): + @overload + def transpose(self: "Array[Axis1, Axis2]") -> "Array[Axis2, Axis1]": + ... + + @overload + def transpose(self: "Array[Axis1, Axis2, Axis3]") -> "Array[Axis3, Axis2, Axis1]": + ... + + def transpose(self) -> Any: + pass + + +def func1(a: Array[Axis1, Axis2], b: Array[Axis1, Axis2, Axis3]): + assert_type(a.transpose(), Array[Axis2, Axis1]) + assert_type(b.transpose(), Array[Axis3, Axis2, Axis1]) diff --git a/conformance/tests/generics_typevartuple_specialization.py b/conformance/tests/generics_typevartuple_specialization.py new file mode 100644 index 000000000..f98e21ba6 --- /dev/null +++ b/conformance/tests/generics_typevartuple_specialization.py @@ -0,0 +1,163 @@ +""" +Tests the handling of a TypeVarTuple specialization. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#behaviour-when-type-parameters-are-not-specified + +from typing import Any, Generic, NewType, TypeVar, TypeVarTuple, assert_type + + +Ts = TypeVarTuple("Ts") +Height = NewType("Height", int) +Width = NewType("Width", int) +Time = NewType("Time", int) + + +class Array(Generic[*Ts]): + ... + + +def takes_any_array1(arr: Array): + ... + + +def takes_any_array2(arr: Array[*tuple[Any, ...]]): + ... + + +def func1(x: Array[Height, Width]): + takes_any_array1(x) # OK + takes_any_array2(x) # OK + + +def func2(y: Array[Time, Height, Width]): + takes_any_array1(y) # OK + takes_any_array2(y) # OK + + +# > Generic aliases can be created using a type variable tuple in a similar +# > way to regular type variables. + +IntTuple = tuple[int, *Ts] +NamedArray = tuple[str, Array[*Ts]] + + +def func3(a: IntTuple[float, bool], b: NamedArray[Height]): + assert_type(a, tuple[int, float, bool]) + assert_type(b, tuple[str, Array[Height]]) + + +def func4(a: IntTuple[()], b: NamedArray[()]): + assert_type(a, tuple[int]) + assert_type(b, tuple[str, Array[()]]) + + +Shape = TypeVarTuple("Shape") +DType = TypeVar("DType") + + +class Array2(Generic[DType, *Shape]): + ... + + +FloatArray = Array2[float, *Shape] +Array1D = Array2[DType, Any] + + +def func5(a: Array1D, b: Array1D[int]): + assert_type(a, Array2[Any, Any]) + assert_type(b, Array2[int, Any]) + + +def takes_float_array_of_any_shape(x: FloatArray): + ... + + +x: FloatArray[Height, Width] = Array2() +takes_float_array_of_any_shape(x) # OK + + +def takes_float_array_with_specific_shape(y: FloatArray[Height, Width]): + ... + + +y: FloatArray = Array2() +takes_float_array_with_specific_shape(y) # OK + + +T = TypeVar("T") +VariadicTuple = tuple[T, *Ts] + + +def func6(a: VariadicTuple[str, int], b: VariadicTuple[float], c: VariadicTuple): + assert_type(a, tuple[str, int]) + assert_type(b, tuple[float]) + assert_type(c, tuple[Any, ...]) + + +Ts1 = TypeVar("Ts1") +Ts2 = TypeVar("Ts2") + +IntTupleVar = tuple[int, *Ts1] # OK +IntFloatTupleVar = IntTupleVar[float, *Ts2] # OK +IntFloatsTupleVar = IntTupleVar[*tuple[float, ...]] # OK + + +IntTupleGeneric = tuple[int, T] + +IntTupleGeneric[str] # OK +IntTupleGeneric[*Ts] # Type error +IntTupleGeneric[*tuple[float, ...]] # Type error + + +T1 = TypeVar("T1") +T2 = TypeVar("T2") +T3 = TypeVar("T3") + +TA1 = tuple[*Ts, T1, T2] # OK +TA2 = tuple[T1, T2, *Ts] # OK +TA3 = tuple[T1, *Ts, T2, T3] # OK +TA4 = tuple[T1, T2, *tuple[int, ...]] # OK +TA5 = tuple[T1, *Ts, T2, *Ts] # Type error +TA6 = tuple[T1, *Ts, T2, *tuple[int, ...]] # Type error + + +TA7 = tuple[*Ts, T1, T2] + +v1: TA7[int] # Type error: requires at least two type arguments + + +def func7(a: TA7[*Ts, T1, T2]) -> tuple[tuple[*Ts], T1, T2]: + ... + + +def func8(a: TA7[str, bool], b: TA7[str, bool, float], c: TA7[str, bool, float, int]): + assert_type(func7(a), tuple[tuple[()], str, bool]) + assert_type(func7(b), tuple[tuple[str], bool, float]) + assert_type(func7(c), tuple[tuple[str, bool], float, int]) + + +TA8 = tuple[T1, *Ts, T2, T3] + + +def func9(a: TA8[T1, *Ts, T2, T3]) -> tuple[tuple[*Ts], T1, T2, T3]: + ... + + +def func10(a: TA8[str, bool, float], b: TA8[str, bool, float, int]): + assert_type(func9(a), tuple[tuple[()], str, bool, float]) + assert_type(func9(b), tuple[tuple[bool], str, float, int]) + + +TA9 = tuple[*Ts, T1] +TA10 = TA9[*tuple[int, ...]] # OK + + +def func11(a: TA10, b: TA9[*tuple[int, ...], str], c: TA9[str, *tuple[int, ...]]): + assert_type(a, tuple[*tuple[int, ...], int]) + assert_type(b, tuple[*tuple[int, ...], str]) + assert_type(c, tuple[str, *tuple[int, ...], int]) + + +TA11 = tuple[T, *Ts1] +v2: TA11[*Ts2] # Type error diff --git a/conformance/tests/generics_typevartuple_unpack.py b/conformance/tests/generics_typevartuple_unpack.py new file mode 100644 index 000000000..b1b8d9436 --- /dev/null +++ b/conformance/tests/generics_typevartuple_unpack.py @@ -0,0 +1,68 @@ +""" +Tests unpack operations for TypeVarTuple. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#unpacking-tuple-types + +from typing import Any, Generic, NewType, TypeVarTuple, assert_type + +# > Unpacking a concrete tuple type is analogous to unpacking a tuple of values at runtime. + + +def func1(x: tuple[int, *tuple[bool, bool], str]): + assert_type(x, tuple[int, bool, bool, str]) + assert_type(x, tuple[*tuple[int, bool], bool, str]) + assert_type(x, tuple[int, bool, *tuple[bool, str]]) + + +# > Unpacking an unbounded tuple preserves the unbounded tuple as it is. + + +def func2(x: tuple[int, *tuple[bool, ...], str]): + assert_type(x, tuple[int, *tuple[bool, ...], str]) + + +Height = NewType("Height", int) +Width = NewType("Width", int) +Batch = NewType("Batch", int) +Channels = NewType("Channels", int) + +Ts = TypeVarTuple("Ts") + + +class Array(Generic[*Ts]): + ... + + +def process_batch_channels(x: Array[Batch, *tuple[Any, ...], Channels]) -> None: + ... + + +def func3( + x: Array[Batch, Height, Width, Channels], y: Array[Batch, Channels], z: Array[Batch] +): + process_batch_channels(x) # OK + process_batch_channels(y) # OK + process_batch_channels(z) # Type error + + +Shape = TypeVarTuple("Shape") + + +def expect_variadic_array(x: Array[Batch, *Shape]) -> None: + ... + + +def expect_precise_array(x: Array[Batch, Height, Width, Channels]) -> None: + ... + + +def func4(y: Array[*tuple[Any, ...]]): + expect_variadic_array(y) # OK + expect_precise_array(y) # OK + + +# > As with TypeVarTuples, only one unpacking may appear in a tuple: + +bad1: tuple[*tuple[int], *tuple[int]] # Type error +bad2: tuple[*tuple[int, ...], *tuple[int]] # Type error diff --git a/conformance/tests/generics_variance.py b/conformance/tests/generics_variance.py new file mode 100644 index 000000000..eba8004d1 --- /dev/null +++ b/conformance/tests/generics_variance.py @@ -0,0 +1,57 @@ +""" +Tests the handling and enforcement of TypeVar variance. +""" + +# Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#variance + +from typing import TypeVar, Generic +from collections.abc import Iterable, Iterator + +# > To facilitate the declaration of container types where covariant or +# > contravariant type checking is acceptable, type variables accept +# > keyword arguments covariant=True or contravariant=True. At most one of +# > these may be passed. +X1 = TypeVar("X1", covariant=True, contravariant=True) # Type error + + +T_co = TypeVar("T_co", covariant=True) + + +class ImmutableList(Generic[T_co]): + def __init__(self, items: Iterable[T_co]) -> None: + ... + + def __iter__(self) -> Iterator[T_co]: + ... + + +class Employee: + ... + + +class Manager(Employee): + ... + + +managers: ImmutableList[Manager] = ImmutableList([Manager()]) +employees: ImmutableList[Employee] = managers # OK + + +E = TypeVar("E", bound=Employee) + + +def dump_employee(e: E) -> E: + return e + + +dump_employee(Manager()) # OK + + +B_co = TypeVar("B_co", covariant=True) + + +# > Variance is only applicable to generic types; generic functions do not +# > have this property. The latter should be defined using only type variables +# > without covariant or contravariant keyword arguments. +def bad_func(x: list[B_co]) -> B_co: # Type checker error + ... diff --git a/conformance/tests/generics_variance_inference.py b/conformance/tests/generics_variance_inference.py new file mode 100644 index 000000000..b6262f939 --- /dev/null +++ b/conformance/tests/generics_variance_inference.py @@ -0,0 +1,194 @@ +""" +Tests variance inference for type parameters. +""" + +# Specification: https://peps.python.org/pep-0695/#variance-inference + +from dataclasses import dataclass + +# T1 should be invariant +# T2 should be contravariant +# T3 should be covariant +from typing import Generic, Sequence, TypeVar + + +class ClassA[T1, T2, T3](list[T1]): + def method1(self, a: T2) -> None: + ... + + def method2(self) -> T3: + ... + + +def func_a(p1: ClassA[float, int, int], p2: ClassA[int, float, float]): + v1: ClassA[int, int, int] = p1 # Type error + v2: ClassA[float, float, int] = p1 # Type error + v3: ClassA[float, int, float] = p1 # OK + + v4: ClassA[int, int, int] = p2 # Type error + v5: ClassA[int, int, float] = p2 # OK + + +class ShouldBeCovariant1[T]: + def __getitem__(self, index: int) -> T: + ... + + def __iter__(self) -> Iterator[T]: + ... + + +vco1_1: ShouldBeCovariant1[float] = ShouldBeCovariant1[int]() # OK +vco1_2: ShouldBeCovariant1[int] = ShouldBeCovariant1[float]() # Type error + + +class ShouldBeCovariant2[T](Sequence[T]): + pass + + +vco2_1: ShouldBeCovariant2[float] = ShouldBeCovariant2[int]() # OK +vco2_2: ShouldBeCovariant2[int] = ShouldBeCovariant2[float]() # Type error + + +class ShouldBeCovariant3[T]: + def method1(self) -> "ShouldBeCovariant2[T]": + ... + + +vco3_1: ShouldBeCovariant3[float] = ShouldBeCovariant3[int]() # OK +vco3_2: ShouldBeCovariant3[int] = ShouldBeCovariant3[float]() # Type error + + +@dataclass(frozen=True) +class ShouldBeCovariant4[T]: + x: T + + +vo4_1: ShouldBeCovariant4[float] = ShouldBeCovariant4[int](1) # OK +vo4_2: ShouldBeCovariant4[int] = ShouldBeCovariant4[float](1) # Type error + + +class ShouldBeCovariant5[T]: + def __init__(self, x: T) -> None: + self._x = x + + @property + def x(self) -> T: + return self._x + + +vo5_1: ShouldBeCovariant5[float] = ShouldBeCovariant5[int](1) # OK +vo5_2: ShouldBeCovariant5[int] = ShouldBeCovariant5[float](1) # Type error + + +class ShouldBeInvariant1[T]: + def __init__(self, value: T) -> None: + self._value = value + + @property + def value(self): + return self._value + + @value.setter + def value(self, value: T): + self._value = value + + +vinv1_1: ShouldBeInvariant1[float] = ShouldBeInvariant1[int](1) # Type error +vinv1_2: ShouldBeInvariant1[int] = ShouldBeInvariant1[float](1.1) # Type error + + +class ShouldBeInvariant2[T]: + def __init__(self, value: T) -> None: + self._value = value + + def get_value(self) -> T: + return self._value + + def set_value(self, value: T): + self._value = value + + +vinv2_1: ShouldBeInvariant2[float] = ShouldBeInvariant2[int](1) # Type error +vinv2_2: ShouldBeInvariant2[int] = ShouldBeInvariant2[float](1.1) # Type error + + +class ShouldBeInvariant3[K, V](dict[K, V]): + pass + + +vinv3_1: ShouldBeInvariant3[float, str] = ShouldBeInvariant3[int, str]() # Type error +vinv3_2: ShouldBeInvariant3[int, str] = ShouldBeInvariant3[float, str]() # Type error +vinv3_3: ShouldBeInvariant3[str, float] = ShouldBeInvariant3[str, int]() # Type error +vinv3_4: ShouldBeInvariant3[str, int] = ShouldBeInvariant3[str, float]() # Type error + + +@dataclass +class ShouldBeInvariant4[T]: + x: T + + +vinv4_1: ShouldBeInvariant4[float] = ShouldBeInvariant4[int](1) # Type error + + +class ShouldBeInvariant5[T]: + def __init__(self, x: T) -> None: + self.x = x + + +vinv5_1: ShouldBeInvariant5[float] = ShouldBeInvariant5[int](1) # Type error + + +class ShouldBeContravariant1[T]: + def __init__(self, value: T) -> None: + pass + + def set_value(self, value: T) -> None: + pass + + +vcontra1_1: ShouldBeContravariant1[float] = ShouldBeContravariant1[int](1) # Type error +vcontra1_2: ShouldBeContravariant1[int] = ShouldBeContravariant1[float](1.2) # OK + + +# Test the case where a class with inferred variance derives from +# a traditional class that doesn't use inferred variance. + +T = TypeVar("T") +T_co = TypeVar("T_co", covariant=True) +T_contra = TypeVar("T_contra", contravariant=True) + + +class Parent_Invariant(Generic[T]): + pass + + +class ShouldBeInvariant1[T](Parent_Invariant[T]): + pass + + +a1: ShouldBeInvariant1[int] = ShouldBeInvariant1[float]() # Type error +a2: ShouldBeInvariant1[float] = ShouldBeInvariant1[int]() # Type error + + +class Parent_Covariant(Generic[T_co]): + pass + + +class ShouldBeCovariant1[T](Parent_Covariant[T]): + pass + + +b1: ShouldBeCovariant1[int] = ShouldBeCovariant1[float]() # Type error +b2: ShouldBeCovariant1[float] = ShouldBeCovariant1[int]() # OK + + +class Parent_Contravariant(Generic[T_contra]): + pass + + +class ShouldBeContravariant1[T](Parent_Contravariant[T]): + pass + + +c1: ShouldBeContravariant1[int] = ShouldBeContravariant1[float]() # OK +c2: ShouldBeContravariant1[float] = ShouldBeContravariant1[int]() # Type error diff --git a/conformance/tests/qualifiers_final_decorator.py b/conformance/tests/qualifiers_final_decorator.py index b03d7c54c..c33b0f8df 100644 --- a/conformance/tests/qualifiers_final_decorator.py +++ b/conformance/tests/qualifiers_final_decorator.py @@ -82,7 +82,7 @@ def method(self, x: int) -> int: ... @overload - @final # Type error: should be applied only to implementation + @final # Type error: should be applied only to implementation def method(self, x: str) -> str: ... From 5d5282087b6cc91cdd9a7a2a950a7ea1615769ae Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 5 Jan 2024 00:21:35 -0700 Subject: [PATCH 2/9] Expanded `@no_type_check` test to cover classes. --- .../results/mypy/directives_no_type_check.toml | 6 +++++- conformance/results/mypy/version.toml | 2 +- .../results/pyre/directives_no_type_check.toml | 11 ++++++----- conformance/results/pyre/version.toml | 2 +- .../results/pyright/directives_no_type_check.toml | 12 +++++++----- conformance/results/pyright/version.toml | 2 +- .../results/pytype/directives_no_type_check.toml | 11 +++++++---- conformance/results/pytype/protocols_generic.toml | 6 +++--- conformance/results/pytype/version.toml | 2 +- conformance/results/results.html | 10 +++++----- conformance/tests/directives_no_type_check.py | 5 +++++ 11 files changed, 42 insertions(+), 27 deletions(-) diff --git a/conformance/results/mypy/directives_no_type_check.toml b/conformance/results/mypy/directives_no_type_check.toml index 2146548eb..4a5499ce6 100644 --- a/conformance/results/mypy/directives_no_type_check.toml +++ b/conformance/results/mypy/directives_no_type_check.toml @@ -1,3 +1,7 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +Does not honor `@no_type_check` class decorator. +""" output = """ +directives_no_type_check.py:16: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment] """ diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index 277e06ef3..736b81322 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.248046875 +test_duration = 1.2672231197357178 diff --git a/conformance/results/pyre/directives_no_type_check.toml b/conformance/results/pyre/directives_no_type_check.toml index 639a79cb5..c8968e5f4 100644 --- a/conformance/results/pyre/directives_no_type_check.toml +++ b/conformance/results/pyre/directives_no_type_check.toml @@ -3,9 +3,10 @@ notes = """ 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`. +directives_no_type_check.py:16:4 Incompatible attribute type [8]: Attribute `x` declared in class `ClassA` has type `int` but is used as type `str`. +directives_no_type_check.py:21:12 Unsupported operand [58]: `+` is not supported for operand types `int` and `str`. +directives_no_type_check.py:22:4 Incompatible return type [7]: Expected `None` but got `int`. +directives_no_type_check.py:25:6 Incompatible parameter type [6]: In call `func1`, for 1st positional argument, expected `int` but got `bytes`. +directives_no_type_check.py:25:18 Incompatible parameter type [6]: In call `func1`, for 2nd positional argument, expected `str` but got `bytes`. +directives_no_type_check.py:26:0 Missing argument [20]: Call `func1` expects argument `a`. """ diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml index e5c2ca0f6..c0893652a 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.2906670570373535 +test_duration = 1.989300012588501 diff --git a/conformance/results/pyright/directives_no_type_check.toml b/conformance/results/pyright/directives_no_type_check.toml index 6bc67f59b..0d6c17e0b 100644 --- a/conformance/results/pyright/directives_no_type_check.toml +++ b/conformance/results/pyright/directives_no_type_check.toml @@ -3,12 +3,14 @@ notes = """ Intentionally does not honor @no_type_check decorator. """ 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" +directives_no_type_check.py:16:14 - error: Expression of type "Literal['']" cannot be assigned to declared type "int" +  "Literal['']" is incompatible with "int" (reportGeneralTypeIssues) +directives_no_type_check.py:21:9 - error: Operator "+" not supported for types "int" and "str" (reportGeneralTypeIssues) +directives_no_type_check.py:22: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" +directives_no_type_check.py:25: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" +directives_no_type_check.py:25: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) +directives_no_type_check.py:26:1 - error: Arguments missing for parameters "a", "b" (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index 79bcf2850..b63904845 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.43935227394104 +test_duration = 1.3031880855560303 diff --git a/conformance/results/pytype/directives_no_type_check.toml b/conformance/results/pytype/directives_no_type_check.toml index 81bfe75b3..b9aca243f 100644 --- a/conformance/results/pytype/directives_no_type_check.toml +++ b/conformance/results/pytype/directives_no_type_check.toml @@ -3,15 +3,18 @@ notes = """ Does not honor @no_type_check decorator. """ output = """ -File "directives_no_type_check.py", line 16, in func1: unsupported operand type(s) for +: int and str [unsupported-operands] +File "directives_no_type_check.py", line 16, in ClassA: Type annotation for x does not match type of assignment [annotation-type-mismatch] + Annotation: int + Assignment: str +File "directives_no_type_check.py", line 21, in func1: unsupported operand type(s) for +: int and str [unsupported-operands] Function __add__ on int expects int -File "directives_no_type_check.py", line 17, in func1: bad return type [bad-return-type] +File "directives_no_type_check.py", line 22, 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] +File "directives_no_type_check.py", line 25, 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] +File "directives_no_type_check.py", line 26, in : Missing parameter 'a' in call to function func1 [missing-parameter] Expected: (a, b) Actually passed: () """ diff --git a/conformance/results/pytype/protocols_generic.toml b/conformance/results/pytype/protocols_generic.toml index 5ce4b02a5..cfc64f916 100644 --- a/conformance/results/pytype/protocols_generic.toml +++ b/conformance/results/pytype/protocols_generic.toml @@ -11,13 +11,13 @@ File "protocols_generic.py", line 40, in : Type annotation for p2 does n Annotation: Proto1[int, str] Assignment: Concrete1 - Method method1 of protocol Proto1[int, str] has the wrong signature in Concrete1: + Method __iter__ of protocol Proto1[int, str] has the wrong signature in Concrete1: >> Proto1[int, str] expects: - def method1(self, x: S) -> S: ... + def __iter__(self) -> Iterator[T_co]: ... >> Concrete1 defines: - def method1(self, x: str) -> str: ... + def __iter__(self) -> Iterator[int]: ... File "protocols_generic.py", line 44, in : Invalid type annotation 'Proto2' [invalid-annotation] Cannot inherit from Generic[...] multiple times File "protocols_generic.py", line 56, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] diff --git a/conformance/results/pytype/version.toml b/conformance/results/pytype/version.toml index 1df6cb201..afe00fe70 100644 --- a/conformance/results/pytype/version.toml +++ b/conformance/results/pytype/version.toml @@ -1,2 +1,2 @@ version = "pytype 2023.12.18" -test_duration = 26.562921047210693 +test_duration = 27.926777124404907 diff --git a/conformance/results/results.html b/conformance/results/results.html index a24a30c44..cbbef456a 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.25sec) +
mypy 1.8.0(1.27sec)
@@ -261,7 +261,7 @@

Python Type System Conformance Test Results

Type checker directives - + @@ -270,7 +270,7 @@

Python Type System Conformance Test Results

     directives_assert_typePass
     directives_castPass
     directives_no_type_checkPass
     directives_no_type_checkPartialDoes not honor `@no_type_check` class decorator.
     directives_reveal_typePass
     directives_type_checkingPass
     directives_type_ignorePartialDoes not honor "# type: ignore" comment if comment includes additional text.
     directives_version_platformPassDoes not understand three-element form of sys.version checks.
Does not understand os.name checks.
-
pyright 1.1.344(1.44sec) +
pyright 1.1.344(1.30sec)
@@ -413,7 +413,7 @@

Python Type System Conformance Test Results

     directives_version_platformPass
-
pyre 0.9.19(2.29sec) +
pyre 0.9.19(1.99sec)
@@ -556,7 +556,7 @@

Python Type System Conformance Test Results

     directives_version_platformPartialDoes not support sys.platform checks.
Does not support os.name checks.
-
pytype 2023.12.18(26.56sec) +
pytype 2023.12.18(27.93sec)
diff --git a/conformance/tests/directives_no_type_check.py b/conformance/tests/directives_no_type_check.py index f62a7a1e7..8d860d960 100644 --- a/conformance/tests/directives_no_type_check.py +++ b/conformance/tests/directives_no_type_check.py @@ -11,6 +11,11 @@ # > Functions with this decorator should be treated as having no annotations. +@no_type_check +class ClassA: + x: int = "" # No error should be reported + + @no_type_check def func1(a: int, b: str) -> None: c = a + b # No error should be reported From 728b24c5a485fc665b4ab4338e7bd792914160e0 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 5 Jan 2024 10:52:15 -0700 Subject: [PATCH 3/9] Implemented PR suggestions by @hauntsaninja. --- .../mypy/generics_paramspec_basic.toml | 1 - .../mypy/generics_syntax_declarations.toml | 15 +-- .../mypy/generics_syntax_infer_variance.toml | 97 ++++++++++--------- .../pyre/generics_paramspec_basic.toml | 1 + .../pyre/generics_syntax_declarations.toml | 2 +- .../pyre/generics_syntax_infer_variance.toml | 2 +- .../pyright/generics_paramspec_basic.toml | 1 - .../pyright/generics_syntax_declarations.toml | 16 +-- .../generics_syntax_infer_variance.toml | 26 ++--- .../generics_syntax_infer_variance.toml | 2 +- .../results/pytype/protocols_generic.toml | 6 +- .../pytype/qualifiers_final_decorator.toml | 4 +- conformance/results/results.html | 6 +- conformance/tests/generics_paramspec_basic.py | 4 +- .../tests/generics_syntax_declarations.py | 8 +- .../tests/generics_syntax_infer_variance.py | 13 ++- docs/spec/generics.rst | 2 +- 17 files changed, 117 insertions(+), 89 deletions(-) diff --git a/conformance/results/mypy/generics_paramspec_basic.toml b/conformance/results/mypy/generics_paramspec_basic.toml index 53244490e..2e3311ae5 100644 --- a/conformance/results/mypy/generics_paramspec_basic.toml +++ b/conformance/results/mypy/generics_paramspec_basic.toml @@ -10,7 +10,6 @@ generics_paramspec_basic.py:27: error: Invalid location for Concatenate [valid- generics_paramspec_basic.py:27: note: You can use Concatenate as the first argument to Callable generics_paramspec_basic.py:31: error: Invalid location for ParamSpec "P" [misc] generics_paramspec_basic.py:31: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' -generics_paramspec_basic.py:35: error: Name "func3" already defined on line 31 [no-redef] generics_paramspec_basic.py:35: error: Invalid location for ParamSpec "P" [valid-type] generics_paramspec_basic.py:35: note: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]' generics_paramspec_basic.py:39: error: Invalid location for ParamSpec "P" [valid-type] diff --git a/conformance/results/mypy/generics_syntax_declarations.toml b/conformance/results/mypy/generics_syntax_declarations.toml index e37dcf135..fa042041b 100644 --- a/conformance/results/mypy/generics_syntax_declarations.toml +++ b/conformance/results/mypy/generics_syntax_declarations.toml @@ -14,21 +14,22 @@ generics_syntax_declarations.py:19: error: PEP 695 generics are not yet supporte generics_syntax_declarations.py:19: error: Free type variable expected in Generic[...] [misc] generics_syntax_declarations.py:19: error: Name "T" is not defined [name-defined] generics_syntax_declarations.py:23: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:23: error: Free type variable expected in Protocol[...] [misc] -generics_syntax_declarations.py:23: error: Name "S" is not defined [name-defined] -generics_syntax_declarations.py:23: error: Name "T" is not defined [name-defined] generics_syntax_declarations.py:27: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:28: error: Name "T" is not defined [name-defined] -generics_syntax_declarations.py:33: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:27: error: Free type variable expected in Protocol[...] [misc] +generics_syntax_declarations.py:27: error: Name "S" is not defined [name-defined] +generics_syntax_declarations.py:27: error: Name "T" is not defined [name-defined] +generics_syntax_declarations.py:31: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:32: error: Name "T" is not defined [name-defined] generics_syntax_declarations.py:37: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_declarations.py:41: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:42: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:45: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_declarations.py:46: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_declarations.py:50: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_declarations.py:54: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_declarations.py:58: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_declarations.py:62: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_declarations.py:69: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:66: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_declarations.py:73: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_declarations.py:77: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_declarations.py:81: error: PEP 695 generics are not yet supported [valid-type] """ diff --git a/conformance/results/mypy/generics_syntax_infer_variance.toml b/conformance/results/mypy/generics_syntax_infer_variance.toml index 4a45f7ed5..fe39ac038 100644 --- a/conformance/results/mypy/generics_syntax_infer_variance.toml +++ b/conformance/results/mypy/generics_syntax_infer_variance.toml @@ -50,51 +50,60 @@ generics_syntax_infer_variance.py:72: error: The type "type[ShouldBeCovariant5]" generics_syntax_infer_variance.py:75: error: Free type variable expected in Generic[...] [misc] generics_syntax_infer_variance.py:76: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] generics_syntax_infer_variance.py:76: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:84: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:84: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:88: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:88: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:89: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:89: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:92: error: Free type variable expected in Generic[...] [misc] -generics_syntax_infer_variance.py:93: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:93: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:96: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:96: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:99: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:99: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:103: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:103: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:104: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:104: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:107: error: Variable "generics_syntax_infer_variance.K" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:78: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:78: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:82: error: "ShouldBeCovariant6" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:82: error: The type "type[ShouldBeCovariant6]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:83: error: "ShouldBeCovariant6" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:83: error: The type "type[ShouldBeCovariant6]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:86: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:87: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:87: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:95: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:95: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:99: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:99: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:100: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:100: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:103: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:104: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:104: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:107: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] generics_syntax_infer_variance.py:107: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:107: error: Variable "generics_syntax_infer_variance.V" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:111: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_syntax_infer_variance.py:111: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:112: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_syntax_infer_variance.py:112: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:113: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_syntax_infer_variance.py:113: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:114: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] -generics_syntax_infer_variance.py:114: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:118: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_infer_variance.py:119: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:119: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:122: error: "ShouldBeInvariant4" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:122: error: The type "type[ShouldBeInvariant4]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:125: error: PEP 695 generics are not yet supported [valid-type] -generics_syntax_infer_variance.py:126: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:126: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:130: error: "ShouldBeInvariant5" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:130: error: The type "type[ShouldBeInvariant5]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:133: error: Free type variable expected in Generic[...] [misc] -generics_syntax_infer_variance.py:134: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] -generics_syntax_infer_variance.py:134: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:110: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:110: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:114: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:114: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:115: error: "ShouldBeInvariant2" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:115: error: The type "type[ShouldBeInvariant2]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:118: error: Variable "generics_syntax_infer_variance.K" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:118: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:118: error: Variable "generics_syntax_infer_variance.V" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:122: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:122: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:123: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:123: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:124: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:124: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:125: error: "ShouldBeInvariant3" expects no type arguments, but 2 given [type-arg] +generics_syntax_infer_variance.py:125: error: The type "type[ShouldBeInvariant3]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:129: error: PEP 695 generics are not yet supported [valid-type] +generics_syntax_infer_variance.py:130: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:130: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:133: error: "ShouldBeInvariant4" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:133: error: The type "type[ShouldBeInvariant4]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:136: error: PEP 695 generics are not yet supported [valid-type] generics_syntax_infer_variance.py:137: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] generics_syntax_infer_variance.py:137: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -generics_syntax_infer_variance.py:141: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:141: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] -generics_syntax_infer_variance.py:142: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] -generics_syntax_infer_variance.py:142: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:141: error: "ShouldBeInvariant5" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:141: error: The type "type[ShouldBeInvariant5]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:144: error: Free type variable expected in Generic[...] [misc] +generics_syntax_infer_variance.py:145: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:145: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:148: error: Variable "generics_syntax_infer_variance.T" is not valid as a type [valid-type] +generics_syntax_infer_variance.py:148: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases +generics_syntax_infer_variance.py:152: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:152: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_syntax_infer_variance.py:153: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] +generics_syntax_infer_variance.py:153: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] """ diff --git a/conformance/results/pyre/generics_paramspec_basic.toml b/conformance/results/pyre/generics_paramspec_basic.toml index b1c685757..7d1bcadab 100644 --- a/conformance/results/pyre/generics_paramspec_basic.toml +++ b/conformance/results/pyre/generics_paramspec_basic.toml @@ -12,4 +12,5 @@ generics_paramspec_basic.py:18:0 Incompatible variable type [9]: TA3 is declared generics_paramspec_basic.py:18:26 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Tuple[typing.Any, Type[Variable[$synthetic_attribute_resolution_variable]]]` but got `Tuple[object, None]`. generics_paramspec_basic.py:27:13 Invalid type variable [34]: The type variable `P` isn't present in the function's parameters. generics_paramspec_basic.py:27:13 Undefined or invalid type [11]: Annotation `Concatenate` is not defined as a type. +generics_paramspec_basic.py:31:13 Invalid type parameters [24]: Single type parameter `Variable[_T]` expected, but a callable parameters `generics_paramspec_basic.P` was given for generic type list. """ diff --git a/conformance/results/pyre/generics_syntax_declarations.toml b/conformance/results/pyre/generics_syntax_declarations.toml index 8753d7012..e20d6f32e 100644 --- a/conformance/results/pyre/generics_syntax_declarations.toml +++ b/conformance/results/pyre/generics_syntax_declarations.toml @@ -3,5 +3,5 @@ notes = """ Type parameter syntax not yet support. """ output = """ -generics_syntax_declarations.py:13:13 Parsing failure [404]: invalid syntax +generics_syntax_declarations.py:13:17 Parsing failure [404]: invalid syntax """ diff --git a/conformance/results/pyre/generics_syntax_infer_variance.toml b/conformance/results/pyre/generics_syntax_infer_variance.toml index 4573868ba..cc7ea7bd8 100644 --- a/conformance/results/pyre/generics_syntax_infer_variance.toml +++ b/conformance/results/pyre/generics_syntax_infer_variance.toml @@ -3,5 +3,5 @@ notes = """ Type parameter syntax not yet support. """ output = """ -generics_syntax_infer_variance.py:118:25 Parsing failure [404]: invalid syntax +generics_syntax_infer_variance.py:129:25 Parsing failure [404]: invalid syntax """ diff --git a/conformance/results/pyright/generics_paramspec_basic.toml b/conformance/results/pyright/generics_paramspec_basic.toml index 23e6b60ce..5d0659b75 100644 --- a/conformance/results/pyright/generics_paramspec_basic.toml +++ b/conformance/results/pyright/generics_paramspec_basic.toml @@ -12,5 +12,4 @@ generics_paramspec_basic.py:31:19 - error: Type "P@func3" cannot be assigned to generics_paramspec_basic.py:35:35 - error: ParamSpec is not allowed in this context generics_paramspec_basic.py:39:18 - error: ParamSpec is not allowed in this context generics_paramspec_basic.py:39:31 - error: ParamSpec is not allowed in this context -generics_paramspec_basic.py:31:5 - error: Function declaration "func3" is obscured by a declaration of the same name (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/generics_syntax_declarations.toml b/conformance/results/pyright/generics_syntax_declarations.toml index b176885d4..9069b7519 100644 --- a/conformance/results/pyright/generics_syntax_declarations.toml +++ b/conformance/results/pyright/generics_syntax_declarations.toml @@ -1,14 +1,14 @@ conformant = "Pass" output = """ generics_syntax_declarations.py:19:17 - error: "Generic" base class cannot be used with type parameter syntax (reportGeneralTypeIssues) -generics_syntax_declarations.py:23:20 - error: Type arguments are not allowed with Protocol class when using type parameter syntax (reportGeneralTypeIssues) -generics_syntax_declarations.py:30:11 - error: Cannot access member "is_integer" for type "str*" +generics_syntax_declarations.py:27:20 - error: Type arguments are not allowed with Protocol class when using type parameter syntax (reportGeneralTypeIssues) +generics_syntax_declarations.py:34:11 - error: Cannot access member "is_integer" for type "str*"   Member "is_integer" is unknown (reportGeneralTypeIssues) -generics_syntax_declarations.py:42:21 - error: TypeVar constraint type cannot be generic -generics_syntax_declarations.py:46:17 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) -generics_syntax_declarations.py:58:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) +generics_syntax_declarations.py:46:21 - error: TypeVar constraint type cannot be generic +generics_syntax_declarations.py:50:17 - error: Expected type expression but received "list[Unknown]" (reportGeneralTypeIssues) generics_syntax_declarations.py:62:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) -generics_syntax_declarations.py:69:17 - error: Expected type expression but received "tuple[type[bytes], type[str]]" (reportGeneralTypeIssues) -generics_syntax_declarations.py:73:18 - error: Expected type expression but received "Literal[3]" (reportGeneralTypeIssues) -generics_syntax_declarations.py:77:23 - error: "S" is not defined (reportUndefinedVariable) +generics_syntax_declarations.py:66:17 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues) +generics_syntax_declarations.py:73:17 - error: Expected type expression but received "tuple[type[bytes], type[str]]" (reportGeneralTypeIssues) +generics_syntax_declarations.py:77:18 - error: Expected type expression but received "Literal[3]" (reportGeneralTypeIssues) +generics_syntax_declarations.py:81:23 - error: "S" is not defined (reportUndefinedVariable) """ diff --git a/conformance/results/pyright/generics_syntax_infer_variance.toml b/conformance/results/pyright/generics_syntax_infer_variance.toml index abb315d07..c27d8e8cd 100644 --- a/conformance/results/pyright/generics_syntax_infer_variance.toml +++ b/conformance/results/pyright/generics_syntax_infer_variance.toml @@ -22,37 +22,41 @@ generics_syntax_infer_variance.py:72:34 - error: Expression of type "ShouldBeCov   "ShouldBeCovariant5[float]" is incompatible with "ShouldBeCovariant5[int]"     Type parameter "T@ShouldBeCovariant5" is covariant, but "float" is not a subtype of "int"       "float" is incompatible with "int" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:88:38 - error: Expression of type "ShouldBeInvariant1[int]" cannot be assigned to declared type "ShouldBeInvariant1[float]" +generics_syntax_infer_variance.py:83:34 - error: Expression of type "ShouldBeCovariant6[float]" cannot be assigned to declared type "ShouldBeCovariant6[int]" +  "ShouldBeCovariant6[float]" is incompatible with "ShouldBeCovariant6[int]" +    Type parameter "T@ShouldBeCovariant6" is covariant, but "float" is not a subtype of "int" +      "float" is incompatible with "int" (reportGeneralTypeIssues) +generics_syntax_infer_variance.py:99:38 - error: Expression of type "ShouldBeInvariant1[int]" cannot be assigned to declared type "ShouldBeInvariant1[float]"   "ShouldBeInvariant1[int]" is incompatible with "ShouldBeInvariant1[float]"     Type parameter "T@ShouldBeInvariant1" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:89:36 - error: Expression of type "ShouldBeInvariant1[float]" cannot be assigned to declared type "ShouldBeInvariant1[int]" +generics_syntax_infer_variance.py:100:36 - error: Expression of type "ShouldBeInvariant1[float]" cannot be assigned to declared type "ShouldBeInvariant1[int]"   "ShouldBeInvariant1[float]" is incompatible with "ShouldBeInvariant1[int]"     Type parameter "T@ShouldBeInvariant1" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:103:38 - error: Expression of type "ShouldBeInvariant2[int]" cannot be assigned to declared type "ShouldBeInvariant2[float]" +generics_syntax_infer_variance.py:114:38 - error: Expression of type "ShouldBeInvariant2[int]" cannot be assigned to declared type "ShouldBeInvariant2[float]"   "ShouldBeInvariant2[int]" is incompatible with "ShouldBeInvariant2[float]"     Type parameter "T@ShouldBeInvariant2" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:104:36 - error: Expression of type "ShouldBeInvariant2[float]" cannot be assigned to declared type "ShouldBeInvariant2[int]" +generics_syntax_infer_variance.py:115:36 - error: Expression of type "ShouldBeInvariant2[float]" cannot be assigned to declared type "ShouldBeInvariant2[int]"   "ShouldBeInvariant2[float]" is incompatible with "ShouldBeInvariant2[int]"     Type parameter "T@ShouldBeInvariant2" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:111:43 - error: Expression of type "ShouldBeInvariant3[int, str]" cannot be assigned to declared type "ShouldBeInvariant3[float, str]" +generics_syntax_infer_variance.py:122:43 - error: Expression of type "ShouldBeInvariant3[int, str]" cannot be assigned to declared type "ShouldBeInvariant3[float, str]"   "ShouldBeInvariant3[int, str]" is incompatible with "ShouldBeInvariant3[float, str]"     Type parameter "K@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:112:41 - error: Expression of type "ShouldBeInvariant3[float, str]" cannot be assigned to declared type "ShouldBeInvariant3[int, str]" +generics_syntax_infer_variance.py:123:41 - error: Expression of type "ShouldBeInvariant3[float, str]" cannot be assigned to declared type "ShouldBeInvariant3[int, str]"   "ShouldBeInvariant3[float, str]" is incompatible with "ShouldBeInvariant3[int, str]"     Type parameter "K@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:113:43 - error: Expression of type "ShouldBeInvariant3[str, int]" cannot be assigned to declared type "ShouldBeInvariant3[str, float]" +generics_syntax_infer_variance.py:124:43 - error: Expression of type "ShouldBeInvariant3[str, int]" cannot be assigned to declared type "ShouldBeInvariant3[str, float]"   "ShouldBeInvariant3[str, int]" is incompatible with "ShouldBeInvariant3[str, float]"     Type parameter "V@ShouldBeInvariant3" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:114:41 - error: Expression of type "ShouldBeInvariant3[str, float]" cannot be assigned to declared type "ShouldBeInvariant3[str, int]" +generics_syntax_infer_variance.py:125:41 - error: Expression of type "ShouldBeInvariant3[str, float]" cannot be assigned to declared type "ShouldBeInvariant3[str, int]"   "ShouldBeInvariant3[str, float]" is incompatible with "ShouldBeInvariant3[str, int]"     Type parameter "V@ShouldBeInvariant3" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:122:38 - error: Expression of type "ShouldBeInvariant4[int]" cannot be assigned to declared type "ShouldBeInvariant4[float]" +generics_syntax_infer_variance.py:133:38 - error: Expression of type "ShouldBeInvariant4[int]" cannot be assigned to declared type "ShouldBeInvariant4[float]"   "ShouldBeInvariant4[int]" is incompatible with "ShouldBeInvariant4[float]"     Type parameter "T@ShouldBeInvariant4" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:130:38 - error: Expression of type "ShouldBeInvariant5[int]" cannot be assigned to declared type "ShouldBeInvariant5[float]" +generics_syntax_infer_variance.py:141:38 - error: Expression of type "ShouldBeInvariant5[int]" cannot be assigned to declared type "ShouldBeInvariant5[float]"   "ShouldBeInvariant5[int]" is incompatible with "ShouldBeInvariant5[float]"     Type parameter "T@ShouldBeInvariant5" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) -generics_syntax_infer_variance.py:141:45 - error: Expression of type "ShouldBeContravariant1[int]" cannot be assigned to declared type "ShouldBeContravariant1[float]" +generics_syntax_infer_variance.py:152:45 - error: Expression of type "ShouldBeContravariant1[int]" cannot be assigned to declared type "ShouldBeContravariant1[float]"   "ShouldBeContravariant1[int]" is incompatible with "ShouldBeContravariant1[float]"     Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float"       "float" is incompatible with "int" (reportGeneralTypeIssues) diff --git a/conformance/results/pytype/generics_syntax_infer_variance.toml b/conformance/results/pytype/generics_syntax_infer_variance.toml index bbeac025a..0351fc6ea 100644 --- a/conformance/results/pytype/generics_syntax_infer_variance.toml +++ b/conformance/results/pytype/generics_syntax_infer_variance.toml @@ -3,5 +3,5 @@ notes = """ Type parameter syntax not yet support. """ output = """ -SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 118) +SyntaxError: Type parameter lists are only supported in Python 3.12 and greater (, line 129) """ diff --git a/conformance/results/pytype/protocols_generic.toml b/conformance/results/pytype/protocols_generic.toml index cfc64f916..5ce4b02a5 100644 --- a/conformance/results/pytype/protocols_generic.toml +++ b/conformance/results/pytype/protocols_generic.toml @@ -11,13 +11,13 @@ File "protocols_generic.py", line 40, in : Type annotation for p2 does n Annotation: Proto1[int, str] Assignment: Concrete1 - Method __iter__ of protocol Proto1[int, str] has the wrong signature in Concrete1: + Method method1 of protocol Proto1[int, str] has the wrong signature in Concrete1: >> Proto1[int, str] expects: - def __iter__(self) -> Iterator[T_co]: ... + def method1(self, x: S) -> S: ... >> Concrete1 defines: - def __iter__(self) -> Iterator[int]: ... + def method1(self, x: str) -> str: ... File "protocols_generic.py", line 44, in : Invalid type annotation 'Proto2' [invalid-annotation] Cannot inherit from Generic[...] multiple times File "protocols_generic.py", line 56, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] diff --git a/conformance/results/pytype/qualifiers_final_decorator.toml b/conformance/results/pytype/qualifiers_final_decorator.toml index 161b08dc3..9d2d633a9 100644 --- a/conformance/results/pytype/qualifiers_final_decorator.toml +++ b/conformance/results/pytype/qualifiers_final_decorator.toml @@ -13,10 +13,10 @@ 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 method3, 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 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 method3, defined in base class Base2 [final-error] File "qualifiers_final_decorator.py", line 76, in method4: bad return type [bad-return-type] Expected: str Actually returned: int diff --git a/conformance/results/results.html b/conformance/results/results.html index cbbef456a..b1059a58d 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -270,7 +270,7 @@

Python Type System Conformance Test Results

     directives_version_platformPassDoes not understand three-element form of sys.version checks.
Does not understand os.name checks.
-
pyright 1.1.344(1.30sec) +
pyright 1.1.344(1.37sec)
@@ -413,7 +413,7 @@

Python Type System Conformance Test Results

     directives_version_platformPass
-
pyre 0.9.19(1.99sec) +
pyre 0.9.19(2.33sec)
@@ -556,7 +556,7 @@

Python Type System Conformance Test Results

     directives_version_platformPartialDoes not support sys.platform checks.
Does not support os.name checks.
-
pytype 2023.12.18(27.93sec) +
pytype 2023.12.18(28.81sec)
diff --git a/conformance/tests/generics_paramspec_basic.py b/conformance/tests/generics_paramspec_basic.py index 19718a82b..b59efd933 100644 --- a/conformance/tests/generics_paramspec_basic.py +++ b/conformance/tests/generics_paramspec_basic.py @@ -32,9 +32,9 @@ def func3(x: list[P]) -> None: # Type error ... -def func3(x: Callable[[int, str], P]) -> None: # Type error +def func4(x: Callable[[int, str], P]) -> None: # Type error ... -def func4(*args: P, **kwargs: P) -> None: # Type error +def func5(*args: P, **kwargs: P) -> None: # Type error ... diff --git a/conformance/tests/generics_syntax_declarations.py b/conformance/tests/generics_syntax_declarations.py index a1500fbe6..eba72cf11 100644 --- a/conformance/tests/generics_syntax_declarations.py +++ b/conformance/tests/generics_syntax_declarations.py @@ -10,13 +10,17 @@ from typing import Generic, ParamSpec, Protocol, TypeVar, TypeVarTuple, assert_type -class ClassA[T, *Ts, **P]: +class ChildClass[T, *Ts, **P]: assert_type(T, TypeVar) assert_type(Ts, TypeVarTuple) assert_type(P, ParamSpec) -class ClassB[T](Generic[T]): # Runtime error +class ClassA[T](Generic[T]): # Runtime error + ... + + +class ClassB[S, T](Protocol): # OK ... diff --git a/conformance/tests/generics_syntax_infer_variance.py b/conformance/tests/generics_syntax_infer_variance.py index 1acc5234f..b0276c8f0 100644 --- a/conformance/tests/generics_syntax_infer_variance.py +++ b/conformance/tests/generics_syntax_infer_variance.py @@ -4,7 +4,7 @@ # Specification: https://peps.python.org/pep-0695/#auto-variance-for-typevar -from typing import Generic, Iterator, Sequence, TypeVar +from typing import Final, Generic, Iterator, Sequence, TypeVar from dataclasses import dataclass @@ -72,6 +72,17 @@ def x(self) -> T: vo5_2: ShouldBeCovariant5[int] = ShouldBeCovariant5[float](1.0) # Type error +class ShouldBeCovariant6(Generic[T]): + x: Final[T] + + def __init__(self, value: T): + self.x = value + + +vo6_1: ShouldBeCovariant6[float] = ShouldBeCovariant6[int](1) # OK +vo6_2: ShouldBeCovariant6[int] = ShouldBeCovariant6[float](1.0) # Type error + + class ShouldBeInvariant1(Generic[T]): def __init__(self, value: T) -> None: self._value = value diff --git a/docs/spec/generics.rst b/docs/spec/generics.rst index 4e502603e..00a22047f 100644 --- a/docs/spec/generics.rst +++ b/docs/spec/generics.rst @@ -765,7 +765,7 @@ evaluated in the same way. def a(q: int) -> str: ... - Y(a, 1) # Should resolve to Y[(q: int), int] + Y(a, 1) # Should resolve to Y[int, (q: int)] Y(a, 1).f # Should resolve to (q: int) -> str The semantics of ``Concatenate[X, Y, P]`` are that it represents the parameters From 0e5bc49008dfb11846a69536ba8dbc6701cf29f4 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 6 Jan 2024 19:00:25 -0700 Subject: [PATCH 4/9] Fixed bug in `generics_typevartuple_specialization` test. Added additional test cases in the `generics_variance` test. --- .../generics_typevartuple_specialization.toml | 9 +- .../results/mypy/generics_variance.toml | 7 + .../generics_typevartuple_specialization.toml | 3 - .../results/pyre/generics_variance.toml | 7 + .../generics_typevartuple_specialization.toml | 2 - .../results/pyright/generics_variance.toml | 24 +++ .../results/pyright/protocols_variance.toml | 2 +- .../generics_typevartuple_specialization.toml | 14 +- .../results/pytype/generics_variance.toml | 7 +- .../results/pytype/protocols_generic.toml | 6 +- conformance/results/results.html | 10 +- .../generics_typevartuple_specialization.py | 4 +- conformance/tests/generics_variance.py | 144 +++++++++++++++++- conformance/tests/protocols_variance.py | 1 - 14 files changed, 207 insertions(+), 33 deletions(-) diff --git a/conformance/results/mypy/generics_typevartuple_specialization.toml b/conformance/results/mypy/generics_typevartuple_specialization.toml index 51d73fb77..dd3125f8a 100644 --- a/conformance/results/mypy/generics_typevartuple_specialization.toml +++ b/conformance/results/mypy/generics_typevartuple_specialization.toml @@ -11,9 +11,6 @@ output = """ generics_typevartuple_specialization.py: error: More than one Unpack in a type is not allowed [misc] generics_typevartuple_specialization.py:85: error: Argument 1 to "takes_float_array_with_specific_shape" has incompatible type "Array2[float, *tuple[Any, ...]]"; expected "Array2[float, Height, Width]" [arg-type] generics_typevartuple_specialization.py:95: error: Expression is of type "tuple[Any, *tuple[Any, ...]]", not "tuple[Any, ...]" [assert-type] -generics_typevartuple_specialization.py:101: error: "Ts1" cannot be unpacked (must be tuple or TypeVarTuple) [valid-type] -generics_typevartuple_specialization.py:102: error: Unpack is only valid in a variadic position [valid-type] -generics_typevartuple_specialization.py:103: error: Unpack is only valid in a variadic position [valid-type] generics_typevartuple_specialization.py:108: error: Type application is only supported for generic classes [misc] generics_typevartuple_specialization.py:109: error: Type application is only supported for generic classes [misc] generics_typevartuple_specialization.py:109: error: Unpack is only valid in a variadic position [valid-type] @@ -21,9 +18,5 @@ generics_typevartuple_specialization.py:110: error: Type application is only sup generics_typevartuple_specialization.py:110: error: Unpack is only valid in a variadic position [valid-type] generics_typevartuple_specialization.py:127: error: Bad number of arguments for type alias, expected: at least 2, given: 1 [type-arg] generics_typevartuple_specialization.py:159: error: Expression is of type "tuple[str, *tuple[int, ...]]", not "tuple[str, *tuple[int, ...], int]" [assert-type] -generics_typevartuple_specialization.py:162: error: "Ts1" cannot be unpacked (must be tuple or TypeVarTuple) [valid-type] -generics_typevartuple_specialization.py:163: error: Unpack is only valid in a variadic position [valid-type] -generics_typevartuple_specialization.py:163: error: Type variable "generics_typevartuple_specialization.Ts2" is unbound [valid-type] -generics_typevartuple_specialization.py:163: note: (Hint: Use "Generic[Ts2]" or "Protocol[Ts2]" base class to bind "Ts2" inside a class) -generics_typevartuple_specialization.py:163: note: (Hint: Use "Ts2" in function signature to bind "Ts2" inside a function) +generics_typevartuple_specialization.py:163: error: TypeVarTuple "Ts2" is unbound [valid-type] """ diff --git a/conformance/results/mypy/generics_variance.toml b/conformance/results/mypy/generics_variance.toml index 97afb4e80..b9ea3ff47 100644 --- a/conformance/results/mypy/generics_variance.toml +++ b/conformance/results/mypy/generics_variance.toml @@ -1,7 +1,14 @@ conformant = "Partial" notes = """ Does not reject a function-scoped TypeVar that is marked as covariant or contravariant. +Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible. """ output = """ generics_variance.py:14: error: TypeVar cannot be both covariant and contravariant [misc] +generics_variance.py:78: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:82: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] +generics_variance.py:94: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] +generics_variance.py:106: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:126: error: Variance of TypeVar "T_co" incompatible with variance in parent type [type-var] +generics_variance.py:132: error: Variance of TypeVar "T_contra" incompatible with variance in parent type [type-var] """ diff --git a/conformance/results/pyre/generics_typevartuple_specialization.toml b/conformance/results/pyre/generics_typevartuple_specialization.toml index 5ed025486..f1aa2fedf 100644 --- a/conformance/results/pyre/generics_typevartuple_specialization.toml +++ b/conformance/results/pyre/generics_typevartuple_specialization.toml @@ -29,8 +29,6 @@ generics_typevartuple_specialization.py:92:13 Undefined or invalid type [11]: An generics_typevartuple_specialization.py:93:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[str], Type[int]]`. generics_typevartuple_specialization.py:95:25 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[object, typing.Any]`. generics_typevartuple_specialization.py:101:20 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[Type[int], *Tuple[typing.Any, ...]]`. -generics_typevartuple_specialization.py:101:20 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.TypeVar`. -generics_typevartuple_specialization.py:102:31 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.TypeVar`. generics_typevartuple_specialization.py:103:32 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. generics_typevartuple_specialization.py:103:39 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[float], typing.Any]`. generics_typevartuple_specialization.py:110:16 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. @@ -90,7 +88,6 @@ generics_typevartuple_specialization.py:159:25 Incompatible parameter type [6]: generics_typevartuple_specialization.py:159:25 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.Type[tuple[Variable[_T_co](covariant)]]`. generics_typevartuple_specialization.py:159:37 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `Tuple[Type[int], typing.Any]`. generics_typevartuple_specialization.py:162:13 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T_co](covariant)]` but got `typing.Tuple[TypeVar, *Tuple[typing.Any, ...]]`. -generics_typevartuple_specialization.py:162:13 Unable to concatenate tuple [60]: Expected to unpack an iterable, but got `typing.TypeVar`. generics_typevartuple_specialization.py:163:4 Invalid type [31]: Expression `$local_generics_typevartuple_specialization$TA11[(*$local_generics_typevartuple_specialization$Ts2)]` is not a valid type. generics_typevartuple_specialization.py:163:4 Undefined or invalid type [11]: Annotation `TA11` is not defined as a type. """ diff --git a/conformance/results/pyre/generics_variance.toml b/conformance/results/pyre/generics_variance.toml index ad32809b3..cc5377b60 100644 --- a/conformance/results/pyre/generics_variance.toml +++ b/conformance/results/pyre/generics_variance.toml @@ -2,6 +2,13 @@ conformant = "Partial" notes = """ Does not reject a TypeVar that is defined as both covariant and contravariant. Does not reject a function-scoped TypeVar that is marked as covariant or contravariant. +Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible. """ output = """ +generics_variance.py:78:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T]` because subclasses cannot use more permissive type variables than their superclasses. +generics_variance.py:82:0 Invalid type variance [46]: The type variable `Variable[T_contra](contravariant)` is incompatible with parent class type variable `Variable[T]` because subclasses cannot use more permissive type variables than their superclasses. +generics_variance.py:94:0 Invalid type variance [46]: The type variable `Variable[T_contra](contravariant)` is incompatible with parent class type variable `Variable[T_co](covariant)` because subclasses cannot use more permissive type variables than their superclasses. +generics_variance.py:106:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T_contra](contravariant)` because subclasses cannot use more permissive type variables than their superclasses. +generics_variance.py:126:0 Invalid type variance [46]: The type variable `Variable[T_co](covariant)` is incompatible with parent class type variable `Variable[T_contra](contravariant)` because subclasses cannot use more permissive type variables than their superclasses. +generics_variance.py:132:0 Invalid type variance [46]: The type variable `Variable[T_contra](contravariant)` is incompatible with parent class type variable `Variable[T_co](covariant)` because subclasses cannot use more permissive type variables than their superclasses. """ diff --git a/conformance/results/pyright/generics_typevartuple_specialization.toml b/conformance/results/pyright/generics_typevartuple_specialization.toml index e429b7001..b9c53e2d8 100644 --- a/conformance/results/pyright/generics_typevartuple_specialization.toml +++ b/conformance/results/pyright/generics_typevartuple_specialization.toml @@ -7,12 +7,10 @@ Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar. """ output = """ generics_typevartuple_specialization.py:95:17 - error: "assert_type" mismatch: expected "tuple[Any, ...]" but received "tuple[Unknown, Unknown]" (reportGeneralTypeIssues) -generics_typevartuple_specialization.py:102:40 - error: Too many type arguments provided for "IntTupleVar[Ts1@IntTupleVar]"; expected 1 but received 2 generics_typevartuple_specialization.py:109:18 - error: Type variable "Ts" has no meaning in this context (reportGeneralTypeIssues) generics_typevartuple_specialization.py:121:27 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple generics_typevartuple_specialization.py:122:27 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple generics_typevartuple_specialization.py:157:17 - error: "assert_type" mismatch: expected "tuple[*tuple[int, ...], int]" but received "tuple[*tuple[int, ...]]" (reportGeneralTypeIssues) generics_typevartuple_specialization.py:159:17 - error: "assert_type" mismatch: expected "tuple[str, *tuple[int, ...], int]" but received "tuple[str, *tuple[int, ...]]" (reportGeneralTypeIssues) generics_typevartuple_specialization.py:163:11 - error: Type variable "Ts2" has no meaning in this context (reportGeneralTypeIssues) -generics_typevartuple_specialization.py:163:10 - error: Too few type arguments provided for "TA11[T@TA11, Ts1@TA11]"; expected 2 but received 1 """ diff --git a/conformance/results/pyright/generics_variance.toml b/conformance/results/pyright/generics_variance.toml index 2539080d0..23f062cfa 100644 --- a/conformance/results/pyright/generics_variance.toml +++ b/conformance/results/pyright/generics_variance.toml @@ -4,4 +4,28 @@ Does not reject a function-scoped TypeVar that is marked as covariant or contrav """ output = """ generics_variance.py:14:50 - error: TypeVar cannot be both covariant and contravariant +generics_variance.py:78:18 - error: Type "T_co@Class1" cannot be assigned to type variable "T@Inv" +  Variance of type argument "T_co@Class1" is incompatible with base class "Inv" (reportGeneralTypeIssues) +generics_variance.py:82:18 - error: Type "T_contra@Class2" cannot be assigned to type variable "T@Inv" +  Variance of type argument "T_contra@Class2" is incompatible with base class "Inv" (reportGeneralTypeIssues) +generics_variance.py:94:20 - error: Type "T_contra@Co_Child3" cannot be assigned to type variable "T_co@Co" +  Variance of type argument "T_contra@Co_Child3" is incompatible with base class "Co" (reportGeneralTypeIssues) +generics_variance.py:106:28 - error: Type "T_co@Contra_Child3" cannot be assigned to type variable "T_contra@Contra" +  Variance of type argument "T_co@Contra_Child3" is incompatible with base class "Contra" (reportGeneralTypeIssues) +generics_variance.py:114:28 - error: Type "Co[T_co@Contra_Child5]" cannot be assigned to type variable "T_contra@Contra" +  Variance of type argument "Co[T_co@Contra_Child5]" is incompatible with base class "Contra" (reportGeneralTypeIssues) +generics_variance.py:127:20 - error: Type "T_co@CoContra_Child2" cannot be assigned to type variable "T_contra@CoContra" +  Variance of type argument "T_co@CoContra_Child2" is incompatible with base class "CoContra" (reportGeneralTypeIssues) +generics_variance.py:133:14 - error: Type "T_contra@CoContra_Child3" cannot be assigned to type variable "T_co@CoContra" +  Variance of type argument "T_contra@CoContra_Child3" is incompatible with base class "CoContra" (reportGeneralTypeIssues) +generics_variance.py:143:24 - error: Type "Co[T_co@CoContra_Child5]" cannot be assigned to type variable "T_contra@CoContra" +  Variance of type argument "Co[T_co@CoContra_Child5]" is incompatible with base class "CoContra" (reportGeneralTypeIssues) +generics_variance.py:164:33 - error: Type "Co[Contra[T_contra@CoToContraToContra]]" cannot be assigned to type variable "T_contra@Contra" +  Variance of type argument "Co[Contra[T_contra@CoToContraToContra]]" is incompatible with base class "Contra" (reportGeneralTypeIssues) +generics_variance.py:168:37 - error: Type "Contra[Contra[T_co@ContraToContraToContra]]" cannot be assigned to type variable "T_contra@Contra" +  Variance of type argument "Contra[Contra[T_co@ContraToContraToContra]]" is incompatible with base class "Contra" (reportGeneralTypeIssues) +generics_variance.py:192:43 - error: Could not specialize type "Contra_TA[T_contra@Contra_TA]" +  Variance of type argument "Co_TA[Contra_TA[T_contra@CoToContraToContra_WithTA]]" is incompatible with "T_contra@Contra_TA" +generics_variance.py:197:15 - error: Could not specialize type "Contra_TA[T_contra@Contra_TA]" +  Variance of type argument "Contra_TA[Contra_TA[T_co@ContraToContraToContra_WithTA]]" is incompatible with "T_contra@Contra_TA" """ diff --git a/conformance/results/pyright/protocols_variance.toml b/conformance/results/pyright/protocols_variance.toml index 383e67a2c..9ec032c27 100644 --- a/conformance/results/pyright/protocols_variance.toml +++ b/conformance/results/pyright/protocols_variance.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not exempt "self" and "cls" parameters from variance checks. +Calculates incorrect variance when `self` or `cls` have explicit annotation. """ output = """ protocols_variance.py:21:7 - warning: Type variable "T1" used in generic protocol "AnotherBox" should be covariant (reportInvalidTypeVarUse) diff --git a/conformance/results/pytype/generics_typevartuple_specialization.toml b/conformance/results/pytype/generics_typevartuple_specialization.toml index 4f831a3c6..490ac959d 100644 --- a/conformance/results/pytype/generics_typevartuple_specialization.toml +++ b/conformance/results/pytype/generics_typevartuple_specialization.toml @@ -68,9 +68,15 @@ File "generics_typevartuple_specialization.py", line 94, in func6: Tuple[Any] [a File "generics_typevartuple_specialization.py", line 95, in func6: Tuple[Any] [assert-type] Expected: tuple Actual: Tuple[Any] -File "generics_typevartuple_specialization.py", line 101, in : Invalid type annotation '' [invalid-annotation] +File "generics_typevartuple_specialization.py", line 98, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_specialization.py", line 99, in : Function TypeVarTuple.__init__ expects 1 arg(s), got 2 [wrong-arg-count] + Expected: (self) + Actually passed: (self, _) +File "generics_typevartuple_specialization.py", line 101, in : Invalid type annotation '' [invalid-annotation] Not a type -File "generics_typevartuple_specialization.py", line 102, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] +File "generics_typevartuple_specialization.py", line 102, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] Tuple[Any] expected 0 parameters, got 1 File "generics_typevartuple_specialization.py", line 103, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] Tuple[Any] expected 0 parameters, got 1 @@ -165,8 +171,8 @@ File "generics_typevartuple_specialization.py", line 158, in func11: Invalid typ Not a type File "generics_typevartuple_specialization.py", line 159, in func11: Invalid type annotation '' [invalid-annotation] Not a type -File "generics_typevartuple_specialization.py", line 162, in : Invalid type annotation '' [invalid-annotation] +File "generics_typevartuple_specialization.py", line 162, in : Invalid type annotation '' [invalid-annotation] Not a type -File "generics_typevartuple_specialization.py", line 163, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] +File "generics_typevartuple_specialization.py", line 163, in : Invalid type annotation 'Tuple[Any][]' [invalid-annotation] Tuple[Any] expected 0 parameters, got 1 """ diff --git a/conformance/results/pytype/generics_variance.toml b/conformance/results/pytype/generics_variance.toml index 6b40b44b2..d4aecb4a9 100644 --- a/conformance/results/pytype/generics_variance.toml +++ b/conformance/results/pytype/generics_variance.toml @@ -5,10 +5,11 @@ Does not support covariant or contravariant TypeVars. output = """ File "generics_variance.py", line 14, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] File "generics_variance.py", line 14, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] -File "generics_variance.py", line 17, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] -File "generics_variance.py", line 25, in __iter__: bad return type [bad-return-type] +File "generics_variance.py", line 18, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] +File "generics_variance.py", line 19, in : argument "contravariant" to TypeVar not supported yet [not-supported-yet] +File "generics_variance.py", line 27, in __iter__: bad return type [bad-return-type] Expected: Iterator Actually returned: None Attributes of protocol Iterator[T_co] are not implemented on None: __next__ -File "generics_variance.py", line 50, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] +File "generics_variance.py", line 52, in : argument "covariant" to TypeVar not supported yet [not-supported-yet] """ diff --git a/conformance/results/pytype/protocols_generic.toml b/conformance/results/pytype/protocols_generic.toml index 5ce4b02a5..cfc64f916 100644 --- a/conformance/results/pytype/protocols_generic.toml +++ b/conformance/results/pytype/protocols_generic.toml @@ -11,13 +11,13 @@ File "protocols_generic.py", line 40, in : Type annotation for p2 does n Annotation: Proto1[int, str] Assignment: Concrete1 - Method method1 of protocol Proto1[int, str] has the wrong signature in Concrete1: + Method __iter__ of protocol Proto1[int, str] has the wrong signature in Concrete1: >> Proto1[int, str] expects: - def method1(self, x: S) -> S: ... + def __iter__(self) -> Iterator[T_co]: ... >> Concrete1 defines: - def method1(self, x: str) -> str: ... + def __iter__(self) -> Iterator[int]: ... File "protocols_generic.py", line 44, in : Invalid type annotation 'Proto2' [invalid-annotation] Cannot inherit from Generic[...] multiple times File "protocols_generic.py", line 56, in func1: Type annotation for v2 does not match type of assignment [annotation-type-mismatch] diff --git a/conformance/results/results.html b/conformance/results/results.html index b1059a58d..f2ced7a70 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.27sec) +
mypy 1.8.0(1.28sec)
@@ -270,7 +270,7 @@

Python Type System Conformance Test Results

     directives_version_platformPassDoes not understand three-element form of sys.version checks.
Does not understand os.name checks.
-
pyright 1.1.344(1.37sec) +
pyright 1.1.344(2.19sec)
@@ -357,7 +357,7 @@

Python Type System Conformance Test Results

- + @@ -413,7 +413,7 @@

Python Type System Conformance Test Results

     protocols_runtime_checkablePartialDoes not reject issubclass call for data protocol.
Does not report unsafe overlap for runtime_checkable protocol.
     protocols_selfPass
     protocols_subtypingPass
     protocols_variancePartialDoes not exempt "self" and "cls" parameters from variance checks.
     protocols_variancePartialCalculates incorrect variance when `self` or `cls` have explicit annotation.
Callables
     directives_version_platformPass
-
pyre 0.9.19(2.33sec) +
pyre 0.9.19(2.64sec)
@@ -556,7 +556,7 @@

Python Type System Conformance Test Results

     directives_version_platformPartialDoes not support sys.platform checks.
Does not support os.name checks.
-
pytype 2023.12.18(28.81sec) +
pytype 2023.12.18(30.11sec)
diff --git a/conformance/tests/generics_typevartuple_specialization.py b/conformance/tests/generics_typevartuple_specialization.py index f98e21ba6..9f2ff9f33 100644 --- a/conformance/tests/generics_typevartuple_specialization.py +++ b/conformance/tests/generics_typevartuple_specialization.py @@ -95,8 +95,8 @@ def func6(a: VariadicTuple[str, int], b: VariadicTuple[float], c: VariadicTuple) assert_type(c, tuple[Any, ...]) -Ts1 = TypeVar("Ts1") -Ts2 = TypeVar("Ts2") +Ts1 = TypeVarTuple("Ts1") +Ts2 = TypeVarTuple("Ts2") IntTupleVar = tuple[int, *Ts1] # OK IntFloatTupleVar = IntTupleVar[float, *Ts2] # OK diff --git a/conformance/tests/generics_variance.py b/conformance/tests/generics_variance.py index eba8004d1..2841937de 100644 --- a/conformance/tests/generics_variance.py +++ b/conformance/tests/generics_variance.py @@ -4,7 +4,7 @@ # Specification: https://typing.readthedocs.io/en/latest/spec/generics.html#variance -from typing import TypeVar, Generic +from typing import Sequence, TypeVar, Generic from collections.abc import Iterable, Iterator # > To facilitate the declaration of container types where covariant or @@ -14,7 +14,9 @@ X1 = TypeVar("X1", covariant=True, contravariant=True) # Type error +T = TypeVar("T") T_co = TypeVar("T_co", covariant=True) +T_contra = TypeVar("T_contra", contravariant=True) class ImmutableList(Generic[T_co]): @@ -55,3 +57,143 @@ def dump_employee(e: E) -> E: # > without covariant or contravariant keyword arguments. def bad_func(x: list[B_co]) -> B_co: # Type checker error ... + + +class Co(Generic[T_co]): + ... + + +class Contra(Generic[T_contra]): + ... + + +class Inv(Generic[T]): + ... + + +class CoContra(Generic[T_co, T_contra]): + ... + + +class Class1(Inv[T_co]): # Type error: Inv requires invariant TypeVar + pass + + +class Class2(Inv[T_contra]): # Type error: Inv requires invariant TypeVar + pass + + +class Co_Child1(Co[T_co]): # OK + ... + + +class Co_Child2(Co[T]): # OK + ... + + +class Co_Child3(Co[T_contra]): # Type error: Co requires covariant + ... + + +class Contra_Child1(Contra[T_contra]): # OK + ... + + +class Contra_Child2(Contra[T]): # OK + ... + + +class Contra_Child3(Contra[T_co]): # Type error: Contra requires contravariant + ... + + +class Contra_Child4(Contra[Co[T_contra]]): # OK + ... + + +class Contra_Child5(Contra[Co[T_co]]): # Type error: Contra requires contravariant + ... + + +class Contra_Child6(Contra[Co[T]]): # OK + ... + + +class CoContra_Child1(CoContra[T_co, T_contra]): # OK + ... + + +class CoContra_Child2( + CoContra[T_co, T_co] +): # Type error: Second type arg must be contravariant + ... + + +class CoContra_Child3( + CoContra[T_contra, T_contra] +): # Type error: First type arg must be covariant + ... + + +class CoContra_Child4(CoContra[T, T]): # OK + ... + + +class CoContra_Child5( + CoContra[Co[T_co], Co[T_co]] +): # Type error: Second type arg must be contravariant + ... + + +class CoToContra(Contra[Co[T_contra]]): # OK + ... + + +class ContraToContra(Contra[Contra[T_co]]): # OK + ... + + +class CoToCo(Co[Co[T_co]]): # OK + ... + + +class ContraToCo(Co[Contra[T_contra]]): # OK + ... + + +class CoToContraToContra(Contra[Co[Contra[T_contra]]]): # Type error + ... + + +class ContraToContraToContra(Contra[Contra[Contra[T_co]]]): # Type error + ... + + +Co_TA = Co[T_co] +Contra_TA = Contra[T_contra] + + +class CoToContra_WithTA(Contra_TA[Co_TA[T_contra]]): # OK + ... + + +class ContraToContra_WithTA(Contra_TA[Contra_TA[T_co]]): # OK + ... + + +class CoToCo_WithTA(Co_TA[Co_TA[T_co]]): # OK + ... + + +class ContraToCo_WithTA(Co_TA[Contra_TA[T_contra]]): # OK + ... + + +class CoToContraToContra_WithTA(Contra_TA[Co_TA[Contra_TA[T_contra]]]): # Type error + ... + + +class ContraToContraToContra_WithTA( + Contra_TA[Contra_TA[Contra_TA[T_co]]] +): # Type error + ... diff --git a/conformance/tests/protocols_variance.py b/conformance/tests/protocols_variance.py index 101771512..27128fc9d 100644 --- a/conformance/tests/protocols_variance.py +++ b/conformance/tests/protocols_variance.py @@ -108,7 +108,6 @@ def __init__(self, x: T1) -> None: class Protocol13(Protocol[T1_contra]): # OK - # "self" and "cls" parameters are exempt from variance calculations. def m1(self: "Protocol13[T1_contra]", x: T1_contra) -> None: ... From a4601f183c45f8148fa2a98a59ed3cb96d3bb11f Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 6 Jan 2024 19:11:20 -0700 Subject: [PATCH 5/9] Regenerated results page. --- conformance/results/results.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conformance/results/results.html b/conformance/results/results.html index f2ced7a70..3aa969200 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.28sec) +
mypy 1.8.0(1.25sec)
@@ -171,7 +171,7 @@

Python Type System Conformance Test Results

- +
     generics_typevartuple_overloadsPass
     generics_typevartuple_specializationPartialIncorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.
Incorrectly specializes generic alias that includes a TypeVar and TypeVarTuple if no type arguments are provided.
Rejects use of unpacked TypeVarTuple in generic type alias definition.
Rejects specialization of generic type alias defined as a tuple containing a TypeVar.
"More than one Unpack" error message has no line number.
Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.
     generics_typevartuple_unpackPartialDoes not reject multiple unpack operators in a tuple.
     generics_variancePartialDoes not reject a function-scoped TypeVar that is marked as covariant or contravariant.
     generics_variancePartialDoes not reject a function-scoped TypeVar that is marked as covariant or contravariant.
Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.
     generics_variance_inferenceUnsupportedType parameter syntax not yet support.
@@ -270,7 +270,7 @@

Python Type System Conformance Test Results

     directives_version_platformPassDoes not understand three-element form of sys.version checks.
Does not understand os.name checks.
-
pyright 1.1.344(2.19sec) +
pyright 1.1.344(1.40sec)
@@ -413,7 +413,7 @@

Python Type System Conformance Test Results

     directives_version_platformPass
-
pyre 0.9.19(2.64sec) +
pyre 0.9.19(2.39sec)
@@ -457,7 +457,7 @@

Python Type System Conformance Test Results

- +
     generics_typevartuple_overloadsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_specializationUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_unpackUnsupportedDoes not support TypeVarTuple.
     generics_variancePartialDoes not reject a TypeVar that is defined as both covariant and contravariant.
Does not reject a function-scoped TypeVar that is marked as covariant or contravariant.
     generics_variancePartialDoes not reject a TypeVar that is defined as both covariant and contravariant.
Does not reject a function-scoped TypeVar that is marked as covariant or contravariant.
Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.
     generics_variance_inferenceUnsupportedType parameter syntax not yet support.
@@ -556,7 +556,7 @@

Python Type System Conformance Test Results

     directives_version_platformPartialDoes not support sys.platform checks.
Does not support os.name checks.
-
pytype 2023.12.18(30.11sec) +
pytype 2023.12.18(28.24sec)
From c08d4e6e0f521735bc9f812ea3de7608acc9b9c6 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 6 Jan 2024 21:49:58 -0700 Subject: [PATCH 6/9] Enhanced protocols test to cover tuples of types passed as second argument to `isinstance` and `issubclass`. --- conformance/tests/protocols_runtime_checkable.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/conformance/tests/protocols_runtime_checkable.py b/conformance/tests/protocols_runtime_checkable.py index ced3fa0f9..61b9fb8e2 100644 --- a/conformance/tests/protocols_runtime_checkable.py +++ b/conformance/tests/protocols_runtime_checkable.py @@ -79,11 +79,14 @@ class Concrete3B: def func3(): + if isinstance(Concrete3A(), Proto2): # OK + pass + if isinstance(Concrete3A(), Proto3): # Type error: unsafe overlap pass - if isinstance(Concrete3B(), Proto3): # Type error: unsafe overlap + if isinstance(Concrete3B(), (Proto3, Proto2)): # Type error: unsafe overlap pass - if issubclass(Concrete3A, Proto3): # Type error: unsafe overlap + if issubclass(Concrete3A, (Proto3, Proto2)): # Type error: unsafe overlap pass From 2efa6f9f6f8bfdb1027ecc1f811a942740784b1f Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Mon, 8 Jan 2024 12:09:34 -0800 Subject: [PATCH 7/9] Fixed a bug in the dataclasses_usage test. Fixed a couple of bugs in the generics_variance_inference test. Fixed a bug in the protocols_definition test. Added a new test condition in the protocols_runtime_checkable test. Updated conformance results for pyright 1.1.345. --- .../results/mypy/dataclasses_usage.toml | 2 +- .../mypy/generics_variance_inference.toml | 23 +++-------- .../results/mypy/protocols_definition.toml | 19 +++++----- .../mypy/protocols_runtime_checkable.toml | 2 + conformance/results/mypy/version.toml | 2 +- .../results/pyre/dataclasses_usage.toml | 2 +- .../pyre/generics_paramspec_semantics.toml | 2 +- .../results/pyre/protocols_definition.toml | 6 +-- conformance/results/pyre/version.toml | 2 +- .../pyright/aliases_type_statement.toml | 2 +- .../pyright/annotations_generators.toml | 12 +++--- .../results/pyright/callables_annotation.toml | 2 +- .../results/pyright/classes_classvar.toml | 4 +- .../results/pyright/dataclasses_usage.toml | 2 +- .../pyright/generics_paramspec_basic.toml | 6 +-- .../generics_paramspec_components.toml | 2 +- .../pyright/generics_paramspec_semantics.toml | 6 +-- .../results/pyright/generics_self_usage.toml | 2 +- .../pyright/generics_syntax_scoping.toml | 20 ++++------ .../pyright/generics_typevartuple_basic.toml | 5 ++- .../pyright/generics_typevartuple_concat.toml | 9 +---- .../generics_typevartuple_specialization.toml | 17 +++++++-- .../pyright/generics_variance_inference.toml | 28 ++++++-------- .../pyright/protocols_class_objects.toml | 6 +++ .../results/pyright/protocols_definition.toml | 19 ++++++---- .../results/pyright/protocols_explicit.toml | 10 ++--- .../results/pyright/protocols_merging.toml | 2 +- .../pyright/protocols_runtime_checkable.toml | 14 ++++++- .../results/pyright/protocols_variance.toml | 4 +- .../results/pyright/qualifiers_annotated.toml | 7 ++-- .../pyright/qualifiers_final_annotation.toml | 21 +++++----- .../pyright/qualifiers_final_decorator.toml | 15 ++++---- conformance/results/pyright/version.toml | 4 +- .../results/pytype/protocols_definition.toml | 4 +- conformance/results/pytype/version.toml | 2 +- conformance/results/results.html | 38 +++++++++---------- conformance/tests/dataclasses_usage.py | 4 +- .../tests/generics_variance_inference.py | 20 +++++----- conformance/tests/protocols_definition.py | 10 ++--- .../tests/protocols_runtime_checkable.py | 9 ++++- 40 files changed, 185 insertions(+), 181 deletions(-) diff --git a/conformance/results/mypy/dataclasses_usage.toml b/conformance/results/mypy/dataclasses_usage.toml index 7e66442d9..da8d922a8 100644 --- a/conformance/results/mypy/dataclasses_usage.toml +++ b/conformance/results/mypy/dataclasses_usage.toml @@ -12,5 +12,5 @@ dataclasses_usage.py:89: error: Incompatible types in assignment (expression has dataclasses_usage.py:127: error: Too many arguments for "DC7" [call-arg] dataclasses_usage.py:130: error: Missing positional argument "y" in call to "DC8" [call-arg] dataclasses_usage.py:179: error: Too many arguments for "DC13" [call-arg] -dataclasses_usage.py:207: error: Name "v1" already defined on line 25 [no-redef] +dataclasses_usage.py:205: error: Name "v1" already defined on line 25 [no-redef] """ diff --git a/conformance/results/mypy/generics_variance_inference.toml b/conformance/results/mypy/generics_variance_inference.toml index ff032080a..1d86d4217 100644 --- a/conformance/results/mypy/generics_variance_inference.toml +++ b/conformance/results/mypy/generics_variance_inference.toml @@ -15,8 +15,6 @@ generics_variance_inference.py:28: error: "ClassA" expects no type arguments, bu generics_variance_inference.py:29: error: "ClassA" expects no type arguments, but 3 given [type-arg] generics_variance_inference.py:32: error: PEP 695 generics are not yet supported [valid-type] generics_variance_inference.py:33: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var] -generics_variance_inference.py:36: error: Name "Iterator" is not defined [name-defined] -generics_variance_inference.py:36: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Iterator") generics_variance_inference.py:40: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] generics_variance_inference.py:40: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] generics_variance_inference.py:41: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] @@ -81,22 +79,13 @@ generics_variance_inference.py:149: error: "ShouldBeContravariant1" expects no t generics_variance_inference.py:149: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] generics_variance_inference.py:150: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] generics_variance_inference.py:150: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:165: error: Name "ShouldBeInvariant1" already defined on line 83 [no-redef] generics_variance_inference.py:165: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:169: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:169: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:170: error: "ShouldBeInvariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:170: error: The type "type[ShouldBeInvariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:177: error: Name "ShouldBeCovariant1" already defined on line 32 [no-redef] +generics_variance_inference.py:169: error: Incompatible types in assignment (expression has type "ShouldBeInvariant6[float]", variable has type "ShouldBeInvariant6[int]") [assignment] +generics_variance_inference.py:170: error: Incompatible types in assignment (expression has type "ShouldBeInvariant6[int]", variable has type "ShouldBeInvariant6[float]") [assignment] generics_variance_inference.py:177: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:181: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:181: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:182: error: "ShouldBeCovariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:182: error: The type "type[ShouldBeCovariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:189: error: Name "ShouldBeContravariant1" already defined on line 141 [no-redef] +generics_variance_inference.py:181: error: Incompatible types in assignment (expression has type "ShouldBeCovariant6[float]", variable has type "ShouldBeCovariant6[int]") [assignment] +generics_variance_inference.py:182: error: Incompatible types in assignment (expression has type "ShouldBeCovariant6[int]", variable has type "ShouldBeCovariant6[float]") [assignment] generics_variance_inference.py:189: error: PEP 695 generics are not yet supported [valid-type] -generics_variance_inference.py:193: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:193: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] -generics_variance_inference.py:194: error: "ShouldBeContravariant1" expects no type arguments, but 1 given [type-arg] -generics_variance_inference.py:194: error: The type "type[ShouldBeContravariant1]" is not generic and not indexable [misc] +generics_variance_inference.py:193: error: Incompatible types in assignment (expression has type "ShouldBeContravariant2[float]", variable has type "ShouldBeContravariant2[int]") [assignment] +generics_variance_inference.py:194: error: Incompatible types in assignment (expression has type "ShouldBeContravariant2[int]", variable has type "ShouldBeContravariant2[float]") [assignment] """ diff --git a/conformance/results/mypy/protocols_definition.toml b/conformance/results/mypy/protocols_definition.toml index 96227ab9d..36816554e 100644 --- a/conformance/results/mypy/protocols_definition.toml +++ b/conformance/results/mypy/protocols_definition.toml @@ -1,6 +1,5 @@ conformant = "Partial" notes = """ -Rejects implicit class variable when matching protocol with explicit ClassVar. Does not detect protocol mismatch if concrete method is missing annotations. Does not detect protocol mismatch if concrete method's parameters are position-only. """ @@ -8,16 +7,16 @@ output = """ protocols_definition.py:30: error: List item 0 has incompatible type "int"; expected "SupportsClose" [list-item] 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:114: error: Incompatible types in assignment (expression has type "Concrete2_Bad1", variable has type "Template2") [assignment] +protocols_definition.py:115: error: Incompatible types in assignment (expression has type "Concrete2_Bad2", variable has type "Template2") [assignment] +protocols_definition.py:115: note: Following member(s) of "Concrete2_Bad2" have conflicts: +protocols_definition.py:115: note: val1: expected "Sequence[int]", got "Sequence[float]" +protocols_definition.py:115: note: Protocol member Template2.val1 expected class variable, got instance variable +protocols_definition.py:116: error: Incompatible types in assignment (expression has type "Concrete2_Bad3", variable has type "Template2") [assignment] +protocols_definition.py:116: note: Following member(s) of "Concrete2_Bad3" have conflicts: +protocols_definition.py:116: note: val1: expected "Sequence[int]", got "list[int]" 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: error: Incompatible types in assignment (expression has type "Concrete2_Bad4", variable has type "Template2") [assignment] 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] diff --git a/conformance/results/mypy/protocols_runtime_checkable.toml b/conformance/results/mypy/protocols_runtime_checkable.toml index b6a042ef1..dfcfd7c4b 100644 --- a/conformance/results/mypy/protocols_runtime_checkable.toml +++ b/conformance/results/mypy/protocols_runtime_checkable.toml @@ -6,4 +6,6 @@ output = """ protocols_runtime_checkable.py:23: error: Only @runtime_checkable protocols can be used with instance and class checks [misc] protocols_runtime_checkable.py:55: error: Only protocols that don't have non-method members can be used with issubclass() [misc] protocols_runtime_checkable.py:55: note: Protocol "DataProtocol" has non-method member(s): name +protocols_runtime_checkable.py:61: error: Only protocols that don't have non-method members can be used with issubclass() [misc] +protocols_runtime_checkable.py:61: note: Protocol "DataProtocol" has non-method member(s): name """ diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index 736b81322..6829f8463 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.2672231197357178 +test_duration = 1.3487539291381836 diff --git a/conformance/results/pyre/dataclasses_usage.toml b/conformance/results/pyre/dataclasses_usage.toml index 1f111055b..810fa6725 100644 --- a/conformance/results/pyre/dataclasses_usage.toml +++ b/conformance/results/pyre/dataclasses_usage.toml @@ -16,5 +16,5 @@ dataclasses_usage.py:130:0 Missing argument [20]: Call `DC8.__init__` expects ar dataclasses_usage.py:172:0 Uninitialized attribute [13]: Attribute `x` is declared in class `DC13` to have type `int` but is never initialized. dataclasses_usage.py:172:0 Uninitialized attribute [13]: Attribute `x_squared` is declared in class `DC13` to have type `int` but is never initialized. dataclasses_usage.py:179:0 Too many arguments [19]: Call `object.__init__` expects 0 positional arguments, 1 was provided. -dataclasses_usage.py:207:0 Incompatible variable type [9]: v1 is declared to have type `DataclassProto` but is used as type `DC15`. +dataclasses_usage.py:205:0 Incompatible variable type [9]: v1 is declared to have type `DataclassProto` but is used as type `DC15`. """ diff --git a/conformance/results/pyre/generics_paramspec_semantics.toml b/conformance/results/pyre/generics_paramspec_semantics.toml index 21f95175c..b058c63ed 100644 --- a/conformance/results/pyre/generics_paramspec_semantics.toml +++ b/conformance/results/pyre/generics_paramspec_semantics.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Constraint solver doesn't find common type for two signatures captured by a single ParamSpec. +Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed). Reports error for legitimate Callable type annotation that uses Concatenate. Does not evaluate the correct type for call of Callable defined with Concatenate. """ diff --git a/conformance/results/pyre/protocols_definition.toml b/conformance/results/pyre/protocols_definition.toml index 3f95938f1..88a96e227 100644 --- a/conformance/results/pyre/protocols_definition.toml +++ b/conformance/results/pyre/protocols_definition.toml @@ -1,6 +1,6 @@ conformant = "Partial" notes = """ -Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar. +Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar or vice versa. Does not reject read-only property in concrete class when attribute in protocol is mutable. Does not reject covariant attribute type when protocol attribute is mutable. Does not reject read-only property in concrete class when protocol has settable property. @@ -10,8 +10,8 @@ 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: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:114:0 Incompatible variable type [9]: v2_bad1 is declared to have type `Template2` but is used as type `Concrete2_Bad1`. +protocols_definition.py:115: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`. diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml index c0893652a..4c4878364 100644 --- a/conformance/results/pyre/version.toml +++ b/conformance/results/pyre/version.toml @@ -1,2 +1,2 @@ version = "pyre 0.9.19" -test_duration = 1.989300012588501 +test_duration = 2.220608949661255 diff --git a/conformance/results/pyright/aliases_type_statement.toml b/conformance/results/pyright/aliases_type_statement.toml index 0c987a446..d4c64611c 100644 --- a/conformance/results/pyright/aliases_type_statement.toml +++ b/conformance/results/pyright/aliases_type_statement.toml @@ -35,6 +35,7 @@ aliases_type_statement.py:48:23 - error: Binary operator not allowed in type ann aliases_type_statement.py:49:23 - error: Expected expression aliases_type_statement.py:49:23 - error: Tuple expression not allowed in type annotation   Use Tuple[T1, ..., Tn] to indicate a tuple type or Union[T1, T2] to indicate a union type (reportGeneralTypeIssues) +aliases_type_statement.py:52:10 - error: Type alias declaration "BadTypeAlias14" is obscured by a declaration of the same name (reportGeneralTypeIssues) aliases_type_statement.py:58:10 - error: A type statement can be used only within a module or class scope aliases_type_statement.py:64:23 - error: Type parameter "V" is not included in the type parameter list for "TA1" (reportGeneralTypeIssues) aliases_type_statement.py:69:17 - error: Type parameter "T1" is not included in the type parameter list for "TA2" (reportGeneralTypeIssues) @@ -47,5 +48,4 @@ aliases_type_statement.py:81:7 - error: Could not specialize type "RecursiveType aliases_type_statement.py:84:28 - error: Type alias "RecursiveTypeAlias3" cannot use itself in its definition (reportGeneralTypeIssues) aliases_type_statement.py:86:31 - error: Type alias "RecursiveTypeAlias4" cannot use itself in its definition (reportGeneralTypeIssues) aliases_type_statement.py:90:28 - error: Type alias "RecursiveTypeAlias6" cannot use itself in its definition (reportGeneralTypeIssues) -aliases_type_statement.py:52:10 - error: Type alias declaration "BadTypeAlias14" is obscured by a declaration of the same name (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/annotations_generators.toml b/conformance/results/pyright/annotations_generators.toml index 9104ee128..a164fa047 100644 --- a/conformance/results/pyright/annotations_generators.toml +++ b/conformance/results/pyright/annotations_generators.toml @@ -1,23 +1,23 @@ conformant = "Pass" output = """ +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: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: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: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: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: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: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: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: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: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: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: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: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" diff --git a/conformance/results/pyright/callables_annotation.toml b/conformance/results/pyright/callables_annotation.toml index eac02284e..625587332 100644 --- a/conformance/results/pyright/callables_annotation.toml +++ b/conformance/results/pyright/callables_annotation.toml @@ -6,8 +6,8 @@ callables_annotation.py:14:11 - error: Argument of type "Literal[2]" cannot be a callables_annotation.py:15:15 - error: Expected 2 positional arguments (reportGeneralTypeIssues) callables_annotation.py:16:10 - error: Expected 2 more positional arguments (reportGeneralTypeIssues) callables_annotation.py:22:8 - error: Expected 0 positional arguments (reportGeneralTypeIssues) -callables_annotation.py:39:14 - error: Expected parameter type list or "..." callables_annotation.py:39:5 - error: Expected return type as second type argument for "Callable" (reportGeneralTypeIssues) +callables_annotation.py:39:14 - error: Expected parameter type list or "..." callables_annotation.py:40:14 - error: Expected parameter type list or "..." callables_annotation.py:41:18 - error: List expression not allowed for this type argument callables_annotation.py:42:14 - error: Expected parameter type list or "..." diff --git a/conformance/results/pyright/classes_classvar.toml b/conformance/results/pyright/classes_classvar.toml index 471d0a27d..b22f8b0de 100644 --- a/conformance/results/pyright/classes_classvar.toml +++ b/conformance/results/pyright/classes_classvar.toml @@ -20,5 +20,7 @@ classes_classvar.py:100:14 - error: Cannot assign member "stats" for type "Stars     Member "__set__" is unknown (reportGeneralTypeIssues) classes_classvar.py:129:13 - error: Expression of type "ProtoAImpl" cannot be assigned to declared type "ProtoA"   "ProtoAImpl" is incompatible with protocol "ProtoA" -    "y" is not a class variable (reportGeneralTypeIssues) +    "y" is not a class variable +      "x" is defined as a ClassVar in protocol +      "y" is defined as a ClassVar in protocol (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/dataclasses_usage.toml b/conformance/results/pyright/dataclasses_usage.toml index 35dd7e6f0..2ca10a09a 100644 --- a/conformance/results/pyright/dataclasses_usage.toml +++ b/conformance/results/pyright/dataclasses_usage.toml @@ -13,5 +13,5 @@ dataclasses_usage.py:89:36 - error: Argument of type "type[str]" cannot be assig dataclasses_usage.py:127:8 - error: Expected 1 positional argument (reportGeneralTypeIssues) dataclasses_usage.py:130:1 - error: Argument missing for parameter "y" (reportGeneralTypeIssues) dataclasses_usage.py:179:1 - error: Expected no arguments to "DC13" constructor (reportGeneralTypeIssues) -dataclasses_usage.py:230:9 - error: Dataclass field without type annotation will cause runtime exception (reportGeneralTypeIssues) +dataclasses_usage.py:228:9 - error: Dataclass field without type annotation will cause runtime exception (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/generics_paramspec_basic.toml b/conformance/results/pyright/generics_paramspec_basic.toml index 5d0659b75..a0afa5111 100644 --- a/conformance/results/pyright/generics_paramspec_basic.toml +++ b/conformance/results/pyright/generics_paramspec_basic.toml @@ -1,12 +1,10 @@ -conformant = "Partial" -notes = """ -Does not reject the use of Concatenate outside of a Callable annotation. -""" +conformant = "Pass" output = """ generics_paramspec_basic.py:10:1 - error: ParamSpec must be assigned to a variable named "NotIt" generics_paramspec_basic.py:15:18 - error: ParamSpec is not allowed in this context generics_paramspec_basic.py:23:14 - error: ParamSpec is not allowed in this context generics_paramspec_basic.py:23:20 - error: ParamSpec is not allowed in this context +generics_paramspec_basic.py:27:14 - error: "Concatenate" is not allowed in this context generics_paramspec_basic.py:31:19 - error: Type "P@func3" cannot be assigned to type variable "_T@list"   ParamSpec is not allowed in this context (reportGeneralTypeIssues) generics_paramspec_basic.py:35:35 - error: ParamSpec is not allowed in this context diff --git a/conformance/results/pyright/generics_paramspec_components.toml b/conformance/results/pyright/generics_paramspec_components.toml index 713ab1165..5bf4e87b5 100644 --- a/conformance/results/pyright/generics_paramspec_components.toml +++ b/conformance/results/pyright/generics_paramspec_components.toml @@ -3,8 +3,8 @@ output = """ generics_paramspec_components.py:17:25 - error: "kwargs" member of ParamSpec is valid only when used with **kwargs parameter generics_paramspec_components.py:17:45 - error: "args" member of ParamSpec is valid only when used with *args parameter generics_paramspec_components.py:20:23 - error: "args" member of ParamSpec is valid only when used with *args parameter -generics_paramspec_components.py:23:46 - error: "args" member of ParamSpec is valid only when used with *args parameter generics_paramspec_components.py:23:28 - error: "args" and "kwargs" members of ParamSpec must both appear within a function signature +generics_paramspec_components.py:23:46 - error: "args" member of ParamSpec is valid only when used with *args parameter generics_paramspec_components.py:26:28 - error: "args" and "kwargs" members of ParamSpec must both appear within a function signature generics_paramspec_components.py:30:25 - error: ParamSpec "P" has no meaning in this context (reportGeneralTypeIssues) generics_paramspec_components.py:30:43 - error: ParamSpec "P" has no meaning in this context (reportGeneralTypeIssues) diff --git a/conformance/results/pyright/generics_paramspec_semantics.toml b/conformance/results/pyright/generics_paramspec_semantics.toml index 6df1f52a8..c69483ab9 100644 --- a/conformance/results/pyright/generics_paramspec_semantics.toml +++ b/conformance/results/pyright/generics_paramspec_semantics.toml @@ -1,7 +1,6 @@ -conformant = "Partial" +conformant = "Pass" notes = """ -Constraint solver doesn't find common type for two signatures captured by a single ParamSpec. -Evaluates incorrect type when evaluating constructor call for generic class parameterized by ParamSpec. +Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed). """ output = """ generics_paramspec_semantics.py:26:6 - error: Expected 2 more positional arguments (reportGeneralTypeIssues) @@ -15,7 +14,6 @@ generics_paramspec_semantics.py:61:23 - error: Argument of type "(*, y: int) ->   Type "(*, y: int) -> int" cannot be assigned to type "(*, x: int) -> int"     Keyword parameter "y" is missing in destination     Keyword parameter "x" is missing in source (reportGeneralTypeIssues) -generics_paramspec_semantics.py:81:13 - error: "assert_type" mismatch: expected "Y[int, (int)]" but received "Y[int, (q: int, /)]" (reportGeneralTypeIssues) generics_paramspec_semantics.py:97:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter of type "str"   "Literal[1]" is incompatible with "str" (reportGeneralTypeIssues) generics_paramspec_semantics.py:107:4 - error: Argument of type "Literal[1]" cannot be assigned to parameter "args" of type "bool" diff --git a/conformance/results/pyright/generics_self_usage.toml b/conformance/results/pyright/generics_self_usage.toml index d20349701..d050f1370 100644 --- a/conformance/results/pyright/generics_self_usage.toml +++ b/conformance/results/pyright/generics_self_usage.toml @@ -3,9 +3,9 @@ output = """ generics_self_usage.py:73:14 - error: "Self" is not valid in this context (reportGeneralTypeIssues) generics_self_usage.py:73:23 - error: "Self" is not valid in this context (reportGeneralTypeIssues) generics_self_usage.py:76:6 - error: "Self" is not valid in this context (reportGeneralTypeIssues) -generics_self_usage.py:82:54 - error: "Self" cannot be used in a function with a `self` or `cls` parameter that has a type annotation other than "Self" (reportGeneralTypeIssues) generics_self_usage.py:82:44 - warning: TypeVar "TFoo2" appears only once in generic function signature   Use "Foo2" instead (reportInvalidTypeVarUse) +generics_self_usage.py:82:54 - error: "Self" cannot be used in a function with a `self` or `cls` parameter that has a type annotation other than "Self" (reportGeneralTypeIssues) generics_self_usage.py:86:16 - error: Expression of type "Foo3" cannot be assigned to return type "Self@Foo3"   Type "Foo3" cannot be assigned to type "Self@Foo3" (reportGeneralTypeIssues) generics_self_usage.py:101:15 - error: "Self" is not valid in this context (reportGeneralTypeIssues) diff --git a/conformance/results/pyright/generics_syntax_scoping.toml b/conformance/results/pyright/generics_syntax_scoping.toml index abd6e08b9..78f8845ff 100644 --- a/conformance/results/pyright/generics_syntax_scoping.toml +++ b/conformance/results/pyright/generics_syntax_scoping.toml @@ -1,19 +1,13 @@ -conformant = "Partial" -notes = """ -Does not evaluate correct type for variables that shadow type parameters. -""" +conformant = "Pass" output = """ -generics_syntax_scoping.py:92:17 - error: Type parameter "T" is already in use -generics_syntax_scoping.py:95:17 - error: Type parameter "T" is already in use -generics_syntax_scoping.py:98:17 - error: Type parameter "T" is already in use generics_syntax_scoping.py:14:29 - error: "S" is not defined (reportUndefinedVariable) generics_syntax_scoping.py:18:26 - error: "T" is not defined (reportUndefinedVariable) generics_syntax_scoping.py:35:7 - error: "T" is not defined (reportUndefinedVariable) generics_syntax_scoping.py:44:17 - error: "T" is not defined (reportUndefinedVariable) -generics_syntax_scoping.py:62:25 - error: "assert_type" mismatch: expected "str" but received "TypeVar" (reportGeneralTypeIssues) -generics_syntax_scoping.py:67:25 - error: "assert_type" mismatch: expected "int" but received "TypeVar" (reportGeneralTypeIssues) -generics_syntax_scoping.py:108:17 - error: "assert_type" mismatch: expected "int" but received "TypeVar" (reportGeneralTypeIssues) -generics_syntax_scoping.py:113:21 - error: "assert_type" mismatch: expected "str" but received "TypeVar" (reportGeneralTypeIssues) -generics_syntax_scoping.py:121:21 - error: "assert_type" mismatch: expected "complex" but received "TypeVar" (reportGeneralTypeIssues) -generics_syntax_scoping.py:124:25 - error: "assert_type" mismatch: expected "complex" but received "TypeVar" (reportGeneralTypeIssues) +generics_syntax_scoping.py:62:25 - error: "assert_type" mismatch: expected "str" but received "Literal['']" (reportGeneralTypeIssues) +generics_syntax_scoping.py:67:25 - error: "assert_type" mismatch: expected "int" but received "Literal[0]" (reportGeneralTypeIssues) +generics_syntax_scoping.py:92:17 - error: Type parameter "T" is already in use +generics_syntax_scoping.py:95:17 - error: Type parameter "T" is already in use +generics_syntax_scoping.py:98:17 - error: Type parameter "T" is already in use +generics_syntax_scoping.py:98:29 - error: Variable not allowed in type expression (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/generics_typevartuple_basic.toml b/conformance/results/pyright/generics_typevartuple_basic.toml index cfc00fa4a..e79f26316 100644 --- a/conformance/results/pyright/generics_typevartuple_basic.toml +++ b/conformance/results/pyright/generics_typevartuple_basic.toml @@ -1,6 +1,5 @@ conformant = "Partial" notes = """ -Does not reject value constraints when constructing TypeVarTuple. Does not enforce that tuples captured by TypeVarTuple are same length (spec bug?). Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?). """ @@ -18,6 +17,8 @@ generics_typevartuple_basic.py:53:37 - error: Expected unpacked TypeVarTuple; us generics_typevartuple_basic.py:56:34 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape generics_typevartuple_basic.py:59:24 - error: Expected unpacked TypeVarTuple; use Unpack[Shape] or *Shape generics_typevartuple_basic.py:65:27 - error: "covariant" is unknown parameter to TypeVarTuple +generics_typevartuple_basic.py:66:27 - error: TypeVarTuple cannot have value constraints +generics_typevartuple_basic.py:66:32 - error: TypeVarTuple cannot have value constraints generics_typevartuple_basic.py:67:27 - error: "bound" is unknown parameter to TypeVarTuple generics_typevartuple_basic.py:87:13 - error: "assert_type" mismatch: expected "tuple[int]" but received "tuple[tuple[Literal[0]], tuple[Literal[1]]]" (reportGeneralTypeIssues) generics_typevartuple_basic.py:101:14 - error: Argument of type "Array[Height]" cannot be assigned to parameter "x" of type "Array[*Shape@multiply]" in function "multiply" @@ -29,6 +30,6 @@ generics_typevartuple_basic.py:101:17 - error: Argument of type "Array[Width]" c generics_typevartuple_basic.py:102:17 - error: Argument of type "Array[Height, Width]" cannot be assigned to parameter "y" of type "Array[*Shape@multiply]" in function "multiply"   "Array[Height, Width]" is incompatible with "Array[Height]"     Type parameter "Shape@Array" is invariant, but "*tuple[Height, Width]" is not the same as "*tuple[Height]" (reportGeneralTypeIssues) -generics_typevartuple_basic.py:108:29 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple generics_typevartuple_basic.py:108:14 - error: Generic class can have at most one TypeVarTuple type parameter but received multiple ("Ts1", "Ts2") +generics_typevartuple_basic.py:108:29 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple """ diff --git a/conformance/results/pyright/generics_typevartuple_concat.toml b/conformance/results/pyright/generics_typevartuple_concat.toml index 932125cda..2146548eb 100644 --- a/conformance/results/pyright/generics_typevartuple_concat.toml +++ b/conformance/results/pyright/generics_typevartuple_concat.toml @@ -1,10 +1,3 @@ -conformant = "Partial" -notes = """ -Does not support tuple slicing when tuple type includes TypeVarTuple. -""" +conformant = "Pass" output = """ -generics_typevartuple_concat.py:56:12 - error: Expression of type "tuple[*tuple[T@move_first_element_to_last | Union[*Ts@move_first_element_to_last], ...], T@move_first_element_to_last]" cannot be assigned to return type "tuple[*Ts@move_first_element_to_last, T@move_first_element_to_last]" -  "tuple[*tuple[T@move_first_element_to_last | Union[*Ts@move_first_element_to_last], ...], T@move_first_element_to_last]" is incompatible with "tuple[*Ts@move_first_element_to_last, T@move_first_element_to_last]" -    Tuple entry 1 is incorrect type -      Type "*tuple[T@move_first_element_to_last | Union[*Ts@move_first_element_to_last], ...]" cannot be assigned to type "*Ts@move_first_element_to_last" (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/generics_typevartuple_specialization.toml b/conformance/results/pyright/generics_typevartuple_specialization.toml index b9c53e2d8..805c0ec5f 100644 --- a/conformance/results/pyright/generics_typevartuple_specialization.toml +++ b/conformance/results/pyright/generics_typevartuple_specialization.toml @@ -1,16 +1,25 @@ conformant = "Partial" notes = """ Incorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`. -Does not reject specialization of TypeVar in generic type alias when unpacked tuple is specified as type argument. -Does not reject specialization of generic type alias when number of type arguments is too few. Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar. """ output = """ generics_typevartuple_specialization.py:95:17 - error: "assert_type" mismatch: expected "tuple[Any, ...]" but received "tuple[Unknown, Unknown]" (reportGeneralTypeIssues) generics_typevartuple_specialization.py:109:18 - error: Type variable "Ts" has no meaning in this context (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:109:18 - error: Could not specialize type "IntTupleGeneric[T@IntTupleGeneric]" +  Unpacked arguments cannot be used in type argument lists +generics_typevartuple_specialization.py:110:18 - error: Could not specialize type "IntTupleGeneric[T@IntTupleGeneric]" +  Unpacked arguments cannot be used in type argument lists generics_typevartuple_specialization.py:121:27 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple generics_typevartuple_specialization.py:122:27 - error: Type argument list can have at most one unpacked TypeVarTuple or Tuple -generics_typevartuple_specialization.py:157:17 - error: "assert_type" mismatch: expected "tuple[*tuple[int, ...], int]" but received "tuple[*tuple[int, ...]]" (reportGeneralTypeIssues) -generics_typevartuple_specialization.py:159:17 - error: "assert_type" mismatch: expected "tuple[str, *tuple[int, ...], int]" but received "tuple[str, *tuple[int, ...]]" (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:127:9 - error: Too few type arguments provided for "TA7[*Ts@TA7, T1@TA7, T2@TA7]"; expected 3 but received 2 +generics_typevartuple_specialization.py:153:13 - error: Could not specialize type "TA9[*Ts@TA9, T1@TA9]" +  Unpacked arguments cannot be used in type argument lists +generics_typevartuple_specialization.py:156:65 - error: Could not specialize type "TA9[*Ts@TA9, T1@TA9]" +  Unpacked arguments cannot be used in type argument lists +generics_typevartuple_specialization.py:157:17 - error: "assert_type" mismatch: expected "tuple[*tuple[int, ...], int]" but received "tuple[Unknown]" (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:159:17 - error: "assert_type" mismatch: expected "tuple[str, *tuple[int, ...], int]" but received "tuple[str, Unknown]" (reportGeneralTypeIssues) generics_typevartuple_specialization.py:163:11 - error: Type variable "Ts2" has no meaning in this context (reportGeneralTypeIssues) +generics_typevartuple_specialization.py:163:11 - error: Could not specialize type "TA11[T@TA11, *Ts1@TA11]" +  Unpacked arguments cannot be used in type argument lists """ diff --git a/conformance/results/pyright/generics_variance_inference.toml b/conformance/results/pyright/generics_variance_inference.toml index 475bf2c9a..3c481ec22 100644 --- a/conformance/results/pyright/generics_variance_inference.toml +++ b/conformance/results/pyright/generics_variance_inference.toml @@ -11,7 +11,6 @@ generics_variance_inference.py:28:33 - error: Expression of type "ClassA[int, fl   "ClassA[int, float, float]" is incompatible with "ClassA[int, int, int]"     Type parameter "T3@ClassA" is covariant, but "float" is not a subtype of "int"       "float" is incompatible with "int" (reportGeneralTypeIssues) -generics_variance_inference.py:36:27 - error: "Iterator" is not defined (reportUndefinedVariable) generics_variance_inference.py:41:35 - error: Expression of type "ShouldBeCovariant1[float]" cannot be assigned to declared type "ShouldBeCovariant1[int]"   "ShouldBeCovariant1[float]" is incompatible with "ShouldBeCovariant1[int]"     Type parameter "T@ShouldBeCovariant1" is covariant, but "float" is not a subtype of "int" @@ -66,21 +65,18 @@ generics_variance_inference.py:149:45 - error: Expression of type "ShouldBeContr   "ShouldBeContravariant1[int]" is incompatible with "ShouldBeContravariant1[float]"     Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float"       "float" is incompatible with "int" (reportGeneralTypeIssues) -generics_variance_inference.py:169:31 - error: Expression of type "ShouldBeInvariant1[float]" cannot be assigned to declared type "ShouldBeInvariant1[int]" -  "ShouldBeInvariant1[float]" is incompatible with "ShouldBeInvariant1[int]" -    Type parameter "T@ShouldBeInvariant1" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) -generics_variance_inference.py:170:33 - error: Expression of type "ShouldBeInvariant1[int]" cannot be assigned to declared type "ShouldBeInvariant1[float]" -  "ShouldBeInvariant1[int]" is incompatible with "ShouldBeInvariant1[float]" -    Type parameter "T@ShouldBeInvariant1" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) -generics_variance_inference.py:181:31 - error: Expression of type "ShouldBeCovariant1[float]" cannot be assigned to declared type "ShouldBeCovariant1[int]" -  "ShouldBeCovariant1[float]" is incompatible with "ShouldBeCovariant1[int]" -    Type parameter "T@ShouldBeCovariant1" is covariant, but "float" is not a subtype of "int" +generics_variance_inference.py:169:31 - error: Expression of type "ShouldBeInvariant6[float]" cannot be assigned to declared type "ShouldBeInvariant6[int]" +  "ShouldBeInvariant6[float]" is incompatible with "ShouldBeInvariant6[int]" +    Type parameter "T@ShouldBeInvariant6" is invariant, but "float" is not the same as "int" (reportGeneralTypeIssues) +generics_variance_inference.py:170:33 - error: Expression of type "ShouldBeInvariant6[int]" cannot be assigned to declared type "ShouldBeInvariant6[float]" +  "ShouldBeInvariant6[int]" is incompatible with "ShouldBeInvariant6[float]" +    Type parameter "T@ShouldBeInvariant6" is invariant, but "int" is not the same as "float" (reportGeneralTypeIssues) +generics_variance_inference.py:181:31 - error: Expression of type "ShouldBeCovariant6[float]" cannot be assigned to declared type "ShouldBeCovariant6[int]" +  "ShouldBeCovariant6[float]" is incompatible with "ShouldBeCovariant6[int]" +    Type parameter "T@ShouldBeCovariant6" is covariant, but "float" is not a subtype of "int"       "float" is incompatible with "int" (reportGeneralTypeIssues) -generics_variance_inference.py:194:37 - error: Expression of type "ShouldBeContravariant1[int]" cannot be assigned to declared type "ShouldBeContravariant1[float]" -  "ShouldBeContravariant1[int]" is incompatible with "ShouldBeContravariant1[float]" -    Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float" +generics_variance_inference.py:194:37 - error: Expression of type "ShouldBeContravariant2[int]" cannot be assigned to declared type "ShouldBeContravariant2[float]" +  "ShouldBeContravariant2[int]" is incompatible with "ShouldBeContravariant2[float]" +    Type parameter "T@ShouldBeContravariant2" is contravariant, but "int" is not a supertype of "float"       "float" is incompatible with "int" (reportGeneralTypeIssues) -generics_variance_inference.py:32:7 - error: Class declaration "ShouldBeCovariant1" is obscured by a declaration of the same name (reportGeneralTypeIssues) -generics_variance_inference.py:83:7 - error: Class declaration "ShouldBeInvariant1" is obscured by a declaration of the same name (reportGeneralTypeIssues) -generics_variance_inference.py:141:7 - error: Class declaration "ShouldBeContravariant1" is obscured by a declaration of the same name (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/protocols_class_objects.toml b/conformance/results/pyright/protocols_class_objects.toml index 8fa46e696..979c37775 100644 --- a/conformance/results/pyright/protocols_class_objects.toml +++ b/conformance/results/pyright/protocols_class_objects.toml @@ -25,4 +25,10 @@ protocols_class_objects.py:59:16 - error: Expression of type "type[ConcreteA]" c protocols_class_objects.py:74:16 - error: Expression of type "type[ConcreteB]" cannot be assigned to declared type "ProtoB1"   "prop1" is an incompatible type     "property" is incompatible with "int" (reportGeneralTypeIssues) +protocols_class_objects.py:102:16 - error: Expression of type "type[ConcreteC1]" cannot be assigned to declared type "ProtoC2" +  "attr1" is not defined as a ClassVar in protocol (reportGeneralTypeIssues) +protocols_class_objects.py:103:16 - error: Expression of type "type[ConcreteC2]" cannot be assigned to declared type "ProtoC1" +  "attr1" is defined as a ClassVar in protocol (reportGeneralTypeIssues) +protocols_class_objects.py:105:16 - error: Expression of type "type[ConcreteC3]" cannot be assigned to declared type "ProtoC1" +  "attr1" is defined as a ClassVar in protocol (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/protocols_definition.toml b/conformance/results/pyright/protocols_definition.toml index bd9150093..0089ec5c9 100644 --- a/conformance/results/pyright/protocols_definition.toml +++ b/conformance/results/pyright/protocols_definition.toml @@ -1,28 +1,33 @@ -conformant = "Partial" -notes = """ -Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar. -""" +conformant = "Pass" 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: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" +protocols_definition.py:114: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:116:22 - error: Expression of type "Concrete2_Bad2" cannot be assigned to declared type "Template2" +protocols_definition.py:115: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 +    "val1" is defined as a ClassVar in protocol       "Sequence[float]" is incompatible with "Sequence[int]" (reportGeneralTypeIssues) -protocols_definition.py:117:22 - error: Expression of type "Concrete2_Bad3" cannot be assigned to declared type "Template2" +protocols_definition.py:116: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 +    "val1" is defined as a ClassVar in protocol       "list[int]" is incompatible with "Sequence[int]" (reportGeneralTypeIssues) +protocols_definition.py:117:22 - error: Expression of type "Concrete2_Bad4" cannot be assigned to declared type "Template2" +  "Concrete2_Bad4" is incompatible with protocol "Template2" +    "val1" is defined as a ClassVar in protocol (reportGeneralTypeIssues) 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:157:22 - error: Expression of type "Concrete3_Bad2" cannot be assigned to declared type "Template3" +  "Concrete3_Bad2" is incompatible with protocol "Template3" +    "val1" is not defined as a ClassVar in protocol (reportGeneralTypeIssues) 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 diff --git a/conformance/results/pyright/protocols_explicit.toml b/conformance/results/pyright/protocols_explicit.toml index bacc5d7d1..d14c8051d 100644 --- a/conformance/results/pyright/protocols_explicit.toml +++ b/conformance/results/pyright/protocols_explicit.toml @@ -1,13 +1,11 @@ -conformant = "Partial" -notes = """ -Does not report error when calling unimplemented protocol method from derived class. -""" +conformant = "Pass" output = """ -protocols_explicit.py:56:32 - error: Cannot assign member "rgb" for type "Point*" -  "str" is incompatible with "int" (reportGeneralTypeIssues) +protocols_explicit.py:27:16 - error: Method "draw" cannot be called because it is abstract and unimplemented (reportGeneralTypeIssues) protocols_explicit.py:54:7 - error: Class derives from one or more protocol classes but does not implement all required members   Member "other" is declared in protocol class "RGB"   Member "transparency" is declared in protocol class "RGB" (reportGeneralTypeIssues) +protocols_explicit.py:56:32 - error: Cannot assign member "rgb" for type "Point*" +  "str" is incompatible with "int" (reportGeneralTypeIssues) protocols_explicit.py:63:5 - error: Cannot instantiate abstract class "Point"   "RGB.intensity" is abstract (reportGeneralTypeIssues) protocols_explicit.py:86:7 - error: Class derives from one or more protocol classes but does not implement all required members diff --git a/conformance/results/pyright/protocols_merging.toml b/conformance/results/pyright/protocols_merging.toml index 3a1308853..dc01ab41e 100644 --- a/conformance/results/pyright/protocols_merging.toml +++ b/conformance/results/pyright/protocols_merging.toml @@ -8,7 +8,7 @@ protocols_merging.py:53:25 - error: Expression of type "SCConcrete2" cannot be a     "__len__" is not present (reportGeneralTypeIssues) protocols_merging.py:54:25 - error: Expression of type "SCConcrete2" cannot be assigned to declared type "SizedAndClosable3"   "SCConcrete2" is incompatible with "SizedAndClosable3" (reportGeneralTypeIssues) -protocols_merging.py:68:16 - error: Protocol class "type[BadProto]" cannot derive from non-protocol class "type[SizedAndClosable3]" +protocols_merging.py:68:16 - error: Protocol class "BadProto" cannot derive from non-protocol class "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" diff --git a/conformance/results/pyright/protocols_runtime_checkable.toml b/conformance/results/pyright/protocols_runtime_checkable.toml index de9c7e8d0..c0dcd70f7 100644 --- a/conformance/results/pyright/protocols_runtime_checkable.toml +++ b/conformance/results/pyright/protocols_runtime_checkable.toml @@ -1,9 +1,19 @@ conformant = "Partial" notes = """ -Does not reject issubclass call for data protocol. -Does not report unsafe overlap for runtime_checkable protocol. +Does not reject issubclass call for data protocol if included in tuple. """ output = """ protocols_runtime_checkable.py:23:22 - error: Second argument to "isinstance" must be a class or tuple of classes   Protocol class must be @runtime_checkable to be used with instance and class checks (reportGeneralTypeIssues) +protocols_runtime_checkable.py:55:22 - error: Data protocols (which include non-method attributes) are not allowed in issubclass calls (reportGeneralTypeIssues) +protocols_runtime_checkable.py:88:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime +  Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues) +protocols_runtime_checkable.py:92:9 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime +  Attributes of "Concrete3B" have the same names as the protocol (reportGeneralTypeIssues) +protocols_runtime_checkable.py:92:9 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime +  Attributes of "Concrete3B" have the same names as the protocol (reportGeneralTypeIssues) +protocols_runtime_checkable.py:96:19 - error: Class overlaps "Proto3" unsafely and could produce a match at runtime +  Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues) +protocols_runtime_checkable.py:96:19 - error: Class overlaps "NonDataProtocol" unsafely and could produce a match at runtime +  Attributes of "Concrete3A" have the same names as the protocol (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/protocols_variance.toml b/conformance/results/pyright/protocols_variance.toml index 9ec032c27..3ca70b876 100644 --- a/conformance/results/pyright/protocols_variance.toml +++ b/conformance/results/pyright/protocols_variance.toml @@ -6,11 +6,11 @@ output = """ protocols_variance.py:21:7 - warning: Type variable "T1" used in generic protocol "AnotherBox" should be covariant (reportInvalidTypeVarUse) protocols_variance.py:40:7 - warning: Type variable "T3" used in generic protocol "Protocol2" should be contravariant (reportInvalidTypeVarUse) protocols_variance.py:56:7 - warning: Type variable "T1" used in generic protocol "Protocol4" should be contravariant (reportInvalidTypeVarUse) -protocols_variance.py:62:22 - error: Covariant type variable cannot be used in parameter type (reportGeneralTypeIssues) protocols_variance.py:61:7 - warning: Type variable "T1_co" used in generic protocol "Protocol5" should be contravariant (reportInvalidTypeVarUse) +protocols_variance.py:62:22 - error: Covariant type variable cannot be used in parameter type (reportGeneralTypeIssues) protocols_variance.py:66:7 - warning: Type variable "T1" used in generic protocol "Protocol6" should be covariant (reportInvalidTypeVarUse) -protocols_variance.py:72:21 - error: Contravariant type variable cannot be used in return type (reportGeneralTypeIssues) protocols_variance.py:71:7 - warning: Type variable "T1_contra" used in generic protocol "Protocol7" should be covariant (reportInvalidTypeVarUse) +protocols_variance.py:72:21 - error: Contravariant type variable cannot be used in return type (reportGeneralTypeIssues) protocols_variance.py:104:7 - warning: Type variable "T1" used in generic protocol "Protocol12" should be covariant (reportInvalidTypeVarUse) protocols_variance.py:110:7 - warning: Type variable "T1_contra" used in generic protocol "Protocol13" should be invariant (reportInvalidTypeVarUse) """ diff --git a/conformance/results/pyright/qualifiers_annotated.toml b/conformance/results/pyright/qualifiers_annotated.toml index 820d04b68..dd52a4a2e 100644 --- a/conformance/results/pyright/qualifiers_annotated.toml +++ b/conformance/results/pyright/qualifiers_annotated.toml @@ -1,9 +1,8 @@ -conformant = "Partial" -notes = """ -Does not reject all invalid type expressions within Annotated. -""" +conformant = "Pass" output = """ +qualifiers_annotated.py:41:17 - error: List expression not allowed for this type argument qualifiers_annotated.py:42:17 - error: Expected type expression but received "tuple[tuple[type[int], type[str]]]" (reportGeneralTypeIssues) +qualifiers_annotated.py:43:17 - error: List expression not allowed for this type argument qualifiers_annotated.py:43:18 - error: Expected type expression but received "Generator[type[int], None, None]" (reportGeneralTypeIssues) qualifiers_annotated.py:44:17 - error: Expected type expression but received "dict[str, str]" (reportGeneralTypeIssues) qualifiers_annotated.py:44:17 - error: Dictionary expression not allowed in type annotation diff --git a/conformance/results/pyright/qualifiers_final_annotation.toml b/conformance/results/pyright/qualifiers_final_annotation.toml index ee0ee3729..4adbf594b 100644 --- a/conformance/results/pyright/qualifiers_final_annotation.toml +++ b/conformance/results/pyright/qualifiers_final_annotation.toml @@ -1,9 +1,9 @@ -conformant = "Partial" -notes = """ -Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition. -""" +conformant = "Pass" output = """ +qualifiers_final_annotation.py:16:1 - error: "BAD1" is declared Final, but value is not assigned qualifiers_final_annotation.py:18:7 - error: Expected a single type argument after "Final" +qualifiers_final_annotation.py:34:5 - error: "ID2" is declared Final, but value is not assigned +qualifiers_final_annotation.py:38:5 - error: "ID3" is declared Final, but value is not assigned qualifiers_final_annotation.py:54:14 - error: Cannot assign member "ID5" for type "ClassA*"   Member "ID5" cannot be assigned through a class instance because it is a ClassVar     Member "__set__" is unknown (reportGeneralTypeIssues) @@ -17,6 +17,7 @@ qualifiers_final_annotation.py:67:14 - error: Cannot assign member "ID7" for typ   Member "ID7" cannot be assigned through a class instance because it is a ClassVar   "ID7" is declared as Final and cannot be reassigned     Member "__set__" is unknown (reportGeneralTypeIssues) +qualifiers_final_annotation.py:71:1 - error: "RATE" is declared as Final and cannot be reassigned qualifiers_final_annotation.py:81:8 - error: Cannot assign member "DEFAULT_ID" for type "type[ClassB]"   "DEFAULT_ID" is declared as Final and cannot be reassigned     Member "__set__" is unknown (reportGeneralTypeIssues) @@ -25,14 +26,16 @@ qualifiers_final_annotation.py:107:22 - error: "Final" is not allowed in this co qualifiers_final_annotation.py:108:19 - error: "ClassVar" is not allowed in this context qualifiers_final_annotation.py:118:9 - error: "Final" is not allowed in this context qualifiers_final_annotation.py:121:14 - error: "Final" is not allowed in this context +qualifiers_final_annotation.py:134:1 - error: Arguments missing for parameters "x", "y" (reportGeneralTypeIssues) +qualifiers_final_annotation.py:134:3 - error: No parameter named "a" (reportGeneralTypeIssues) +qualifiers_final_annotation.py:135:5 - error: Argument of type "Literal['']" cannot be assigned to parameter "x" of type "int" in function "__new__" +  "Literal['']" is incompatible with "int" (reportGeneralTypeIssues) +qualifiers_final_annotation.py:135:11 - error: Argument of type "Literal['']" cannot be assigned to parameter "y" of type "int" in function "__new__" +  "Literal['']" is incompatible with "int" (reportGeneralTypeIssues) +qualifiers_final_annotation.py:141:5 - error: "ID1" is declared as Final and cannot be reassigned qualifiers_final_annotation.py:145:5 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:147:10 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:149:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:152:30 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:155:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) -qualifiers_final_annotation.py:141:5 - error: "ID1" is declared as Final and cannot be reassigned -qualifiers_final_annotation.py:16:1 - error: "BAD1" is declared Final, but value is not assigned -qualifiers_final_annotation.py:71:1 - error: "RATE" is declared as Final and cannot be reassigned -qualifiers_final_annotation.py:34:5 - error: "ID2" is declared Final, but value is not assigned -qualifiers_final_annotation.py:38:5 - error: "ID3" is declared Final, but value is not assigned """ diff --git a/conformance/results/pyright/qualifiers_final_decorator.toml b/conformance/results/pyright/qualifiers_final_decorator.toml index 2cce4fc8e..903bf2a5c 100644 --- a/conformance/results/pyright/qualifiers_final_decorator.toml +++ b/conformance/results/pyright/qualifiers_final_decorator.toml @@ -1,17 +1,16 @@ -conformant = "Partial" -notes = """ -Does not report override of overloaded method marked @final. -Does not report error for non-method function marked @final. -Does not report error if overload is marked @final but implementation is not. -Does not report error in stub if first overload is not marked @final but subsequent ones are. -""" +conformant = "Pass" output = """ qualifiers_final_decorator.py:8:6 - warning: Import "_qualifiers_final_decorator" could not be resolved from source (reportMissingModuleSource) qualifiers_final_decorator.py:21:16 - error: Base class "Base1" is marked final and cannot be subclassed qualifiers_final_decorator.py:56:9 - error: Method "method1" cannot override final method defined in class "Base2" qualifiers_final_decorator.py:60:9 - error: Method "method2" cannot override final method defined in class "Base2" qualifiers_final_decorator.py:64:9 - error: Method "method3" cannot override final method defined in class "Base2" +qualifiers_final_decorator.py:75:9 - error: Method "method4" cannot override final method defined in class "Base2" +qualifiers_final_decorator.py:86:9 - error: Overload for "method" is marked @final but implementation is not (reportGeneralTypeIssues) +qualifiers_final_decorator.py:89:9 - error: Method "method" cannot override final method defined in class "Base3" +qualifiers_final_decorator.py:102:9 - error: Method "method" cannot override final method defined in class "Base4" +qualifiers_final_decorator.py:118:9 - error: Method "method" cannot override final method defined in class "Base5_2" qualifiers_final_decorator.py:118:9 - error: Method "method" overrides class "Base5_2" in an incompatible manner   Positional parameter count mismatch; base method has 2, but override has 1 (reportIncompatibleMethodOverride) -qualifiers_final_decorator.py:118:9 - error: Method "method" cannot override final method defined in class "Base5_2" +qualifiers_final_decorator.py:126:5 - error: Function "func1" cannot be marked @final because it is not a method (reportGeneralTypeIssues) """ diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index b63904845..a389c675d 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.3031880855560303 +version = "pyright 1.1.345" +test_duration = 1.416844129562378 diff --git a/conformance/results/pytype/protocols_definition.toml b/conformance/results/pytype/protocols_definition.toml index aba256390..ac4cdf8be 100644 --- a/conformance/results/pytype/protocols_definition.toml +++ b/conformance/results/pytype/protocols_definition.toml @@ -23,11 +23,11 @@ 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 115, in : Type annotation for v2_bad1 does not match type of assignment [annotation-type-mismatch] +File "protocols_definition.py", line 114, 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 116, in : Type annotation for v2_bad2 does not match type of assignment [annotation-type-mismatch] +File "protocols_definition.py", line 115, 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] diff --git a/conformance/results/pytype/version.toml b/conformance/results/pytype/version.toml index afe00fe70..b35b5974f 100644 --- a/conformance/results/pytype/version.toml +++ b/conformance/results/pytype/version.toml @@ -1,2 +1,2 @@ version = "pytype 2023.12.18" -test_duration = 27.926777124404907 +test_duration = 27.983895778656006 diff --git a/conformance/results/results.html b/conformance/results/results.html index 3aa969200..18d80f0a9 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.25sec) +
mypy 1.8.0(1.35sec)
@@ -205,7 +205,7 @@

Python Type System Conformance Test Results

- + @@ -270,7 +270,7 @@

Python Type System Conformance Test Results

Protocols
     protocols_class_objectsPass
     protocols_definitionPartialRejects implicit class variable when matching protocol with explicit ClassVar.
Does not detect protocol mismatch if concrete method is missing annotations.
Does not detect protocol mismatch if concrete method's parameters are position-only.
     protocols_definitionPartialDoes not detect protocol mismatch if concrete method is missing annotations.
Does not detect protocol mismatch if concrete method's parameters are position-only.
     protocols_explicitPassDoes not report unimplemented attributes for class that explicitly derives from protocol until it is instantiated.
     protocols_genericPartialFails protocol matching when method-scoped TypeVar is used in protocol.
     protocols_mergingPass
     directives_version_platformPassDoes not understand three-element form of sys.version checks.
Does not understand os.name checks.
-
pyright 1.1.344(1.40sec) +
pyright 1.1.345(1.42sec)
@@ -294,9 +294,9 @@

Python Type System Conformance Test Results

- + - + @@ -306,22 +306,22 @@

Python Type System Conformance Test Results

- + - + - + - + - - - + + + @@ -348,13 +348,13 @@

Python Type System Conformance Test Results

- - + + - + @@ -413,7 +413,7 @@

Python Type System Conformance Test Results

Generics
     generics_paramspec_basicPartialDoes not reject the use of Concatenate outside of a Callable annotation.
     generics_paramspec_basicPass
     generics_paramspec_componentsPass
     generics_paramspec_semanticsPartialConstraint solver doesn't find common type for two signatures captured by a single ParamSpec.
Evaluates incorrect type when evaluating constructor call for generic class parameterized by ParamSpec.
     generics_paramspec_semanticsPassConstraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).
     generics_paramspec_specializationPass
     generics_self_advancedPass
     generics_self_attributesPass
     generics_syntax_compatibilityPass
     generics_syntax_declarationsPass
     generics_syntax_infer_variancePass
     generics_syntax_scopingPartialDoes not evaluate correct type for variables that shadow type parameters.
     generics_syntax_scopingPass
     generics_typevartuple_argsPartialDoes not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_basicPartialDoes not reject value constraints when constructing TypeVarTuple.
Does not enforce that tuples captured by TypeVarTuple are same length (spec bug?).
Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_basicPartialDoes not enforce that tuples captured by TypeVarTuple are same length (spec bug?).
Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_callablePass
     generics_typevartuple_concatPartialDoes not support tuple slicing when tuple type includes TypeVarTuple.
     generics_typevartuple_concatPass
     generics_typevartuple_overloadsPass
     generics_typevartuple_specializationPartialIncorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.
Does not reject specialization of TypeVar in generic type alias when unpacked tuple is specified as type argument.
Does not reject specialization of generic type alias when number of type arguments is too few.
Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.
     generics_typevartuple_specializationPartialIncorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.
Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.
     generics_typevartuple_unpackPartialDoes not treat `tuple[Any, ...]` as having an arbitrary length.
     generics_variancePartialDoes not reject a function-scoped TypeVar that is marked as covariant or contravariant.
     generics_variance_inferencePass
Type qualifiers
     qualifiers_annotatedPartialDoes not reject all invalid type expressions within Annotated.
     qualifiers_final_annotationPartialDoes not treat use of Final name as if it was replaced by the literal in NamedTuple definition.
     qualifiers_final_decoratorPartialDoes not report override of overloaded method marked @final.
Does not report error for non-method function marked @final.
Does not report error if overload is marked @final but implementation is not.
Does not report error in stub if first overload is not marked @final but subsequent ones are.
     qualifiers_annotatedPass
     qualifiers_final_annotationPass
     qualifiers_final_decoratorPass
Class type compatibility
Protocols
     protocols_class_objectsPartialIncorrectly reports some class objects as incompatible with a protocol.
Fails to report some class objects as incompatible with a protocol.
     protocols_definitionPartialDoes not reject ClassVar in concrete class when attribute in protocol is not ClassVar.
     protocols_explicitPartialDoes not report error when calling unimplemented protocol method from derived class.
     protocols_definitionPass
     protocols_explicitPass
     protocols_genericPass
     protocols_mergingPass
     protocols_modulesPass
     protocols_recursivePass
     protocols_runtime_checkablePartialDoes not reject issubclass call for data protocol.
Does not report unsafe overlap for runtime_checkable protocol.
     protocols_runtime_checkablePartialDoes not reject issubclass call for data protocol if included in tuple.
     protocols_selfPass
     protocols_subtypingPass
     protocols_variancePartialCalculates incorrect variance when `self` or `cls` have explicit annotation.
     directives_version_platformPass
-
pyre 0.9.19(2.39sec) +
pyre 0.9.19(2.22sec)
@@ -439,7 +439,7 @@

Python Type System Conformance Test Results

Generics - + @@ -491,7 +491,7 @@

Python Type System Conformance Test Results

- + @@ -556,7 +556,7 @@

Python Type System Conformance Test Results

     generics_paramspec_basicPartialDoes not enforce name consistency for ParamSpec assigned to identifier.
Incorrectly reports error for legitimate use of ParamSpec in generic type alias.
Does not reject ParamSpec when used in various invalid locations.
     generics_paramspec_componentsPartialDoes not report illegal use of "P.args" on normal parameter.
Does not report error when P.args is specified but P.kwargs is missing.
Does not report error when P is out of scope and P.args and P.kwargs is used.
Does not report error when calling callback defined with ParamSpec with incorrect arguments.
Does not report error when keyword argument is specified between P.args and P.kwargs.
Does not report error when calling callable and argument is missing for concatenated parameters.
     generics_paramspec_semanticsPartialConstraint solver doesn't find common type for two signatures captured by a single ParamSpec.
Reports error for legitimate Callable type annotation that uses Concatenate.
Does not evaluate the correct type for call of Callable defined with Concatenate.
     generics_paramspec_semanticsPartialConstraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).
Reports error for legitimate Callable type annotation that uses Concatenate.
Does not evaluate the correct type for call of Callable defined with Concatenate.
     generics_paramspec_specializationPartialReports error for legitimate use of ParamSpec and Concatenate in function signature.
Reports error for legitimate specialization of generic class parameterized with ParamSpec.
     generics_self_advancedUnsupportedDoes not understand `Self` type.
     generics_self_attributesUnsupportedDoes not understand `Self` type.
Protocols
     protocols_class_objectsPartialDoes not reject protocol class assigned to type[Proto].
Incorrectly reports some class objects as incompatible with a protocol.
Fails to report some class objects as incompatible with a protocol.
     protocols_definitionPartialDoes not reject ClassVar in concrete class when attribute in protocol is not ClassVar.
Does not reject read-only property in concrete class when attribute in protocol is mutable.
Does not reject covariant attribute type when protocol attribute is mutable.
Does not reject read-only property in concrete class when protocol has settable property.
Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable.
Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable.
     protocols_definitionPartialDoes not reject ClassVar in concrete class when attribute in protocol is not ClassVar or vice versa.
Does not reject read-only property in concrete class when attribute in protocol is mutable.
Does not reject covariant attribute type when protocol attribute is mutable.
Does not reject read-only property in concrete class when protocol has settable property.
Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable.
Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable.
     protocols_explicitPartialDoes not report error when calling unimplemented protocol method from derived class.
Does not report error when method is not implemented in derived class.
     protocols_genericPartialDoes not reject the use of Protocol and Generic together as base classes.
Does not detect protocol mismatch when method-scoped TypeVar is used in protocol.
     protocols_mergingPartialDoes not reject a protocol class that derives from a non-protocol class.
     directives_version_platformPartialDoes not support sys.platform checks.
Does not support os.name checks.
-
pytype 2023.12.18(28.24sec) +
pytype 2023.12.18(27.98sec)
diff --git a/conformance/tests/dataclasses_usage.py b/conformance/tests/dataclasses_usage.py index d41a93f45..f37310f33 100644 --- a/conformance/tests/dataclasses_usage.py +++ b/conformance/tests/dataclasses_usage.py @@ -199,9 +199,7 @@ class DC15(DC14): class DataclassProto(Protocol): - # Checking for this attribute seems to currently be - # the most reliable way to ascertain that something is a dataclass - __dataclass_fields__: dict[str, Any] + __dataclass_fields__: ClassVar[dict[str, Any]] v1: DataclassProto = dc15 diff --git a/conformance/tests/generics_variance_inference.py b/conformance/tests/generics_variance_inference.py index b6262f939..781b94886 100644 --- a/conformance/tests/generics_variance_inference.py +++ b/conformance/tests/generics_variance_inference.py @@ -9,7 +9,7 @@ # T1 should be invariant # T2 should be contravariant # T3 should be covariant -from typing import Generic, Sequence, TypeVar +from typing import Generic, Iterator, Sequence, TypeVar class ClassA[T1, T2, T3](list[T1]): @@ -162,33 +162,33 @@ class Parent_Invariant(Generic[T]): pass -class ShouldBeInvariant1[T](Parent_Invariant[T]): +class ShouldBeInvariant6[T](Parent_Invariant[T]): pass -a1: ShouldBeInvariant1[int] = ShouldBeInvariant1[float]() # Type error -a2: ShouldBeInvariant1[float] = ShouldBeInvariant1[int]() # Type error +a1: ShouldBeInvariant6[int] = ShouldBeInvariant6[float]() # Type error +a2: ShouldBeInvariant6[float] = ShouldBeInvariant6[int]() # Type error class Parent_Covariant(Generic[T_co]): pass -class ShouldBeCovariant1[T](Parent_Covariant[T]): +class ShouldBeCovariant6[T](Parent_Covariant[T]): pass -b1: ShouldBeCovariant1[int] = ShouldBeCovariant1[float]() # Type error -b2: ShouldBeCovariant1[float] = ShouldBeCovariant1[int]() # OK +b1: ShouldBeCovariant6[int] = ShouldBeCovariant6[float]() # Type error +b2: ShouldBeCovariant6[float] = ShouldBeCovariant6[int]() # OK class Parent_Contravariant(Generic[T_contra]): pass -class ShouldBeContravariant1[T](Parent_Contravariant[T]): +class ShouldBeContravariant2[T](Parent_Contravariant[T]): pass -c1: ShouldBeContravariant1[int] = ShouldBeContravariant1[float]() # OK -c2: ShouldBeContravariant1[float] = ShouldBeContravariant1[int]() # Type error +c1: ShouldBeContravariant2[int] = ShouldBeContravariant2[float]() # OK +c2: ShouldBeContravariant2[float] = ShouldBeContravariant2[int]() # Type error diff --git a/conformance/tests/protocols_definition.py b/conformance/tests/protocols_definition.py index d54ce16fb..9b3307a19 100644 --- a/conformance/tests/protocols_definition.py +++ b/conformance/tests/protocols_definition.py @@ -94,10 +94,6 @@ class Concrete2_Good1: val1: ClassVar[Sequence[int]] = [2] -class Concrete2_Good2: - val1: Sequence[int] = [2] - - class Concrete2_Bad1: ... @@ -110,11 +106,15 @@ class Concrete2_Bad3: val1: list[int] = [2] +class Concrete2_Bad4: + val1: Sequence[int] = [2] + + v2_good1: Template2 = Concrete2_Good1() # OK -v2_good2: Template2 = Concrete2_Good2() # OK v2_bad1: Template2 = Concrete2_Bad1() # Type error v2_bad2: Template2 = Concrete2_Bad2() # Type error v2_bad3: Template2 = Concrete2_Bad3() # Type error +v2_bad4: Template2 = Concrete2_Bad4() # Type error class Template3(Protocol): diff --git a/conformance/tests/protocols_runtime_checkable.py b/conformance/tests/protocols_runtime_checkable.py index 61b9fb8e2..1d47e8d8b 100644 --- a/conformance/tests/protocols_runtime_checkable.py +++ b/conformance/tests/protocols_runtime_checkable.py @@ -58,6 +58,9 @@ def func2(a: Any): if issubclass(a, NonDataProtocol): # OK return + if issubclass(a, (NonDataProtocol, DataProtocol)): # Type error + return + # > Type checkers should reject an isinstance() or issubclass() call if there # > is an unsafe overlap between the type of the first argument and the protocol. @@ -85,8 +88,10 @@ def func3(): if isinstance(Concrete3A(), Proto3): # Type error: unsafe overlap pass - if isinstance(Concrete3B(), (Proto3, Proto2)): # Type error: unsafe overlap + if isinstance( + Concrete3B(), (Proto3, NonDataProtocol) + ): # Type error: unsafe overlap pass - if issubclass(Concrete3A, (Proto3, Proto2)): # Type error: unsafe overlap + if issubclass(Concrete3A, (Proto3, NonDataProtocol)): # Type error: unsafe overlap pass From 9655852304e1e5061ef3b9e504d1acf3843bdd65 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 9 Jan 2024 20:56:55 -0800 Subject: [PATCH 8/9] Updated look of conformance test results page so it's easier to read. --- conformance/results/mypy/version.toml | 2 +- conformance/results/pyre/version.toml | 2 +- conformance/results/pyright/version.toml | 2 +- conformance/results/pytype/version.toml | 2 +- conformance/results/results.html | 642 ++--------------------- conformance/src/reporting.py | 66 ++- conformance/src/results_template.html | 69 ++- 7 files changed, 141 insertions(+), 644 deletions(-) diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index 6829f8463..de222af8b 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.3487539291381836 +test_duration = 1.3177800178527832 diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml index 4c4878364..b7b3f9770 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.220608949661255 +test_duration = 2.2062928676605225 diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index a389c675d..948fac0b2 100644 --- a/conformance/results/pyright/version.toml +++ b/conformance/results/pyright/version.toml @@ -1,2 +1,2 @@ version = "pyright 1.1.345" -test_duration = 1.416844129562378 +test_duration = 1.3236510753631592 diff --git a/conformance/results/pytype/version.toml b/conformance/results/pytype/version.toml index b35b5974f..acf97698a 100644 --- a/conformance/results/pytype/version.toml +++ b/conformance/results/pytype/version.toml @@ -1,2 +1,2 @@ version = "pytype 2023.12.18" -test_duration = 27.983895778656006 +test_duration = 26.059975147247314 diff --git a/conformance/results/results.html b/conformance/results/results.html index 18d80f0a9..3165bdc06 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -63,44 +63,38 @@ margin-top: 4px; margin-bottom: 4px; - border: 0px solid #000; - } - - .spacer { - border-color: #f0f0f0; border-style: solid; - border-bottom-width: 1px; + border-color: white; + border-left-width: 8px; + border-right-width: 8px; + border-top-width: 0; + border-bottom-width: 0; } .col1 { - width: 25%; + width: 28%; vertical-align: top; } .col2 { - width: 10%; - vertical-align: top; - } - - .col3 { - width: 65%; - vertical-align: top; + width: 18%; + cursor: pointer; + text-align: center; } .tc-header { - margin-top: 20px; - margin-bottom: 8px; + padding-top: 4px; + text-align: center; } .tc-name { - font-size: 18px; - font-weight: bold; + font-size: 16px; + margin-top: 8px; + margin-bottom: 8px; } .tc-time { - margin-left: 8px; font-size: 12px; - font-weight: normal; } .test_group { @@ -119,6 +113,41 @@ .not-conformant { background-color: rgb(242, 171, 171); } + + .tooltip-text { + visibility: hidden; + position: absolute; + z-index: 2; + width: 400px; + color: black; + font-size: 12px; + background-color: white; + border: 1px solid black; + padding: 10px 15px 10px 15px; + text-align: left; + } + + .hover-text:hover .tooltip-text { + visibility: visible; + } + + .hover-text .tooltip-text p { + margin: 4px; + } + + #bottom { + top: 25px; + left: -80%; + } + + #bottom::before { + top: -5%; + left: 94%; + } + + .hover-text { + position: relative; + } @@ -127,578 +156,7 @@

Python Type System Conformance Test Results

-
mypy 1.8.0(1.35sec) -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Type annotations
     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_methodsPassType evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
     annotations_typeexprPass
-Special types in annotations
     specialtypes_anyPass
     specialtypes_neverPartialDoes not reject NoReturn when used outside of return type annotation.
     specialtypes_nonePass
     specialtypes_promotionsPass
     specialtypes_tuplePass
     specialtypes_tuple_unpackPass
     specialtypes_typePartialDoes not treat `type` same as `type[Any]` for assert_type.
Does not allow access to unknown attributes from object of type `type[Any]`.
-Generics
     generics_paramspec_basicPartialDoes not reject ParamSpec when used "bare" in type alias definition.
     generics_paramspec_componentsPartialDoes not report illegal use of "P.args" on normal parameter.
Does not report error when P.args is specified but P.kwargs is missing.
Does not report error when P is out of scope and P.args and P.kwargs is used.
Does not report error when keyword argument is specified between P.args and P.kwargs.
Does not report error when calling callable and argument is missing for concatenated parameters.
     generics_paramspec_semanticsPass
     generics_paramspec_specializationPass
     generics_self_advancedPartialDoes not infer the type of an unannotated `self` parameter to be type `Self`.
Does not retain `Self` when calling method that returns `Self`.
Does not infer the type of an unannotated `cls` parameter to be type `type[Self]`.
Does not retain `Self` when accessing attribute through `type[Self]`.
     generics_self_attributesPass
     generics_self_basicPartialDoes not properly handle constructor call through `cls` parameter.
     generics_self_protocolsPass
     generics_self_usagePass
     generics_syntax_compatibilityUnsupportedType parameter syntax not yet support.
     generics_syntax_declarationsUnsupportedType parameter syntax not yet support.
     generics_syntax_infer_varianceUnsupportedType parameter syntax not yet support.
     generics_syntax_scopingUnsupportedType parameter syntax not yet support.
     generics_typevartuple_argsPartialDoes not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_basicPartialDoes not enforce that tuples captured by TypeVarTuple are same length (spec bug?).
Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
Does not enforce that tuples captured by TypeVarTuple are invariant in non-tuple class.
     generics_typevartuple_callablePass
     generics_typevartuple_concatPass
     generics_typevartuple_overloadsPass
     generics_typevartuple_specializationPartialIncorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.
Incorrectly specializes generic alias that includes a TypeVar and TypeVarTuple if no type arguments are provided.
Rejects use of unpacked TypeVarTuple in generic type alias definition.
Rejects specialization of generic type alias defined as a tuple containing a TypeVar.
"More than one Unpack" error message has no line number.
Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.
     generics_typevartuple_unpackPartialDoes not reject multiple unpack operators in a tuple.
     generics_variancePartialDoes not reject a function-scoped TypeVar that is marked as covariant or contravariant.
Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.
     generics_variance_inferenceUnsupportedType parameter syntax not yet support.
-Type qualifiers
     qualifiers_annotatedPartialDoes not allow ClassVar to be nested within Annotated.
Does not allow Final to be nested within Annotated.
Does not allow Required and NotRequired to be nested within Annotated.
     qualifiers_final_annotationPartialDoes not treat use of Final name as if it was replaced by the literal in NamedTuple definition.
Does not allow conditional assignment of Final instance variable in __init__ method.
Does not allow redefinition of private class variable that is marked Final in parent class.
Does not report modification of local Final variable via "for" statement.
     qualifiers_final_decoratorPass
-Class type compatibility
     classes_classvarPartialInternal error if TypeVarTuple is used in ClassVar.
Does not reject use of ParamSpec in ClassVar.
Rejects ClassVar nested in Annotated.
Does not reject use of ClassVar in TypeAlias definition.
Does not infer type of ClassVar from assignment if no type is provided.
     classes_overridePartialDoes not handle case where parent class derives from Any.
-Type aliases
     aliases_explicitPartialDoes not reject specialization of type alias that has already been implicitly specialized.
     aliases_implicitPass
     aliases_newtypePass
     aliases_recursivePass
     aliases_type_statementUnsupportedDoes not support `type` statement.
     aliases_typealiastypeUnsupportedSupport for TypeAliasType is not implemented.
     aliases_variancePass
-Literals
     literals_interactionsPartialDoes not narrow type of `x` with `x in Literal` type guard pattern.
     literals_literalstringUnsupportedSupport for `LiteralString` is not implemented.
     literals_parameterizationsPartialDoes not reject tuple within Literal.
     literals_semanticsPass
-Protocols
     protocols_class_objectsPass
     protocols_definitionPartialDoes not detect protocol mismatch if concrete method is missing annotations.
Does not detect protocol mismatch if concrete method's parameters are position-only.
     protocols_explicitPassDoes not report unimplemented attributes for class that explicitly derives from protocol until it is instantiated.
     protocols_genericPartialFails protocol matching when method-scoped TypeVar is used in protocol.
     protocols_mergingPass
     protocols_modulesPass
     protocols_recursivePass
     protocols_runtime_checkablePartialDoes not report unsafe overlap for runtime_checkable protocol.
     protocols_selfPass
     protocols_subtypingPass
     protocols_variancePass
-Callables
     callables_annotationPass
     callables_kwargsPass
     callables_protocolPass
-Overloads
     overloads_basicPass
-Dataclasses
     dataclasses_descriptorsPartialDoes not correctly evaluate type of descriptor access.
     dataclasses_frozenPass
     dataclasses_hashPartialDoes not report when dataclass is not compatible with Hashable protocol.
     dataclasses_inheritancePass
     dataclasses_kwonlyPartialIncorrectly rejects kw_only field with default before positional field.
     dataclasses_orderPass
     dataclasses_postinitPass
     dataclasses_slotsPartialDoes not reject write to instance variable that is not defined in __slots__.
     dataclasses_transform_classPass
     dataclasses_transform_fieldPartialDoes not properly handle field constructor that has default value for `kw_only` or `init` parameter.
     dataclasses_transform_funcPartialDoes not handle `kw_only=False` override when `kw_only_default=True`.
Does not report error when `order=False` and comparison operators are used.
     dataclasses_transform_metaPass
     dataclasses_usagePass
-Typed dictionaries
     typeddicts_alt_syntaxPassDoes not support keyword-argument form of alternative syntax (deprecated in 3.11).
     typeddicts_class_syntaxPass
     typeddicts_finalPass
     typeddicts_inheritancePass
     typeddicts_operationsPass
     typeddicts_requiredPartialDoes not support nesting of `Annotated` and `Required` or `NotRequired`.
     typeddicts_type_consistencyPass
     typeddicts_usagePass
-Type narrowing
     narrowing_typeguardPass
-Type checker directives
     directives_assert_typePass
     directives_castPass
     directives_no_type_checkPartialDoes not honor `@no_type_check` class decorator.
     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.345(1.42sec) -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Type annotations
     annotations_coroutinesPass
     annotations_forward_refsPass
     annotations_generatorsPass
     annotations_methodsPassType evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
     annotations_typeexprPass
-Special types in annotations
     specialtypes_anyPass
     specialtypes_neverPartialDoes not reject NoReturn when used outside of return type annotation.
     specialtypes_nonePass
     specialtypes_promotionsPass
     specialtypes_tuplePass
     specialtypes_tuple_unpackPass
     specialtypes_typePartialDoes not reject Callable when passed to type[T].
-Generics
     generics_paramspec_basicPass
     generics_paramspec_componentsPass
     generics_paramspec_semanticsPassConstraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).
     generics_paramspec_specializationPass
     generics_self_advancedPass
     generics_self_attributesPass
     generics_self_basicPass
     generics_self_protocolsPass
     generics_self_usagePass
     generics_syntax_compatibilityPass
     generics_syntax_declarationsPass
     generics_syntax_infer_variancePass
     generics_syntax_scopingPass
     generics_typevartuple_argsPartialDoes not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_basicPartialDoes not enforce that tuples captured by TypeVarTuple are same length (spec bug?).
Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).
     generics_typevartuple_callablePass
     generics_typevartuple_concatPass
     generics_typevartuple_overloadsPass
     generics_typevartuple_specializationPartialIncorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.
Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.
     generics_typevartuple_unpackPartialDoes not treat `tuple[Any, ...]` as having an arbitrary length.
     generics_variancePartialDoes not reject a function-scoped TypeVar that is marked as covariant or contravariant.
     generics_variance_inferencePass
-Type qualifiers
     qualifiers_annotatedPass
     qualifiers_final_annotationPass
     qualifiers_final_decoratorPass
-Class type compatibility
     classes_classvarPass
     classes_overridePass
-Type aliases
     aliases_explicitPass
     aliases_implicitPass
     aliases_newtypePass
     aliases_recursivePass
     aliases_type_statementPass
     aliases_typealiastypePass
     aliases_variancePass
-Literals
     literals_interactionsPass
     literals_literalstringPass
     literals_parameterizationsPass
     literals_semanticsPass
-Protocols
     protocols_class_objectsPartialIncorrectly reports some class objects as incompatible with a protocol.
Fails to report some class objects as incompatible with a protocol.
     protocols_definitionPass
     protocols_explicitPass
     protocols_genericPass
     protocols_mergingPass
     protocols_modulesPass
     protocols_recursivePass
     protocols_runtime_checkablePartialDoes not reject issubclass call for data protocol if included in tuple.
     protocols_selfPass
     protocols_subtypingPass
     protocols_variancePartialCalculates incorrect variance when `self` or `cls` have explicit annotation.
-Callables
     callables_annotationPass
     callables_kwargsPass
     callables_protocolPass
-Overloads
     overloads_basicPass
-Dataclasses
     dataclasses_descriptorsPass
     dataclasses_frozenPass
     dataclasses_hashPass
     dataclasses_inheritancePass
     dataclasses_kwonlyPass
     dataclasses_orderPass
     dataclasses_postinitPass
     dataclasses_slotsPass
     dataclasses_transform_classPass
     dataclasses_transform_fieldPass
     dataclasses_transform_funcPass
     dataclasses_transform_metaPass
     dataclasses_usagePass
-Typed dictionaries
     typeddicts_alt_syntaxPass
     typeddicts_class_syntaxPass
     typeddicts_finalPass
     typeddicts_inheritancePass
     typeddicts_operationsPass
     typeddicts_requiredPass
     typeddicts_type_consistencyPass
     typeddicts_usagePass
-Type narrowing
     narrowing_typeguardPass
-Type checker directives
     directives_assert_typePass
     directives_castPass
     directives_no_type_checkUnsupportedIntentionally does not honor @no_type_check decorator.
     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.22sec) -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Type annotations
     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_methodsPassType evaluation differs from other type checkers because of ambiguity in the spec related to method bindings.
     annotations_typeexprPass
-Special types in annotations
     specialtypes_anyPartialDoes not treat missing type argument as Any in generic type.
Does not support Any as a base class.
     specialtypes_neverPartialDoes not reject NoReturn when used outside of return type annotation.
Does not treat Never as compatible with all other types.
     specialtypes_nonePartialDoes not correctly handle type annotation type[None].
     specialtypes_promotionsPartialDoes not reject use of attribute that is compatible only with float.
     specialtypes_tuplePartialDoes not report type violation when assigning tuple[T, ...] to tuple[T].
     specialtypes_tuple_unpackUnsupportedDoes not support unpacked tuple in type expression.
     specialtypes_typePartialDoes not reject Callable when passed to type[T].
Does not treat `type` same as `type[Any]` for assert_type.
Does not allow access to unknown attributes from object of type `type[Any]`.
Does not reject access to unknown attributes from object of type `Type[object]`.
Reports type incompatibility between `type` and `Callable[..., Any]`.
-Generics
     generics_paramspec_basicPartialDoes not enforce name consistency for ParamSpec assigned to identifier.
Incorrectly reports error for legitimate use of ParamSpec in generic type alias.
Does not reject ParamSpec when used in various invalid locations.
     generics_paramspec_componentsPartialDoes not report illegal use of "P.args" on normal parameter.
Does not report error when P.args is specified but P.kwargs is missing.
Does not report error when P is out of scope and P.args and P.kwargs is used.
Does not report error when calling callback defined with ParamSpec with incorrect arguments.
Does not report error when keyword argument is specified between P.args and P.kwargs.
Does not report error when calling callable and argument is missing for concatenated parameters.
     generics_paramspec_semanticsPartialConstraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).
Reports error for legitimate Callable type annotation that uses Concatenate.
Does not evaluate the correct type for call of Callable defined with Concatenate.
     generics_paramspec_specializationPartialReports error for legitimate use of ParamSpec and Concatenate in function signature.
Reports error for legitimate specialization of generic class parameterized with ParamSpec.
     generics_self_advancedUnsupportedDoes not understand `Self` type.
     generics_self_attributesUnsupportedDoes not understand `Self` type.
     generics_self_basicUnsupportedDoes not understand `Self` type.
     generics_self_protocolsPartialDoes not reject protocol compatibility due to method `Self` return type.
     generics_self_usageUnsupportedDoes not understand `Self` type.
     generics_syntax_compatibilityUnsupportedType parameter syntax not yet support.
     generics_syntax_declarationsUnsupportedType parameter syntax not yet support.
     generics_syntax_infer_varianceUnsupportedType parameter syntax not yet support.
     generics_syntax_scopingUnsupportedType parameter syntax not yet support.
     generics_typevartuple_argsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_basicUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_callableUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_concatUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_overloadsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_specializationUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_unpackUnsupportedDoes not support TypeVarTuple.
     generics_variancePartialDoes not reject a TypeVar that is defined as both covariant and contravariant.
Does not reject a function-scoped TypeVar that is marked as covariant or contravariant.
Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.
     generics_variance_inferenceUnsupportedType parameter syntax not yet support.
-Type qualifiers
     qualifiers_annotatedPartialDoes not reject Annotated with a single parameter.
     qualifiers_final_annotationPartialDoes not report Final variable with missing initialization in module scope.
Does not report error for invalid nesting of Final and ClassVar.
Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.
     qualifiers_final_decoratorPartialReports error for overloaded method implementation marked @final if its overloads do not.
Does not report error for overloaded @final method defined in stub file.
Reports misleading error when overload is marked @final but implementation is not.
-Class type compatibility
     classes_classvarPartialDoes not reject use of TypeVar in ClassVar.
Does not reject use of ParamSpec in ClassVar.
Does not reject use of ClassVar as a generic type argument.
Does not reject use of ClassVar in parameter type annotation.
Does not reject use of ClassVar in local variable annotation.
Does not reject use of ClassVar in instance variable annotation.
Does not reject use of ClassVar in return type annotation.
Does not reject use of ClassVar in type alias definition.
     classes_overrideUnsupportedDoes not yet support the @override decorator.
-Type aliases
     aliases_explicitPartialIncorrectly reports error for type alias defined with ParamSpec.
Incorrectly rejects some valid type aliases when used in annotations.
Incorrectly evaluates generic type alias with ParamSpec with missing type argument.
Does not report some illegal annotation forms as invalid type aliases.
Does not report invalid specialization of generic type aliases.
Incorrectly rejects import alias of `TypeAlias` when used to define type alias.
Does not report invalid specialization of already-specialized generic type alias.
     aliases_implicitPartialIncorrectly reports error for type alias defined with ParamSpec.
Incorrectly rejects some valid type aliases when used in annotations.
Incorrectly evaluates generic type alias with ParamSpec with missing type argument.
Does not report invalid specialization of generic type aliases.
Does not report error for attempt to instantiate union type alias.
Does not report invalid specialization of already-specialized generic type alias.
     aliases_newtypePartialDoes not reject use of NewType in `isinstance` call.
Does not reject use of NewType in class definition statement.
Does not report inconsistency between name of NewType and assigned identifier name.
Does not reject use of NewType with generic class with TypeVar.
Does not reject use of NewType with protocol class.
Does not reject use of NewType with TypedDict class.
Does not reject use of NewType with another NewType.
Does not reject use of NewType with Any.
     aliases_recursivePartialDoes not properly handle some recursive type aliases.
Does not properly handle specialization of generic recursive type aliases.
     aliases_type_statementUnsupportedDoes not support `type` statement.
     aliases_typealiastypeUnsupportedSupport for TypeAliasType is not implemented.
     aliases_variancePass
-Literals
     literals_interactionsPartialDoes not detect out-of-bound tuple literal index.
Does not narrow type of `x` with `x in Literal` type guard pattern.
Does not narrow type of `x` with `x == Literal` type guard pattern.
     literals_literalstringPass
     literals_parameterizationsPartialDoes not support type aliases in Literal type expression.
Does not support nested Literal type expression.
Does not reject unary + operator in Literal type expression.
Does not reject tuple in Literal type expression.
Does not reject "bare" Literal in type expression.
     literals_semanticsPartialDoes not reject augmented operation that modifies literal value.
-Protocols
     protocols_class_objectsPartialDoes not reject protocol class assigned to type[Proto].
Incorrectly reports some class objects as incompatible with a protocol.
Fails to report some class objects as incompatible with a protocol.
     protocols_definitionPartialDoes not reject ClassVar in concrete class when attribute in protocol is not ClassVar or vice versa.
Does not reject read-only property in concrete class when attribute in protocol is mutable.
Does not reject covariant attribute type when protocol attribute is mutable.
Does not reject read-only property in concrete class when protocol has settable property.
Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable.
Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable.
     protocols_explicitPartialDoes not report error when calling unimplemented protocol method from derived class.
Does not report error when method is not implemented in derived class.
     protocols_genericPartialDoes not reject the use of Protocol and Generic together as base classes.
Does not detect protocol mismatch when method-scoped TypeVar is used in protocol.
     protocols_mergingPartialDoes not reject a protocol class that derives from a non-protocol class.
     protocols_modulesUnsupportedDoes not perform protocol checks for modules.
     protocols_recursivePass
     protocols_runtime_checkableUnsupportedDoes not reject isinstance or issubclass call for protocol that is not runtime_checkable.
Does not reject issubclass call for data protocol.
Does not report unsafe overlap for runtime_checkable protocol.
     protocols_selfPass
     protocols_subtypingPass
     protocols_varianceUnsupportedDoes not detect incorrect TypeVar variance within generic protocols.
-Callables
     callables_annotationPartialDoes not evaluate correct type for `*args: int` parameter.
Does not reject illegal form `Callable[[...], int]`.
     callables_kwargsUnsupportedDoes not understand Unpack in the context of **kwargs annotation.
     callables_protocolPartialDoes not correctly handle callback protocol that declares attributes in all functions.
Does not report type incompatibility for callback protocol with positional-only parameters.
Incorrectly reports type compatibility error with callback that has *args and **kwargs.
Does not report type incompatibility for callback missing a default argument for positional parameter.
Does not report type incompatibility for callback missing a default argument for keyword parameter.
-Overloads
     overloads_basicPartialDoes not reject a function with a single @overload signature.
-Dataclasses
     dataclasses_descriptorsPartialIncorrectly generates error when calling constructor of dataclass with descriptor.
     dataclasses_frozenPartialDoes not reject frozen dataclass inherited from non-frozen dataclass.
Does not reject non-frozen dataclass inherited from frozen dataclass.
     dataclasses_hashPartialDoes not report when dataclass is not compatible with Hashable protocol.
     dataclasses_inheritancePartialDoes not reject ClassVar that is overridden by instance variable.
Does not reject instance variable that is overridden by ClassVar.
     dataclasses_kwonlyPass
     dataclasses_orderPartialDoes not report type incompatibility with comparison operator.
     dataclasses_postinitUnsupportedDoes not perform validation of `__post_init__` method.
Does not reject access of `InitVar` from object.
     dataclasses_slotsPartialDoes not report error when `slots=True` is used with `__slots__` definition.
Does not reject write to instance variable that is not defined in __slots__.
Does not reject access to `__slots__` from dataclass instance when `slots=False`.
     dataclasses_transform_classUnsupportedDoes not understand @dataclass_transform.
     dataclasses_transform_fieldUnsupportedDoes not understand @dataclass_transform.
     dataclasses_transform_funcUnsupportedDoes not understand @dataclass_transform.
     dataclasses_transform_metaUnsupportedDoes not understand @dataclass_transform.
     dataclasses_usagePartialDoes not report error when field with no default follows field with default.
Incorrectly reports error with InitVar that has default value.
-Typed dictionaries
     typeddicts_alt_syntaxPartialDoes not report when name of TypedDict doesn't match assigned identifier name.
Does not support keyword-argument form of alternative syntax (deprecated in 3.11).
     typeddicts_class_syntaxPartialDoes not reject methods within TypedDict class.
Does not report when metaclass is provided.
Does not report when other keyword argument is provided.
Does not support generic TypedDict class.
     typeddicts_finalPartialDoes not handle value with literal type as index to TypedDict object.
     typeddicts_inheritancePartialDoes not reject TypedDict class that inherits from non-TypedDict class.
     typeddicts_operationsPass
     typeddicts_requiredPartialDoes not reject use of `Required` in function parameter annotation.
Does not reject nested use of `Required` in type annotation.
Does not support recursive TypedDict definitions.
     typeddicts_type_consistencyPartialDoes not reject assignment of TypedDict with missing key.
Does not return non-Optional value from `get` method for required key.
Does not properly handle nested TypedDicts.
     typeddicts_usagePartialDoes not report errant use of TypedDict in `isinstance` call.
Does not reject use of TypedDict as TypeVar bound.
-Type narrowing
     narrowing_typeguardPartialDoes not support `tuple` in `assert_type` call.
Does not reject TypeGuard method with too few parameters.
-Type checker directives
     directives_assert_typeUnsupportedDoes not understand "assert_type".
     directives_castPass
     directives_no_type_checkUnsupportedDoes not honor @no_type_check decorator.
     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(27.98sec) -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Type annotations
     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_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.
-Special types in annotations
     specialtypes_anyPass
     specialtypes_neverUnsupportedDoes not understand NoReturn or Never.
     specialtypes_nonePartialDoes not detect type incompatibility between None and type[None].
Does not detect type incompatibility between None and incompatible protocol.
     specialtypes_promotionsPass
     specialtypes_tuplePartialDoes not report type violation when assigning tuple[T, ...] to tuple[T].
     specialtypes_tuple_unpackUnsupportedDoes not support unpacked tuple in type expression.
     specialtypes_typePartialDoes not reject Callable when passed to type[T].
Does not allow access to known attributes from object of type `type[Any]`.
-Generics
     generics_paramspec_basicUnsupportedDoes not support ParamSpec.
     generics_paramspec_componentsUnsupportedDoes not support ParamSpec.
     generics_paramspec_semanticsUnsupportedDoes not support ParamSpec.
     generics_paramspec_specializationUnsupportedDoes not support ParamSpec.
     generics_self_advancedUnsupportedDoes not understand `Self` type.
     generics_self_attributesUnsupportedDoes not understand `Self` type.
     generics_self_basicUnsupportedDoes not understand `Self` type.
     generics_self_protocolsPartialDoes not reject protocol compatibility due to method `Self` return type.
     generics_self_usageUnsupportedDoes not understand `Self` type.
     generics_syntax_compatibilityUnsupportedType parameter syntax not yet support.
     generics_syntax_declarationsUnsupportedType parameter syntax not yet support.
     generics_syntax_infer_varianceUnsupportedType parameter syntax not yet support.
     generics_syntax_scopingUnsupportedType parameter syntax not yet support.
     generics_typevartuple_argsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_basicUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_callableUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_concatUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_overloadsUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_specializationUnsupportedDoes not support TypeVarTuple.
     generics_typevartuple_unpackUnsupportedDoes not support TypeVarTuple.
     generics_varianceUnsupportedDoes not support covariant or contravariant TypeVars.
     generics_variance_inferenceUnsupportedType parameter syntax not yet support.
-Type qualifiers
     qualifiers_annotatedPartialDoes not reject some illegal type expression forms used in Annotated.
Does not allow TypeVar to be used in type alias when wrapped with Annotated.
     qualifiers_final_annotationPartialDoes not report Final variable with missing initialization.
Does not reject Final instance variable declared outside of __init__ method.
Does not reject modification of global variable declared Final.
Does not reject modification of local variable declared Final.
     qualifiers_final_decoratorPartialDoes not report error for overloaded @final method defined in stub file.
Does not report error for overload that is marked @final when implementation is not.
-Class type compatibility
     classes_classvarPartialDoes not reject use of TypeVar in ClassVar.
Does not reject use of ParamSpec in ClassVar.
Does not reject use of ClassVar as a generic type argument.
Rejects initialization of ClassVar if no type argument is provided.
Does not reject use of ClassVar in parameter type annotation.
Does not reject use of ClassVar in local variable annotation.
Does not reject use of ClassVar in instance variable annotation.
Does not reject use of ClassVar in return type annotation.
Does not reject use of ClassVar in type alias definition.
Does not reject assignment of ClassVar through instance of class.
     classes_overrideUnsupportedDoes not yet support the @override decorator.
-Type aliases
     aliases_explicitPartialIncorrectly reports error for type alias defined with ParamSpec.
Does not report invalid specialization of generic type alias with bound TypeVar.
Incorrectly evaluates generic type alias with ParamSpec with missing type argument.
Does not report some illegal annotation forms as invalid type aliases.
Does not report invalid specialization of already-specialized generic type alias.
     aliases_implicitPartialIncorrectly reports error for type alias defined with ParamSpec.
Does not report invalid specialization of generic type alias with bound TypeVar.
Incorrectly evaluates generic type alias with ParamSpec with missing type argument.
Allows some illegal annotation forms to be interpreted as valid type aliases.
Does not report invalid specialization of already-specialized generic type alias.
     aliases_newtypePartialDoes not reject use of NewType in `isinstance` call.
Does not reject use of NewType in class definition statement.
Does not report inconsistency between name of NewType and assigned identifier name.
Does not reject use of NewType with generic class with TypeVar.
Does not reject use of NewType with protocol class.
Does not reject use of NewType with TypedDict class.
Does not reject use of NewType with another NewType.
Does not reject use of NewType with Any.
     aliases_recursivePartialDoes not detect type violation for some deeply-nested types.
Does not properly handle `|` for unions in some recursive type alias definitions.
Does not detect cyclical references in recursive type alias definition.
     aliases_type_statementUnsupportedDoes not support `type` statement.
     aliases_typealiastypeUnsupportedSupport for TypeAliasType is not implemented.
     aliases_varianceUnsupportedDoes not detect variance incompatibility.
-Literals
     literals_interactionsPartialIncorrectly rejects some legal Literal annotations.
Does not reject some illegal Literal annotations.
Does not use Literal to distinguish overloads.
Does not narrow based on `x is Literal` type guard pattern.
Does not narrow based on `x == Literal` type guard pattern.
     literals_literalstringUnsupportedDoes not understand `LiteralString` special form.
     literals_parameterizationsUnsupportedDoes not understand `Literal` type annotation.
     literals_semanticsUnsupportedDoes not understand `Literal` type annotation.
-Protocols
     protocols_class_objectsPartialDoes not reject protocol class assigned to type[Proto].
Incorrectly reports some class objects as incompatible with a protocol.
Fails to report some class objects as incompatible with a protocol.
     protocols_definitionPartialReports errors for protocol static method with "..." implementation.
Does not report error when instance variable is set through "self" access in protocol class.
Does not report protocol mismatch when concrete class has attribute with covariant type and protocol attribute is mutable.
Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar.
Does not reject read-only property in concrete class when attribute in protocol is mutable.
Does not reject covariant attribute type when protocol attribute is mutable.
Does not detect protocol mismatch if concrete method is missing annotations.
Does not detect protocol mismatch if concrete method's parameters are keyword-only.
Does not detect protocol mismatch if concrete method's parameters are position-only.
Does not detect protocol mismatch if concrete method is a classmethod.
Does not detect protocol mismatch if concrete method is a staticmethod.
Does not reject read-only property in concrete class when protocol has settable property.
Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable.
Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable.
     protocols_explicitPartialReports errors for protocol static method with "..." implementation.
Does not report error when calling unimplemented protocol method from derived class.
Does not report type incompatibility when assigning to attribute defined in protocol.
Does not reject instantiation of class that derives from protocol but doesn't implement attribute.
Does not report instantiation of class that derives from protocol but doesn't implement method.
     protocols_genericPartialDoes not correctly enforce contravariance in protocol type compatibility tests.
Does not correctly enforce invariance in protocol type compatibility tests.
Does not detect protocol mismatch when method-scoped TypeVar is used in protocol.
     protocols_mergingPartialDoes not reject a protocol class that derives from a non-protocol class.
Does not report attempt to instantiate abstract class downgraded from protocol class.
     protocols_modulesPartialDoes not report incompatibilities for protocol methods.
     protocols_recursivePartialIncorrectly reports type error for some recursive protocols.
     protocols_runtime_checkableUnsupportedDoes not reject isinstance or issubclass call for protocol that is not runtime_checkable.
Does not reject issubclass call for data protocol.
Does not report unsafe overlap for runtime_checkable protocol.
     protocols_selfPartialDoes not properly handle Self type within a protocol.
     protocols_subtypingPartialDoes not reject attempt to instantiate protocol class.
Does not report some protocol type compatibility violations involving contravariance.
     protocols_varianceUnsupportedDoes not detect incorrect TypeVar variance within generic protocols.
-Callables
     callables_annotationPass
     callables_kwargsUnsupportedDoes not understand Unpack in the context of **kwargs annotation.
     callables_protocolUnsupportedDoes not properly handle type compatibility checks with callback protocols.
-Overloads
     overloads_basicPartialDoes not reject a function with a single @overload signature.
Does not reject a function with @overload signature but no implementation.
-Dataclasses
     dataclasses_descriptorsUnsupportedDoes not understand descriptor objects in dataclass.
     dataclasses_frozenUnsupportedDoes not report assignment to field within frozen dataclass instance.
Does not reject frozen dataclass inherited from non-frozen dataclass.
Does not reject non-frozen dataclass inherited from frozen dataclass.
     dataclasses_hashPartialDoes not report when dataclass is not compatible with Hashable protocol.
     dataclasses_inheritancePartialDoes not reject ClassVar that is overridden by instance variable.
Does not reject instance variable that is overridden by ClassVar.
     dataclasses_kwonlyPartialIncorrectly reports error when kw_only field has default value.
Incorrectly rejects kw_only field with default before positional field.
     dataclasses_orderPartialDoes not report type incompatibility with comparison operator.
     dataclasses_postinitPartialDoes not validate `__post_init__` method.
Reports incorrect error for incompatible `__post_init__` method override.
     dataclasses_slotsPartialDoes not report error when `slots=True` is used with `__slots__` definition.
Does not reject write to instance variable that is not defined in __slots__.
Incorrectly reports error when accessing `__slots__` when `slots=True`.
     dataclasses_transform_classUnsupportedDoes not understand @dataclass_transform.
     dataclasses_transform_fieldUnsupportedDoes not understand @dataclass_transform.
     dataclasses_transform_funcUnsupportedDoes not understand @dataclass_transform.
     dataclasses_transform_metaUnsupportedDoes not understand @dataclass_transform.
     dataclasses_usagePass
-Typed dictionaries
     typeddicts_alt_syntaxPartialDoes not reject use of variable as second argument to `TypedDict` call.
Does not report when name of TypedDict doesn't match assigned identifier name.
Does not support keyword-argument form of alternative syntax (deprecated in 3.11).
     typeddicts_class_syntaxPartialDoes not reject methods within TypedDict class.
Does not report when metaclass is provided.
Does not report when other keyword argument is provided.
     typeddicts_finalPass
     typeddicts_inheritancePass
     typeddicts_operationsPartialDoes not report type violation with TypedDict value assignment.
Does not report reference to unknown key in TypedDict.
Does not reject `clear` method on TypedDict with required keys.
Does not reject delete operation for required key in TypedDict.
     typeddicts_requiredPartialDoes not reject use of `Required` in non-TypedDict class.
Does not reject use of `Required` in function parameter annotation.
Does not reject nested use of `Required` in type annotation.
     typeddicts_type_consistencyPartialDoes not report some type violations for TypedDict type compatibility.
Incorrectly reports type violation in cases where there is none.
Does not report type incompatibility between TypedDict and `dict[str, Any]`.
     typeddicts_usagePartialDoes not report errant use of TypedDict in `isinstance` call.
Does not reject use of TypedDict as TypeVar bound.
-Type narrowing
     narrowing_typeguardPartialDoes not reject TypeGuard method with too few parameters.
-Type checker directives
     directives_assert_typePass
     directives_castPartialDoes not reject a call to "cast" with additional arguments.
     directives_no_type_checkUnsupportedDoes not honor @no_type_check decorator.
     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.
+
 
mypy 1.8.0
1.32sec
pyright 1.1.345
1.32sec
pyre 0.9.19
2.21sec
pytype 2023.12.18
26.06sec
Type annotations
     annotations_coroutinesPassPass
Partial

Does not evaluate correct type for async function.

Partial

Does not evaluate correct type for async function.

     annotations_forward_refs
Partial

Does 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.

Pass
Partial

Does 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.

Partial

Does 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_generators
Partial

Does not report incompatible Generator type in `yield from` statement.

Pass
Partial

Does not report invalid return type for generator when function implicitly returns None.

Incorrectly evaluates type of call to async generator.

Partial

Does 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_methodsPassPassPassPass
     annotations_typeexprPassPassPass
Partial

Does 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.

Special types in annotations
     specialtypes_anyPassPass
Partial

Does not treat missing type argument as Any in generic type.

Does not support Any as a base class.

Pass
     specialtypes_never
Partial

Does not reject NoReturn when used outside of return type annotation.

Partial

Does not reject NoReturn when used outside of return type annotation.

Partial

Does not reject NoReturn when used outside of return type annotation.

Does not treat Never as compatible with all other types.

Unsupported

Does not understand NoReturn or Never.

     specialtypes_nonePassPass
Partial

Does not correctly handle type annotation type[None].

Partial

Does not detect type incompatibility between None and type[None].

Does not detect type incompatibility between None and incompatible protocol.

     specialtypes_promotionsPassPass
Partial

Does not reject use of attribute that is compatible only with float.

Pass
     specialtypes_tuplePassPass
Partial

Does not report type violation when assigning tuple[T, ...] to tuple[T].

Partial

Does not report type violation when assigning tuple[T, ...] to tuple[T].

     specialtypes_tuple_unpackPassPass
Unsupported

Does not support unpacked tuple in type expression.

Unsupported

Does not support unpacked tuple in type expression.

     specialtypes_type
Partial

Does not treat `type` same as `type[Any]` for assert_type.

Does not allow access to unknown attributes from object of type `type[Any]`.

Partial

Does not reject Callable when passed to type[T].

Partial

Does not reject Callable when passed to type[T].

Does not treat `type` same as `type[Any]` for assert_type.

Does not allow access to unknown attributes from object of type `type[Any]`.

Does not reject access to unknown attributes from object of type `Type[object]`.

Reports type incompatibility between `type` and `Callable[..., Any]`.

Partial

Does not reject Callable when passed to type[T].

Does not allow access to known attributes from object of type `type[Any]`.

Generics
     generics_paramspec_basic
Partial

Does not reject ParamSpec when used "bare" in type alias definition.

Pass
Partial

Does not enforce name consistency for ParamSpec assigned to identifier.

Incorrectly reports error for legitimate use of ParamSpec in generic type alias.

Does not reject ParamSpec when used in various invalid locations.

Unsupported

Does not support ParamSpec.

     generics_paramspec_components
Partial

Does not report illegal use of "P.args" on normal parameter.

Does not report error when P.args is specified but P.kwargs is missing.

Does not report error when P is out of scope and P.args and P.kwargs is used.

Does not report error when keyword argument is specified between P.args and P.kwargs.

Does not report error when calling callable and argument is missing for concatenated parameters.

Pass
Partial

Does not report illegal use of "P.args" on normal parameter.

Does not report error when P.args is specified but P.kwargs is missing.

Does not report error when P is out of scope and P.args and P.kwargs is used.

Does not report error when calling callback defined with ParamSpec with incorrect arguments.

Does not report error when keyword argument is specified between P.args and P.kwargs.

Does not report error when calling callable and argument is missing for concatenated parameters.

Unsupported

Does not support ParamSpec.

     generics_paramspec_semanticsPassPass
Partial

Constraint solver doesn't find common type for two signatures captured by a single ParamSpec (allowed).

Reports error for legitimate Callable type annotation that uses Concatenate.

Does not evaluate the correct type for call of Callable defined with Concatenate.

Unsupported

Does not support ParamSpec.

     generics_paramspec_specializationPassPass
Partial

Reports error for legitimate use of ParamSpec and Concatenate in function signature.

Reports error for legitimate specialization of generic class parameterized with ParamSpec.

Unsupported

Does not support ParamSpec.

     generics_self_advanced
Partial

Does not infer the type of an unannotated `self` parameter to be type `Self`.

Does not retain `Self` when calling method that returns `Self`.

Does not infer the type of an unannotated `cls` parameter to be type `type[Self]`.

Does not retain `Self` when accessing attribute through `type[Self]`.

Pass
Unsupported

Does not understand `Self` type.

Unsupported

Does not understand `Self` type.

     generics_self_attributesPassPass
Unsupported

Does not understand `Self` type.

Unsupported

Does not understand `Self` type.

     generics_self_basic
Partial

Does not properly handle constructor call through `cls` parameter.

Pass
Unsupported

Does not understand `Self` type.

Unsupported

Does not understand `Self` type.

     generics_self_protocolsPassPass
Partial

Does not reject protocol compatibility due to method `Self` return type.

Partial

Does not reject protocol compatibility due to method `Self` return type.

     generics_self_usagePassPass
Unsupported

Does not understand `Self` type.

Unsupported

Does not understand `Self` type.

     generics_syntax_compatibility
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

     generics_syntax_declarations
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

     generics_syntax_infer_variance
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

     generics_syntax_scoping
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

     generics_typevartuple_args
Partial

Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).

Partial

Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).

Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_basic
Partial

Does not enforce that tuples captured by TypeVarTuple are same length (spec bug?).

Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).

Does not enforce that tuples captured by TypeVarTuple are invariant in non-tuple class.

Partial

Does not enforce that tuples captured by TypeVarTuple are same length (spec bug?).

Does not enforce that tuples captured by TypeVarTuple are same type (spec bug?).

Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_callablePassPass
Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_concatPassPass
Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_overloadsPassPass
Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_specialization
Partial

Incorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.

Incorrectly specializes generic alias that includes a TypeVar and TypeVarTuple if no type arguments are provided.

Rejects use of unpacked TypeVarTuple in generic type alias definition.

Rejects specialization of generic type alias defined as a tuple containing a TypeVar.

"More than one Unpack" error message has no line number.

Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.

Partial

Incorrectly reports type incompatibility when generic class is specialized with `*tuple[Any, ...]`.

Incorrectly evaluates tuple split across a TypeVarTuple and a TypeVar.

Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_typevartuple_unpack
Partial

Does not reject multiple unpack operators in a tuple.

Partial

Does not treat `tuple[Any, ...]` as having an arbitrary length.

Unsupported

Does not support TypeVarTuple.

Unsupported

Does not support TypeVarTuple.

     generics_variance
Partial

Does not reject a function-scoped TypeVar that is marked as covariant or contravariant.

Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.

Partial

Does not reject a function-scoped TypeVar that is marked as covariant or contravariant.

Partial

Does not reject a TypeVar that is defined as both covariant and contravariant.

Does not reject a function-scoped TypeVar that is marked as covariant or contravariant.

Does not reject use of class-scoped TypeVar used in a base class when variance is incompatible.

Unsupported

Does not support covariant or contravariant TypeVars.

     generics_variance_inference
Unsupported

Type parameter syntax not yet support.

Pass
Unsupported

Type parameter syntax not yet support.

Unsupported

Type parameter syntax not yet support.

Type qualifiers
     qualifiers_annotated
Partial

Does not allow ClassVar to be nested within Annotated.

Does not allow Final to be nested within Annotated.

Does not allow Required and NotRequired to be nested within Annotated.

Pass
Partial

Does not reject Annotated with a single parameter.

Partial

Does not reject some illegal type expression forms used in Annotated.

Does not allow TypeVar to be used in type alias when wrapped with Annotated.

     qualifiers_final_annotation
Partial

Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.

Does not allow conditional assignment of Final instance variable in __init__ method.

Does not allow redefinition of private class variable that is marked Final in parent class.

Does not report modification of local Final variable via "for" statement.

Pass
Partial

Does not report Final variable with missing initialization in module scope.

Does not report error for invalid nesting of Final and ClassVar.

Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.

Partial

Does not report Final variable with missing initialization.

Does not reject Final instance variable declared outside of __init__ method.

Does not reject modification of global variable declared Final.

Does not reject modification of local variable declared Final.

     qualifiers_final_decoratorPassPass
Partial

Reports error for overloaded method implementation marked @final if its overloads do not.

Does not report error for overloaded @final method defined in stub file.

Reports misleading error when overload is marked @final but implementation is not.

Partial

Does not report error for overloaded @final method defined in stub file.

Does not report error for overload that is marked @final when implementation is not.

Class type compatibility
     classes_classvar
Partial

Internal error if TypeVarTuple is used in ClassVar.

Does not reject use of ParamSpec in ClassVar.

Rejects ClassVar nested in Annotated.

Does not reject use of ClassVar in TypeAlias definition.

Does not infer type of ClassVar from assignment if no type is provided.

Pass
Partial

Does not reject use of TypeVar in ClassVar.

Does not reject use of ParamSpec in ClassVar.

Does not reject use of ClassVar as a generic type argument.

Does not reject use of ClassVar in parameter type annotation.

Does not reject use of ClassVar in local variable annotation.

Does not reject use of ClassVar in instance variable annotation.

Does not reject use of ClassVar in return type annotation.

Does not reject use of ClassVar in type alias definition.

Partial

Does not reject use of TypeVar in ClassVar.

Does not reject use of ParamSpec in ClassVar.

Does not reject use of ClassVar as a generic type argument.

Rejects initialization of ClassVar if no type argument is provided.

Does not reject use of ClassVar in parameter type annotation.

Does not reject use of ClassVar in local variable annotation.

Does not reject use of ClassVar in instance variable annotation.

Does not reject use of ClassVar in return type annotation.

Does not reject use of ClassVar in type alias definition.

Does not reject assignment of ClassVar through instance of class.

     classes_override
Partial

Does not handle case where parent class derives from Any.

Pass
Unsupported

Does not yet support the @override decorator.

Unsupported

Does not yet support the @override decorator.

Type aliases
     aliases_explicit
Partial

Does not reject specialization of type alias that has already been implicitly specialized.

Pass
Partial

Incorrectly reports error for type alias defined with ParamSpec.

Incorrectly rejects some valid type aliases when used in annotations.

Incorrectly evaluates generic type alias with ParamSpec with missing type argument.

Does not report some illegal annotation forms as invalid type aliases.

Does not report invalid specialization of generic type aliases.

Incorrectly rejects import alias of `TypeAlias` when used to define type alias.

Does not report invalid specialization of already-specialized generic type alias.

Partial

Incorrectly reports error for type alias defined with ParamSpec.

Does not report invalid specialization of generic type alias with bound TypeVar.

Incorrectly evaluates generic type alias with ParamSpec with missing type argument.

Does not report some illegal annotation forms as invalid type aliases.

Does not report invalid specialization of already-specialized generic type alias.

     aliases_implicitPassPass
Partial

Incorrectly reports error for type alias defined with ParamSpec.

Incorrectly rejects some valid type aliases when used in annotations.

Incorrectly evaluates generic type alias with ParamSpec with missing type argument.

Does not report invalid specialization of generic type aliases.

Does not report error for attempt to instantiate union type alias.

Does not report invalid specialization of already-specialized generic type alias.

Partial

Incorrectly reports error for type alias defined with ParamSpec.

Does not report invalid specialization of generic type alias with bound TypeVar.

Incorrectly evaluates generic type alias with ParamSpec with missing type argument.

Allows some illegal annotation forms to be interpreted as valid type aliases.

Does not report invalid specialization of already-specialized generic type alias.

     aliases_newtypePassPass
Partial

Does not reject use of NewType in `isinstance` call.

Does not reject use of NewType in class definition statement.

Does not report inconsistency between name of NewType and assigned identifier name.

Does not reject use of NewType with generic class with TypeVar.

Does not reject use of NewType with protocol class.

Does not reject use of NewType with TypedDict class.

Does not reject use of NewType with another NewType.

Does not reject use of NewType with Any.

Partial

Does not reject use of NewType in `isinstance` call.

Does not reject use of NewType in class definition statement.

Does not report inconsistency between name of NewType and assigned identifier name.

Does not reject use of NewType with generic class with TypeVar.

Does not reject use of NewType with protocol class.

Does not reject use of NewType with TypedDict class.

Does not reject use of NewType with another NewType.

Does not reject use of NewType with Any.

     aliases_recursivePassPass
Partial

Does not properly handle some recursive type aliases.

Does not properly handle specialization of generic recursive type aliases.

Partial

Does not detect type violation for some deeply-nested types.

Does not properly handle `|` for unions in some recursive type alias definitions.

Does not detect cyclical references in recursive type alias definition.

     aliases_type_statement
Unsupported

Does not support `type` statement.

Pass
Unsupported

Does not support `type` statement.

Unsupported

Does not support `type` statement.

     aliases_typealiastype
Unsupported

Support for TypeAliasType is not implemented.

Pass
Unsupported

Support for TypeAliasType is not implemented.

Unsupported

Support for TypeAliasType is not implemented.

     aliases_variancePassPassPass
Unsupported

Does not detect variance incompatibility.

Literals
     literals_interactions
Partial

Does not narrow type of `x` with `x in Literal` type guard pattern.

Pass
Partial

Does not detect out-of-bound tuple literal index.

Does not narrow type of `x` with `x in Literal` type guard pattern.

Does not narrow type of `x` with `x == Literal` type guard pattern.

Partial

Incorrectly rejects some legal Literal annotations.

Does not reject some illegal Literal annotations.

Does not use Literal to distinguish overloads.

Does not narrow based on `x is Literal` type guard pattern.

Does not narrow based on `x == Literal` type guard pattern.

     literals_literalstring
Unsupported

Support for `LiteralString` is not implemented.

PassPass
Unsupported

Does not understand `LiteralString` special form.

     literals_parameterizations
Partial

Does not reject tuple within Literal.

Pass
Partial

Does not support type aliases in Literal type expression.

Does not support nested Literal type expression.

Does not reject unary + operator in Literal type expression.

Does not reject tuple in Literal type expression.

Does not reject "bare" Literal in type expression.

Unsupported

Does not understand `Literal` type annotation.

     literals_semanticsPassPass
Partial

Does not reject augmented operation that modifies literal value.

Unsupported

Does not understand `Literal` type annotation.

Protocols
     protocols_class_objectsPass
Partial

Incorrectly reports some class objects as incompatible with a protocol.

Fails to report some class objects as incompatible with a protocol.

Partial

Does not reject protocol class assigned to type[Proto].

Incorrectly reports some class objects as incompatible with a protocol.

Fails to report some class objects as incompatible with a protocol.

Partial

Does not reject protocol class assigned to type[Proto].

Incorrectly reports some class objects as incompatible with a protocol.

Fails to report some class objects as incompatible with a protocol.

     protocols_definition
Partial

Does not detect protocol mismatch if concrete method is missing annotations.

Does not detect protocol mismatch if concrete method's parameters are position-only.

Pass
Partial

Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar or vice versa.

Does not reject read-only property in concrete class when attribute in protocol is mutable.

Does not reject covariant attribute type when protocol attribute is mutable.

Does not reject read-only property in concrete class when protocol has settable property.

Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable.

Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable.

Partial

Reports errors for protocol static method with "..." implementation.

Does not report error when instance variable is set through "self" access in protocol class.

Does not report protocol mismatch when concrete class has attribute with covariant type and protocol attribute is mutable.

Does not reject ClassVar in concrete class when attribute in protocol is not ClassVar.

Does not reject read-only property in concrete class when attribute in protocol is mutable.

Does not reject covariant attribute type when protocol attribute is mutable.

Does not detect protocol mismatch if concrete method is missing annotations.

Does not detect protocol mismatch if concrete method's parameters are keyword-only.

Does not detect protocol mismatch if concrete method's parameters are position-only.

Does not detect protocol mismatch if concrete method is a classmethod.

Does not detect protocol mismatch if concrete method is a staticmethod.

Does not reject read-only property in concrete class when protocol has settable property.

Does not reject immutable named tuple attribute in concrete class when protocol attribute is mutable.

Does not reject immutable frozen dataclass attribute in concrete class when protocol attribute is mutable.

     protocols_explicitPassPass
Partial

Does not report error when calling unimplemented protocol method from derived class.

Does not report error when method is not implemented in derived class.

Partial

Reports errors for protocol static method with "..." implementation.

Does not report error when calling unimplemented protocol method from derived class.

Does not report type incompatibility when assigning to attribute defined in protocol.

Does not reject instantiation of class that derives from protocol but doesn't implement attribute.

Does not report instantiation of class that derives from protocol but doesn't implement method.

     protocols_generic
Partial

Fails protocol matching when method-scoped TypeVar is used in protocol.

Pass
Partial

Does not reject the use of Protocol and Generic together as base classes.

Does not detect protocol mismatch when method-scoped TypeVar is used in protocol.

Partial

Does not correctly enforce contravariance in protocol type compatibility tests.

Does not correctly enforce invariance in protocol type compatibility tests.

Does not detect protocol mismatch when method-scoped TypeVar is used in protocol.

     protocols_mergingPassPass
Partial

Does not reject a protocol class that derives from a non-protocol class.

Partial

Does not reject a protocol class that derives from a non-protocol class.

Does not report attempt to instantiate abstract class downgraded from protocol class.

     protocols_modulesPassPass
Unsupported

Does not perform protocol checks for modules.

Partial

Does not report incompatibilities for protocol methods.

     protocols_recursivePassPassPass
Partial

Incorrectly reports type error for some recursive protocols.

     protocols_runtime_checkable
Partial

Does not report unsafe overlap for runtime_checkable protocol.

Partial

Does not reject issubclass call for data protocol if included in tuple.

Unsupported

Does not reject isinstance or issubclass call for protocol that is not runtime_checkable.

Does not reject issubclass call for data protocol.

Does not report unsafe overlap for runtime_checkable protocol.

Unsupported

Does not reject isinstance or issubclass call for protocol that is not runtime_checkable.

Does not reject issubclass call for data protocol.

Does not report unsafe overlap for runtime_checkable protocol.

     protocols_selfPassPassPass
Partial

Does not properly handle Self type within a protocol.

     protocols_subtypingPassPassPass
Partial

Does not reject attempt to instantiate protocol class.

Does not report some protocol type compatibility violations involving contravariance.

     protocols_variancePass
Partial

Calculates incorrect variance when `self` or `cls` have explicit annotation.

Unsupported

Does not detect incorrect TypeVar variance within generic protocols.

Unsupported

Does not detect incorrect TypeVar variance within generic protocols.

Callables
     callables_annotationPassPass
Partial

Does not evaluate correct type for `*args: int` parameter.

Does not reject illegal form `Callable[[...], int]`.

Pass
     callables_kwargsPassPass
Unsupported

Does not understand Unpack in the context of **kwargs annotation.

Unsupported

Does not understand Unpack in the context of **kwargs annotation.

     callables_protocolPassPass
Partial

Does not correctly handle callback protocol that declares attributes in all functions.

Does not report type incompatibility for callback protocol with positional-only parameters.

Incorrectly reports type compatibility error with callback that has *args and **kwargs.

Does not report type incompatibility for callback missing a default argument for positional parameter.

Does not report type incompatibility for callback missing a default argument for keyword parameter.

Unsupported

Does not properly handle type compatibility checks with callback protocols.

Overloads
     overloads_basicPassPass
Partial

Does not reject a function with a single @overload signature.

Partial

Does not reject a function with a single @overload signature.

Does not reject a function with @overload signature but no implementation.

Dataclasses
     dataclasses_descriptors
Partial

Does not correctly evaluate type of descriptor access.

Pass
Partial

Incorrectly generates error when calling constructor of dataclass with descriptor.

Unsupported

Does not understand descriptor objects in dataclass.

     dataclasses_frozenPassPass
Partial

Does not reject frozen dataclass inherited from non-frozen dataclass.

Does not reject non-frozen dataclass inherited from frozen dataclass.

Unsupported

Does not report assignment to field within frozen dataclass instance.

Does not reject frozen dataclass inherited from non-frozen dataclass.

Does not reject non-frozen dataclass inherited from frozen dataclass.

     dataclasses_hash
Partial

Does not report when dataclass is not compatible with Hashable protocol.

Pass
Partial

Does not report when dataclass is not compatible with Hashable protocol.

Partial

Does not report when dataclass is not compatible with Hashable protocol.

     dataclasses_inheritancePassPass
Partial

Does not reject ClassVar that is overridden by instance variable.

Does not reject instance variable that is overridden by ClassVar.

Partial

Does not reject ClassVar that is overridden by instance variable.

Does not reject instance variable that is overridden by ClassVar.

     dataclasses_kwonly
Partial

Incorrectly rejects kw_only field with default before positional field.

PassPass
Partial

Incorrectly reports error when kw_only field has default value.

Incorrectly rejects kw_only field with default before positional field.

     dataclasses_orderPassPass
Partial

Does not report type incompatibility with comparison operator.

Partial

Does not report type incompatibility with comparison operator.

     dataclasses_postinitPassPass
Unsupported

Does not perform validation of `__post_init__` method.

Does not reject access of `InitVar` from object.

Partial

Does not validate `__post_init__` method.

Reports incorrect error for incompatible `__post_init__` method override.

     dataclasses_slots
Partial

Does not reject write to instance variable that is not defined in __slots__.

Pass
Partial

Does not report error when `slots=True` is used with `__slots__` definition.

Does not reject write to instance variable that is not defined in __slots__.

Does not reject access to `__slots__` from dataclass instance when `slots=False`.

Partial

Does not report error when `slots=True` is used with `__slots__` definition.

Does not reject write to instance variable that is not defined in __slots__.

Incorrectly reports error when accessing `__slots__` when `slots=True`.

     dataclasses_transform_classPassPass
Unsupported

Does not understand @dataclass_transform.

Unsupported

Does not understand @dataclass_transform.

     dataclasses_transform_field
Partial

Does not properly handle field constructor that has default value for `kw_only` or `init` parameter.

Pass
Unsupported

Does not understand @dataclass_transform.

Unsupported

Does not understand @dataclass_transform.

     dataclasses_transform_func
Partial

Does not handle `kw_only=False` override when `kw_only_default=True`.

Does not report error when `order=False` and comparison operators are used.

Pass
Unsupported

Does not understand @dataclass_transform.

Unsupported

Does not understand @dataclass_transform.

     dataclasses_transform_metaPassPass
Unsupported

Does not understand @dataclass_transform.

Unsupported

Does not understand @dataclass_transform.

     dataclasses_usagePassPass
Partial

Does not report error when field with no default follows field with default.

Incorrectly reports error with InitVar that has default value.

Pass
Typed dictionaries
     typeddicts_alt_syntaxPassPass
Partial

Does not report when name of TypedDict doesn't match assigned identifier name.

Does not support keyword-argument form of alternative syntax (deprecated in 3.11).

Partial

Does not reject use of variable as second argument to `TypedDict` call.

Does not report when name of TypedDict doesn't match assigned identifier name.

Does not support keyword-argument form of alternative syntax (deprecated in 3.11).

     typeddicts_class_syntaxPassPass
Partial

Does not reject methods within TypedDict class.

Does not report when metaclass is provided.

Does not report when other keyword argument is provided.

Does not support generic TypedDict class.

Partial

Does not reject methods within TypedDict class.

Does not report when metaclass is provided.

Does not report when other keyword argument is provided.

     typeddicts_finalPassPass
Partial

Does not handle value with literal type as index to TypedDict object.

Pass
     typeddicts_inheritancePassPass
Partial

Does not reject TypedDict class that inherits from non-TypedDict class.

Pass
     typeddicts_operationsPassPassPass
Partial

Does not report type violation with TypedDict value assignment.

Does not report reference to unknown key in TypedDict.

Does not reject `clear` method on TypedDict with required keys.

Does not reject delete operation for required key in TypedDict.

     typeddicts_required
Partial

Does not support nesting of `Annotated` and `Required` or `NotRequired`.

Pass
Partial

Does not reject use of `Required` in function parameter annotation.

Does not reject nested use of `Required` in type annotation.

Does not support recursive TypedDict definitions.

Partial

Does not reject use of `Required` in non-TypedDict class.

Does not reject use of `Required` in function parameter annotation.

Does not reject nested use of `Required` in type annotation.

     typeddicts_type_consistencyPassPass
Partial

Does not reject assignment of TypedDict with missing key.

Does not return non-Optional value from `get` method for required key.

Does not properly handle nested TypedDicts.

Partial

Does not report some type violations for TypedDict type compatibility.

Incorrectly reports type violation in cases where there is none.

Does not report type incompatibility between TypedDict and `dict[str, Any]`.

     typeddicts_usagePassPass
Partial

Does not report errant use of TypedDict in `isinstance` call.

Does not reject use of TypedDict as TypeVar bound.

Partial

Does not report errant use of TypedDict in `isinstance` call.

Does not reject use of TypedDict as TypeVar bound.

Type narrowing
     narrowing_typeguardPassPass
Partial

Does not support `tuple` in `assert_type` call.

Does not reject TypeGuard method with too few parameters.

Partial

Does not reject TypeGuard method with too few parameters.

Type checker directives
     directives_assert_typePassPass
Unsupported

Does not understand "assert_type".

Pass
     directives_castPassPassPass
Partial

Does not reject a call to "cast" with additional arguments.

     directives_no_type_check
Partial

Does not honor `@no_type_check` class decorator.

Unsupported

Intentionally does not honor @no_type_check decorator.

Unsupported

Does not honor @no_type_check decorator.

Unsupported

Does not honor @no_type_check decorator.

     directives_reveal_typePassPass
Unsupported

Does not understand reveal_type call.

Partial

Does not reject call to reveal_type with zero arguments.

Does not reject call to reveal_type with too many arguments.

     directives_type_checkingPassPassPassPass
     directives_type_ignore
Partial

Does not honor "# type: ignore" comment if comment includes additional text.

PassPass
Partial

Does not honor "# type: ignore" comment if comment includes additional text.

     directives_type_ignore_file1PassPass
Unsupported

Does not support file-level `#type: ignore` comment.

Pass
     directives_type_ignore_file2PassPassPass
Partial

Does not ignore `# type: ignore` if it occurs after docstrings in the file.

     directives_version_platformPassPass
Partial

Does not support sys.platform checks.

Does not support os.name checks.

Pass