Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions conformance/results/mypy/generics_defaults_referential.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
conformant = "Partial"
output = """
generics_defaults_referential.py:23: error: Expression is of type "type[slice[StartT, StopT, StepT]]", not "type[slice[int, int, int | None]]" [assert-type]
generics_defaults_referential.py:37: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
generics_defaults_referential.py:53: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc]
generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]
generics_defaults_referential.py:38: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
generics_defaults_referential.py:54: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
generics_defaults_referential.py:75: error: TypeVar default must be one of the constraint types [misc]
generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]
generics_defaults_referential.py:103: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]
generics_defaults_referential.py:79: error: TypeVar default must be one of the constraint types [misc]
generics_defaults_referential.py:104: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]
"""
conformance_automated = "Fail"
errors_diff = """
Line 36: Expected 1 errors
Line 60: Expected 1 errors
Line 68: Expected 1 errors
Line 37: Expected 1 errors
Line 61: Expected 1 errors
Line 69: Expected 1 errors
Line 23: Unexpected errors ['generics_defaults_referential.py:23: error: Expression is of type "type[slice[StartT, StopT, StepT]]", not "type[slice[int, int, int | None]]" [assert-type]']
Line 77: Unexpected errors ['generics_defaults_referential.py:77: error: TypeVar default must be one of the constraint types [misc]']
Line 103: Unexpected errors ['generics_defaults_referential.py:103: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]']
Line 78: Unexpected errors ['generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]']
Line 104: Unexpected errors ['generics_defaults_referential.py:104: error: Expression is of type "Bar[int, list[Never]]", not "Bar[int, list[int]]" [assert-type]']
"""
14 changes: 7 additions & 7 deletions conformance/results/pyrefly/generics_defaults_referential.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ conformance_automated = "Pass"
errors_diff = """
"""
output = """
ERROR generics_defaults_referential.py:36:13-15: Argument `Literal['']` is not assignable to parameter `b` with type `int` in function `Foo.__init__` [bad-argument-type]
ERROR generics_defaults_referential.py:37:10-12: Argument `Literal['']` is not assignable to parameter `a` with type `int` in function `Foo.__init__` [bad-argument-type]
ERROR generics_defaults_referential.py:53:7-13: Default of type parameter `Start2T` refers to out-of-scope type parameter `StopT` [invalid-type-var]
ERROR generics_defaults_referential.py:60:11-15: Default of type parameter `S2` refers to out-of-scope type parameter `S1` [invalid-type-var]
ERROR generics_defaults_referential.py:68:40-42: Expected default `TypeVar[X1]` of `Invalid1` to be assignable to the upper bound of `str` [invalid-type-var]
ERROR generics_defaults_referential.py:74:52-54: Expected default `TypeVar[Y1]` of `Invalid2` to be one of the following constraints: `float`, `str` [invalid-type-var]
ERROR generics_defaults_referential.py:78:63-65: Expected default `TypeVar[Y2]` of `AlsoInvalid2` to be one of the following constraints: `bool`, `complex` [invalid-type-var]
ERROR generics_defaults_referential.py:37:17-18: Argument `str` is not assignable to parameter `b` with type `int` in function `Foo.__init__` [bad-argument-type]
ERROR generics_defaults_referential.py:38:14-15: Argument `str` is not assignable to parameter `a` with type `int` in function `Foo.__init__` [bad-argument-type]
ERROR generics_defaults_referential.py:54:7-13: Default of type parameter `Start2T` refers to out-of-scope type parameter `StopT` [invalid-type-var]
ERROR generics_defaults_referential.py:61:11-15: Default of type parameter `S2` refers to out-of-scope type parameter `S1` [invalid-type-var]
ERROR generics_defaults_referential.py:69:40-42: Expected default `TypeVar[X1]` of `Invalid1` to be assignable to the upper bound of `str` [invalid-type-var]
ERROR generics_defaults_referential.py:75:52-54: Expected default `TypeVar[Y1]` of `Invalid2` to be one of the following constraints: `float`, `str` [invalid-type-var]
ERROR generics_defaults_referential.py:79:63-65: Expected default `TypeVar[Y2]` of `AlsoInvalid2` to be one of the following constraints: `bool`, `complex` [invalid-type-var]
"""
18 changes: 9 additions & 9 deletions conformance/results/pyright/generics_defaults_referential.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
conformant = "Pass"
output = """
generics_defaults_referential.py:36:13 - error: Argument of type "Literal['']" cannot be assigned to parameter "b" of type "int" in function "__init__"
  "Literal['']" is not assignable to "int" (reportArgumentType)
generics_defaults_referential.py:37:10 - error: Argument of type "Literal['']" cannot be assigned to parameter "a" of type "int" in function "__init__"
  "Literal['']" is not assignable to "int" (reportArgumentType)
generics_defaults_referential.py:53:7 - error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope
generics_defaults_referential.py:37:17 - error: Argument of type "str" cannot be assigned to parameter "b" of type "int" in function "__init__"
  "str" is not assignable to "int" (reportArgumentType)
generics_defaults_referential.py:38:14 - error: Argument of type "str" cannot be assigned to parameter "a" of type "int" in function "__init__"
  "str" is not assignable to "int" (reportArgumentType)
generics_defaults_referential.py:54:7 - error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope
  Type variable "StopT" is not in scope (reportGeneralTypeIssues)
generics_defaults_referential.py:60:11 - error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope
generics_defaults_referential.py:61:11 - error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope
  Type variable "S1" is not in scope (reportGeneralTypeIssues)
generics_defaults_referential.py:68:40 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues)
generics_defaults_referential.py:74:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
generics_defaults_referential.py:78:63 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
generics_defaults_referential.py:69:40 - error: TypeVar default type must be a subtype of the bound type (reportGeneralTypeIssues)
generics_defaults_referential.py:75:52 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
generics_defaults_referential.py:79:63 - error: TypeVar default type must be one of the constrained types (reportGeneralTypeIssues)
"""
conformance_automated = "Pass"
errors_diff = """
Expand Down
14 changes: 7 additions & 7 deletions conformance/results/zuban/generics_defaults_referential.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ conformance_automated = "Pass"
errors_diff = """
"""
output = """
generics_defaults_referential.py:36: error: Argument 2 to "Foo" has incompatible type "str"; expected "int" [arg-type]
generics_defaults_referential.py:37: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
generics_defaults_referential.py:53: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
generics_defaults_referential.py:60: error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope [misc]
generics_defaults_referential.py:68: error: TypeVar default must be a subtype of the bound type [misc]
generics_defaults_referential.py:74: error: TypeVar default must be one of the constraint types [misc]
generics_defaults_referential.py:78: error: TypeVar default must be one of the constraint types [misc]
generics_defaults_referential.py:37: error: Argument 2 to "Foo" has incompatible type "str"; expected "int" [arg-type]
generics_defaults_referential.py:38: error: Argument 1 to "Foo" has incompatible type "str"; expected "int" [arg-type]
generics_defaults_referential.py:54: error: Type parameter "Start2T" has a default type that refers to one or more type variables that are out of scope [misc]
generics_defaults_referential.py:61: error: Type parameter "S2" has a default type that refers to one or more type variables that are out of scope [misc]
generics_defaults_referential.py:69: error: TypeVar default must be a subtype of the bound type [misc]
generics_defaults_referential.py:75: error: TypeVar default must be one of the constraint types [misc]
generics_defaults_referential.py:79: error: TypeVar default must be one of the constraint types [misc]
"""
7 changes: 4 additions & 3 deletions conformance/tests/generics_defaults_referential.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class Foo(Generic[DefaultStrT, T2]):
def __init__(self, a: DefaultStrT, b: T2) -> None: ...


assert_type(Foo(1, ""), Foo[int, str])
Foo[int](1, "") # E: Foo[int, str] cannot be assigned to self: Foo[int, int] in Foo.__init__
Foo[int]("", 1) # E: Foo[str, int] cannot be assigned to self: Foo[int, int] in Foo.__init__
def func1(i: int, s: str) -> None:
assert_type(Foo(i, s), Foo[int, str])
Foo[int](i, s) # E: Foo[int, str] cannot be assigned to self: Foo[int, int] in Foo.__init__
Foo[int](s, i) # E: Foo[str, int] cannot be assigned to self: Foo[int, int] in Foo.__init__


# > ``T1`` must be used before ``T2`` in the parameter list of the generic.
Expand Down