diff --git a/conformance/results/mypy/aliases_newtype.toml b/conformance/results/mypy/aliases_newtype.toml index ed1e9a0d..e1c8c64a 100644 --- a/conformance/results/mypy/aliases_newtype.toml +++ b/conformance/results/mypy/aliases_newtype.toml @@ -1,21 +1,25 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +`NewType`s are considered classes, not functions. +""" output = """ aliases_newtype.py:11: error: Argument 1 to "UserId" has incompatible type "str"; expected "int" [arg-type] aliases_newtype.py:12: error: Incompatible types in assignment (expression has type "int", variable has type "UserId") [assignment] -aliases_newtype.py:20: error: Cannot use isinstance() with NewType type [misc] -aliases_newtype.py:23: error: Cannot subclass "NewType" [misc] -aliases_newtype.py:32: error: String argument 1 "BadName" to NewType(...) does not match variable name "GoodName" [misc] -aliases_newtype.py:38: error: "GoodNewType1" expects no type arguments, but 1 given [type-arg] -aliases_newtype.py:44: error: Argument 2 to NewType(...) must be subclassable (got "int | str") [valid-newtype] -aliases_newtype.py:47: error: Type variable "aliases_newtype.T" is unbound [valid-type] -aliases_newtype.py:47: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) -aliases_newtype.py:47: note: (Hint: Use "T" in function signature to bind "T" inside a function) -aliases_newtype.py:49: error: NewType cannot be used with protocol classes [misc] -aliases_newtype.py:51: error: Argument 2 to NewType(...) must be subclassable (got "Literal[7]") [valid-newtype] -aliases_newtype.py:58: error: Argument 2 to NewType(...) must be subclassable (got "TD1") [valid-newtype] -aliases_newtype.py:60: error: NewType(...) expects exactly two positional arguments [misc] -aliases_newtype.py:62: error: Argument 2 to NewType(...) must be subclassable (got "Any") [valid-newtype] +aliases_newtype.py:23: error: Cannot use isinstance() with NewType type [misc] +aliases_newtype.py:26: error: Cannot subclass "NewType" [misc] +aliases_newtype.py:35: error: String argument 1 "BadName" to NewType(...) does not match variable name "GoodName" [misc] +aliases_newtype.py:41: error: "GoodNewType1" expects no type arguments, but 1 given [type-arg] +aliases_newtype.py:47: error: Argument 2 to NewType(...) must be subclassable (got "int | str") [valid-newtype] +aliases_newtype.py:50: error: Type variable "aliases_newtype.T" is unbound [valid-type] +aliases_newtype.py:50: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) +aliases_newtype.py:50: note: (Hint: Use "T" in function signature to bind "T" inside a function) +aliases_newtype.py:52: error: NewType cannot be used with protocol classes [misc] +aliases_newtype.py:54: error: Argument 2 to NewType(...) must be subclassable (got "Literal[7]") [valid-newtype] +aliases_newtype.py:61: error: Argument 2 to NewType(...) must be subclassable (got "TD1") [valid-newtype] +aliases_newtype.py:63: error: NewType(...) expects exactly two positional arguments [misc] +aliases_newtype.py:65: error: Argument 2 to NewType(...) must be subclassable (got "Any") [valid-newtype] """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 18: Expected 1 errors """ diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index 41659210..192bb6fb 100644 --- a/conformance/results/mypy/version.toml +++ b/conformance/results/mypy/version.toml @@ -1,2 +1,2 @@ version = "mypy 1.15.0" -test_duration = 1.5 +test_duration = 1.4 diff --git a/conformance/results/pyright/aliases_newtype.toml b/conformance/results/pyright/aliases_newtype.toml index 256c1361..a0a12c0c 100644 --- a/conformance/results/pyright/aliases_newtype.toml +++ b/conformance/results/pyright/aliases_newtype.toml @@ -1,22 +1,26 @@ -conformant = "Pass" +conformant = "Partial" +notes = """ +`NewType`s are considered classes, not functions. +""" output = """ aliases_newtype.py:11:8 - error: Argument of type "Literal['user']" cannot be assigned to parameter "_x" of type "int" in function "__init__"   "Literal['user']" is not assignable to "int" (reportArgumentType) aliases_newtype.py:12:14 - error: Type "Literal[42]" is not assignable to declared type "UserId"   "Literal[42]" is not assignable to "UserId" (reportAssignmentType) -aliases_newtype.py:20:16 - error: Second argument to "isinstance" must be a class or tuple of classes +aliases_newtype.py:23:16 - error: Second argument to "isinstance" must be a class or tuple of classes   Class created with NewType cannot be used with instance and class checks (reportArgumentType) -aliases_newtype.py:23:21 - error: Base class "UserId" is marked final and cannot be subclassed (reportGeneralTypeIssues) -aliases_newtype.py:32:1 - error: NewType must be assigned to a variable with the same name (reportGeneralTypeIssues) -aliases_newtype.py:38:19 - error: Expected no type arguments for class "GoodNewType1" (reportInvalidTypeArguments) -aliases_newtype.py:44:38 - error: Expected class as second argument to NewType (reportGeneralTypeIssues) -aliases_newtype.py:47:43 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) -aliases_newtype.py:49:38 - error: NewType cannot be used with structural type (a Protocol or TypedDict class) (reportGeneralTypeIssues) -aliases_newtype.py:51:38 - error: NewType cannot be used with Literal type (reportGeneralTypeIssues) -aliases_newtype.py:58:38 - error: NewType cannot be used with structural type (a Protocol or TypedDict class) (reportGeneralTypeIssues) -aliases_newtype.py:60:15 - error: NewType requires two positional arguments (reportCallIssue) -aliases_newtype.py:62:38 - error: The second argument to NewType must be a known class, not Any or Unknown (reportGeneralTypeIssues) +aliases_newtype.py:26:21 - error: Base class "UserId" is marked final and cannot be subclassed (reportGeneralTypeIssues) +aliases_newtype.py:35:1 - error: NewType must be assigned to a variable with the same name (reportGeneralTypeIssues) +aliases_newtype.py:41:19 - error: Expected no type arguments for class "GoodNewType1" (reportInvalidTypeArguments) +aliases_newtype.py:47:38 - error: Expected class as second argument to NewType (reportGeneralTypeIssues) +aliases_newtype.py:50:43 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues) +aliases_newtype.py:52:38 - error: NewType cannot be used with structural type (a Protocol or TypedDict class) (reportGeneralTypeIssues) +aliases_newtype.py:54:38 - error: NewType cannot be used with Literal type (reportGeneralTypeIssues) +aliases_newtype.py:61:38 - error: NewType cannot be used with structural type (a Protocol or TypedDict class) (reportGeneralTypeIssues) +aliases_newtype.py:63:15 - error: NewType requires two positional arguments (reportCallIssue) +aliases_newtype.py:65:38 - error: The second argument to NewType must be a known class, not Any or Unknown (reportGeneralTypeIssues) """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 18: Expected 1 errors """ diff --git a/conformance/results/pyright/aliases_typealiastype.toml b/conformance/results/pyright/aliases_typealiastype.toml index 732bebde..e0f4a8c9 100644 --- a/conformance/results/pyright/aliases_typealiastype.toml +++ b/conformance/results/pyright/aliases_typealiastype.toml @@ -31,8 +31,8 @@ aliases_typealiastype.py:61:42 - error: Expected class but received "Literal[Tru aliases_typealiastype.py:62:42 - error: Expected class but received "Literal[1]" (reportGeneralTypeIssues) aliases_typealiastype.py:63:42 - error: Binary operator not allowed in type expression (reportInvalidTypeForm) aliases_typealiastype.py:64:42 - error: Type expressions cannot use format string literals (f-strings) (reportGeneralTypeIssues) +aliases_typealiastype.py:66:47 - error: "BadAlias21" is not defined (reportUndefinedVariable) """ -conformance_automated = "Fail" +conformance_automated = "Pass" errors_diff = """ -Line 66: Expected 1 errors """ diff --git a/conformance/results/pyright/callables_protocol.toml b/conformance/results/pyright/callables_protocol.toml index 47af0047..82afbb4c 100644 --- a/conformance/results/pyright/callables_protocol.toml +++ b/conformance/results/pyright/callables_protocol.toml @@ -32,11 +32,10 @@ callables_protocol.py:70:7 - error: Type "(**b: str) -> None" is not assignable   Type "(**b: str) -> None" is not assignable to type "(*vals: bytes, **kwargs: str) -> None"     Parameter "*vals" has no corresponding parameter (reportAssignmentType) callables_protocol.py:97:16 - error: Type "(x: int) -> None" is not assignable to declared type "Proto4" -  "function" is incompatible with protocol "Proto4" -    "other_attribute" is not present -    "__call__" is not present (reportAssignmentType) +  "FunctionType" is incompatible with protocol "Proto4" +    "other_attribute" is not present (reportAssignmentType) callables_protocol.py:121:18 - error: Type "(*vals: bytes, max_len: int | None = None) -> list[bytes]" is not assignable to declared type "NotProto6" -  "function" is not assignable to "NotProto6" (reportAssignmentType) +  "FunctionType" is not assignable to "NotProto6" (reportAssignmentType) callables_protocol.py:169:7 - error: Type "(x: int) -> Any" is not assignable to declared type "Proto8"   One or more overloads of "__call__" is not assignable     Type "(x: int) -> Any" is not assignable to type "(x: str) -> str" diff --git a/conformance/results/pyright/generics_syntax_infer_variance.toml b/conformance/results/pyright/generics_syntax_infer_variance.toml index b23985d5..05f4c0d5 100644 --- a/conformance/results/pyright/generics_syntax_infer_variance.toml +++ b/conformance/results/pyright/generics_syntax_infer_variance.toml @@ -6,6 +6,12 @@ generics_syntax_infer_variance.py:29:35 - error: Type "ShouldBeCovariant1[float]   "ShouldBeCovariant1[float]" is not assignable to "ShouldBeCovariant1[int]"     Type parameter "T@ShouldBeCovariant1" is covariant, but "float" is not a subtype of "int"       "float" is not assignable to "int" (reportAssignmentType) +generics_syntax_infer_variance.py:36:37 - error: Cannot instantiate abstract class "ShouldBeCovariant2" +  "Collection.__len__" is not implemented +  "Sequence.__getitem__" is not implemented (reportAbstractUsage) +generics_syntax_infer_variance.py:37:35 - error: Cannot instantiate abstract class "ShouldBeCovariant2" +  "Collection.__len__" is not implemented +  "Sequence.__getitem__" is not implemented (reportAbstractUsage) generics_syntax_infer_variance.py:37:35 - error: Type "ShouldBeCovariant2[float]" is not assignable to declared type "ShouldBeCovariant2[int]"   "ShouldBeCovariant2[float]" is not assignable to "ShouldBeCovariant2[int]"     Type parameter "T@ShouldBeCovariant2" is covariant, but "float" is not a subtype of "int" @@ -57,6 +63,7 @@ generics_syntax_infer_variance.py:155:45 - error: Type "ShouldBeContravariant1[i     Type parameter "T@ShouldBeContravariant1" is contravariant, but "int" is not a supertype of "float"       "float" is not assignable to "int" (reportAssignmentType) """ -conformance_automated = "Pass" +conformance_automated = "Fail" errors_diff = """ +Line 36: Unexpected errors ['generics_syntax_infer_variance.py:36:37 - error: Cannot instantiate abstract class "ShouldBeCovariant2"'] """ diff --git a/conformance/results/pyright/protocols_definition.toml b/conformance/results/pyright/protocols_definition.toml index c27a3753..0ed86d0f 100644 --- a/conformance/results/pyright/protocols_definition.toml +++ b/conformance/results/pyright/protocols_definition.toml @@ -46,7 +46,7 @@ protocols_definition.py:160:22 - error: Type "Concrete3_Bad5" is not assignable protocols_definition.py:218:22 - error: Type "Concrete4_Bad1" is not assignable to declared type "Template4"   "Concrete4_Bad1" is incompatible with protocol "Template4"     "val1" is an incompatible type -      "function" is not assignable to "Sequence[float]" (reportAssignmentType) +      "FunctionType" is not assignable to "Sequence[float]" (reportAssignmentType) protocols_definition.py:219:22 - error: Type "Concrete4_Bad2" is not assignable to declared type "Template4"   "Concrete4_Bad2" is incompatible with protocol "Template4"     "val1" is not present (reportAssignmentType) diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index f105339d..e3b37052 100644 --- a/conformance/results/pyright/version.toml +++ b/conformance/results/pyright/version.toml @@ -1,2 +1,2 @@ -version = "pyright 1.1.400" -test_duration = 1.1 +version = "pyright 1.1.401" +test_duration = 1.0 diff --git a/conformance/results/results.html b/conformance/results/results.html index b881e237..c88562ed 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -159,13 +159,13 @@

Python Type System Conformance Test Results

- - - + + diff --git a/conformance/tests/aliases_newtype.py b/conformance/tests/aliases_newtype.py index 00add697..713b0bf8 100644 --- a/conformance/tests/aliases_newtype.py +++ b/conformance/tests/aliases_newtype.py @@ -14,6 +14,9 @@ assert_type(UserId(5) + 1, int) +# > NewType('Derived', Base) returns a dummy function +_: type = UserId # E: functions are not instances of `type` + # > Both isinstance and issubclass, as well as subclassing will fail for # > NewType('Derived', Base) since function objects don’t support these # > operations.
 
mypy 1.15.0
-
1.5sec
+
1.4sec
pyright 1.1.400
-
1.1sec
+
pyright 1.1.401
+
1.0sec
pyre 0.9.23
-
10.7sec
+
0.6sec
@@ -422,8 +422,8 @@

Python Type System Conformance Test Results

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.

     aliases_newtypePassPass
Partial

`NewType`s are considered classes, not functions.

Partial

`NewType`s are considered classes, not functions.

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

     aliases_recursive