Skip to content

Commit

Permalink
Merge branch 'main' into triple_quote
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum authored Jan 14, 2024
2 parents 15b38de + 4b7d0b7 commit edffeab
Show file tree
Hide file tree
Showing 19 changed files with 162 additions and 129 deletions.
18 changes: 10 additions & 8 deletions conformance/results/mypy/aliases_newtype.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ aliases_newtype.py:12: error: Incompatible types in assignment (expression has t
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:36: error: "GoodNewType1" expects no type arguments, but 1 given [type-arg]
aliases_newtype.py:42: error: Argument 2 to NewType(...) must be subclassable (got "int | str") [valid-newtype]
aliases_newtype.py:45: error: Type variable "aliases_newtype.T" is unbound [valid-type]
aliases_newtype.py:45: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
aliases_newtype.py:45: note: (Hint: Use "T" in function signature to bind "T" inside a function)
aliases_newtype.py:47: error: NewType cannot be used with protocol classes [misc]
aliases_newtype.py:49: error: Argument 2 to NewType(...) must be subclassable (got "Literal[7]") [valid-newtype]
aliases_newtype.py:56: error: Argument 2 to NewType(...) must be subclassable (got "TD1") [valid-newtype]
aliases_newtype.py:38: error: "GoodNewType1" expects no type arguments, but 1 given [type-arg]
aliases_newtype.py:41: error: Cannot redefine "GoodNewType2" as a NewType [misc]
aliases_newtype.py:41: error: Name "GoodNewType2" already defined on line 36 [no-redef]
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]
"""
22 changes: 12 additions & 10 deletions conformance/results/mypy/literals_parameterizations.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
conformant = "Partial"
notes = """
Rejects integer Literal with unary `+` operator.
Does not reject tuple within Literal.
"""
output = """
literals_parameterizations.py:40: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:20: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:41: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:42: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:43: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:44: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:46: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:47: error: Parameter 1 of Literal[...] is invalid [valid-type]
literals_parameterizations.py:45: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:47: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:48: error: Parameter 1 of Literal[...] is invalid [valid-type]
literals_parameterizations.py:49: error: Parameter 1 of Literal[...] is invalid [valid-type]
literals_parameterizations.py:50: error: Parameter 1 of Literal[...] cannot be of type "float" [valid-type]
literals_parameterizations.py:51: error: Parameter 1 of Literal[...] cannot be of type "Any" [valid-type]
literals_parameterizations.py:52: error: Parameter 1 of Literal[...] is invalid [valid-type]
literals_parameterizations.py:55: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:58: error: Literal[...] must have at least one parameter [valid-type]
literals_parameterizations.py:59: error: Parameter 1 of Literal[...] is invalid [valid-type]
literals_parameterizations.py:63: error: Incompatible types in assignment (expression has type "Literal[Color.RED]", variable has type "Literal['Color.RED']") [assignment]
literals_parameterizations.py:50: error: Parameter 1 of Literal[...] is invalid [valid-type]
literals_parameterizations.py:51: error: Parameter 1 of Literal[...] cannot be of type "float" [valid-type]
literals_parameterizations.py:52: error: Parameter 1 of Literal[...] cannot be of type "Any" [valid-type]
literals_parameterizations.py:53: error: Parameter 1 of Literal[...] is invalid [valid-type]
literals_parameterizations.py:56: error: Invalid type: Literal[...] cannot contain arbitrary expressions [valid-type]
literals_parameterizations.py:60: error: Literal[...] must have at least one parameter [valid-type]
literals_parameterizations.py:61: error: Parameter 1 of Literal[...] is invalid [valid-type]
literals_parameterizations.py:65: error: Incompatible types in assignment (expression has type "Literal[Color.RED]", variable has type "Literal['Color.RED']") [assignment]
"""
7 changes: 3 additions & 4 deletions conformance/results/pyre/aliases_newtype.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ Does not report inconsistency between name of NewType and assigned identifier na
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.
"""
output = """
aliases_newtype.py:11:7 Incompatible parameter type [6]: In call `UserId.__init__`, for 1st positional argument, expected `int` but got `str`.
aliases_newtype.py:12:0 Incompatible variable type [9]: u1 is declared to have type `UserId` but is used as type `int`.
aliases_newtype.py:36:5 Invalid type parameters [24]: Non-generic type `GoodNewType1` cannot take parameters.
aliases_newtype.py:42:37 Invalid inheritance [39]: `typing.Union[int, str]` is not a valid parent class.
aliases_newtype.py:49:37 Invalid inheritance [39]: `typing_extensions.Literal[7]` is not a valid parent class.
aliases_newtype.py:38:5 Invalid type parameters [24]: Non-generic type `GoodNewType1` cannot take parameters.
aliases_newtype.py:44:37 Invalid inheritance [39]: `typing.Union[int, str]` is not a valid parent class.
aliases_newtype.py:51:37 Invalid inheritance [39]: `typing_extensions.Literal[7]` is not a valid parent class.
aliases_newtype.py:60:14 Too many arguments [19]: Call `NewType.__init__` expects 2 positional arguments, 3 were provided.
aliases_newtype.py:62:37 Invalid inheritance [39]: `typing.Any` is not a valid parent class.
"""
41 changes: 21 additions & 20 deletions conformance/results/pyre/literals_parameterizations.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ Does not reject tuple in Literal type expression.
Does not reject "bare" Literal in type expression.
"""
output = """
literals_parameterizations.py:32:0 Invalid type [31]: Expression `AppendMode` is not a literal value.
literals_parameterizations.py:32:0 Invalid type [31]: Expression `ReadOnlyMode` is not a literal value.
literals_parameterizations.py:32:0 Invalid type [31]: Expression `WriteAndTruncateMode` is not a literal value.
literals_parameterizations.py:32:0 Invalid type [31]: Expression `WriteNoTruncateMode` is not a literal value.
literals_parameterizations.py:32:0 Undefined or invalid type [11]: Annotation `` is not defined as a type.
literals_parameterizations.py:34:8 Invalid type [31]: Expression `typing.Literal[(typing.Literal[(typing.Literal[(1, 2, 3)], "foo")], 5, None)]` is not a valid type.
literals_parameterizations.py:40:6 Invalid type [31]: Expression `typing.Literal[3.__add__(4)]` is not a valid type.
literals_parameterizations.py:41:6 Invalid type [31]: Expression `typing.Literal["foo".replace("o", "b")]` is not a valid type.
literals_parameterizations.py:42:6 Invalid type [31]: Expression `typing.Literal[4.__add__(3.000000j)]` is not a valid type.
literals_parameterizations.py:44:6 Invalid type [31]: Expression `typing.Literal[not False]` is not a valid type.
literals_parameterizations.py:46:6 Invalid type [31]: Expression `typing.Literal[{ "a":"b","c":"d" }]` is not a valid type.
literals_parameterizations.py:47:6 Invalid type [31]: Expression `typing.Literal[int]` is not a valid type.
literals_parameterizations.py:48:6 Invalid type [31]: Expression `variable` is not a literal value.
literals_parameterizations.py:49:7 Invalid type [31]: Expression `T` is not a literal value.
literals_parameterizations.py:50:7 Invalid type [31]: Expression `typing.Literal[3.140000]` is not a valid type.
literals_parameterizations.py:51:7 Invalid type [31]: Expression `Any` is not a literal value.
literals_parameterizations.py:52:7 Invalid type [31]: Expression `typing.Literal[...]` is not a valid type.
literals_parameterizations.py:55:19 Invalid type [31]: Expression `typing.Literal[1.__add__(2)]` is not a valid type.
literals_parameterizations.py:59:3 Invalid type [31]: Expression `my_function` is not a literal value.
literals_parameterizations.py:63:4 Incompatible variable type [9]: x1 is declared to have type `typing_extensions.Literal['Color.RED']` but is used as type `typing_extensions.Literal[Color.RED]`.
literals_parameterizations.py:33:0 Invalid type [31]: Expression `AppendMode` is not a literal value.
literals_parameterizations.py:33:0 Invalid type [31]: Expression `ReadOnlyMode` is not a literal value.
literals_parameterizations.py:33:0 Invalid type [31]: Expression `WriteAndTruncateMode` is not a literal value.
literals_parameterizations.py:33:0 Invalid type [31]: Expression `WriteNoTruncateMode` is not a literal value.
literals_parameterizations.py:33:0 Undefined or invalid type [11]: Annotation `` is not defined as a type.
literals_parameterizations.py:35:8 Invalid type [31]: Expression `typing.Literal[(typing.Literal[(typing.Literal[(1, 2, 3)], "foo")], 5, None)]` is not a valid type.
literals_parameterizations.py:41:6 Invalid type [31]: Expression `typing.Literal[3.__add__(4)]` is not a valid type.
literals_parameterizations.py:42:6 Invalid type [31]: Expression `typing.Literal["foo".replace("o", "b")]` is not a valid type.
literals_parameterizations.py:43:6 Invalid type [31]: Expression `typing.Literal[4.__add__(3.000000j)]` is not a valid type.
literals_parameterizations.py:44:6 Invalid type [31]: Expression `typing.Literal[~ 5]` is not a valid type.
literals_parameterizations.py:45:6 Invalid type [31]: Expression `typing.Literal[not False]` is not a valid type.
literals_parameterizations.py:47:6 Invalid type [31]: Expression `typing.Literal[{ "a":"b","c":"d" }]` is not a valid type.
literals_parameterizations.py:48:6 Invalid type [31]: Expression `typing.Literal[int]` is not a valid type.
literals_parameterizations.py:49:6 Invalid type [31]: Expression `variable` is not a literal value.
literals_parameterizations.py:50:7 Invalid type [31]: Expression `T` is not a literal value.
literals_parameterizations.py:51:7 Invalid type [31]: Expression `typing.Literal[3.140000]` is not a valid type.
literals_parameterizations.py:52:7 Invalid type [31]: Expression `Any` is not a literal value.
literals_parameterizations.py:53:7 Invalid type [31]: Expression `typing.Literal[...]` is not a valid type.
literals_parameterizations.py:56:19 Invalid type [31]: Expression `typing.Literal[1.__add__(2)]` is not a valid type.
literals_parameterizations.py:61:3 Invalid type [31]: Expression `my_function` is not a literal value.
literals_parameterizations.py:65:4 Incompatible variable type [9]: x1 is declared to have type `typing_extensions.Literal['Color.RED']` but is used as type `typing_extensions.Literal[Color.RED]`.
"""
1 change: 0 additions & 1 deletion conformance/results/pyre/protocols_class_objects.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ Fails to report some class objects as incompatible with a protocol.
output = """
protocols_class_objects.py:26:11 Invalid class instantiation [45]: Cannot instantiate abstract class `Proto` with abstract method `meth`.
protocols_class_objects.py:58:0 Incompatible variable type [9]: pa1 is declared to have type `ProtoA1` but is used as type `Type[ConcreteA]`.
protocols_class_objects.py:59:0 Incompatible variable type [9]: pa2 is declared to have type `ProtoA2` but is used as type `Type[ConcreteA]`.
protocols_class_objects.py:93:0 Uninitialized attribute [13]: Attribute `attr1` is declared in class `CMeta` to have type `int` but is never initialized.
"""
19 changes: 11 additions & 8 deletions conformance/results/pyright/aliases_newtype.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
conformant = "Pass"
conformant = "Partial"
notes = """
Rejects use of NewType created with another NewType.
"""
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 incompatible with "int" (reportGeneralTypeIssues)
Expand All @@ -8,13 +11,13 @@ aliases_newtype.py:20:16 - error: Second argument to "isinstance" must be a clas
  Class created with NewType cannot be used with instance and class checks (reportGeneralTypeIssues)
aliases_newtype.py:23:21 - error: Base class "UserId" is marked final and cannot be subclassed
aliases_newtype.py:32:1 - error: NewType must be assigned to a variable with the same name (reportGeneralTypeIssues)
aliases_newtype.py:36:19 - error: Expected no type arguments for class "GoodNewType1" (reportGeneralTypeIssues)
aliases_newtype.py:42:38 - error: Expected class as second argument to NewType
aliases_newtype.py:45:43 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues)
aliases_newtype.py:47:38 - error: NewType cannot be used with structural type (a protocol or TypedDict class)
aliases_newtype.py:49:38 - error: NewType cannot be used with Literal type
aliases_newtype.py:56:38 - error: NewType cannot be used with structural type (a protocol or TypedDict class)
aliases_newtype.py:58:38 - error: NewType cannot be used with a class created with NewType
aliases_newtype.py:36:40 - error: NewType cannot be used with a class created with NewType
aliases_newtype.py:38:19 - error: Expected no type arguments for class "GoodNewType1" (reportGeneralTypeIssues)
aliases_newtype.py:44:38 - error: Expected class as second argument to NewType
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)
aliases_newtype.py:51:38 - error: NewType cannot be used with Literal type
aliases_newtype.py:58:38 - error: NewType cannot be used with structural type (a protocol or TypedDict class)
aliases_newtype.py:60:15 - error: NewType requires two positional arguments (reportGeneralTypeIssues)
aliases_newtype.py:62:38 - error: The second argument to NewType must be a known class, not Any or Unknown (reportGeneralTypeIssues)
"""
18 changes: 11 additions & 7 deletions conformance/results/pyright/literals_parameterizations.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
conformant = "Pass"
conformant = "Partial"
notes = """
Rejects integer Literal with unary `+` operator.
"""
output = """
literals_parameterizations.py:40:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:20:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:41:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:42:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:43:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
Expand All @@ -9,13 +12,14 @@ literals_parameterizations.py:45:15 - error: Type arguments for "Literal" must b
literals_parameterizations.py:46:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:47:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:48:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:49:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:49:15 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:50:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:51:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:52:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:55:28 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:58:4 - error: "Literal" cannot be used in this context without a type argument
literals_parameterizations.py:59:12 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:63:32 - error: Expression of type "Literal[Color.RED]" cannot be assigned to declared type "Literal['Color.RED']"
literals_parameterizations.py:53:16 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:56:28 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:60:4 - error: "Literal" cannot be used in this context without a type argument
literals_parameterizations.py:61:12 - error: Type arguments for "Literal" must be None, a literal value (int, bool, str, or bytes), or an enum value
literals_parameterizations.py:65:32 - error: Expression of type "Literal[Color.RED]" cannot be assigned to declared type "Literal['Color.RED']"
  "Literal[Color.RED]" cannot be assigned to type "Literal['Color.RED']" (reportGeneralTypeIssues)
"""
6 changes: 0 additions & 6 deletions conformance/results/pyright/protocols_class_objects.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ protocols_class_objects.py:58:16 - error: Expression of type "type[ConcreteA]" c
      Parameter name mismatch: "x" versus "self"
      Parameter 1: type "int" cannot be assigned to type "ConcreteA"
        "int" is incompatible with "ConcreteA" (reportGeneralTypeIssues)
protocols_class_objects.py:59:16 - error: Expression of type "type[ConcreteA]" cannot be assigned to declared type "ProtoA2"
  "type[type]" is incompatible with "type[ConcreteA]"
  "type[type]" is incompatible with "type[ConcreteA]"
  "method1" is an incompatible type
    Type "(self: ConcreteA, x: int) -> int" cannot be assigned to type "(obj: Any, x: int) -> int"
      Parameter name mismatch: "obj" versus "self" (reportGeneralTypeIssues)
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)
Expand Down
Loading

0 comments on commit edffeab

Please sign in to comment.