Skip to content
Merged
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
8 changes: 5 additions & 3 deletions conformance/results/mypy/constructors_callable.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ constructors_callable.py:145: error: Expression is of type "Class6Any", not "Any
constructors_callable.py:145: error: Too few arguments [call-arg]
constructors_callable.py:164: note: Revealed type is "Overload(def (x: int) -> constructors_callable.Class7[int], def (x: str) -> constructors_callable.Class7[str])"
constructors_callable.py:184: note: Revealed type is "def [T] (x: list[T], y: list[T]) -> constructors_callable.Class8[T]"
constructors_callable.py:186: error: Cannot infer function type argument [misc]
constructors_callable.py:195: note: Revealed type is "def [T] (x: list[T], y: list[T]) -> constructors_callable.Class9"
constructors_callable.py:197: error: Cannot infer function type argument [misc]
constructors_callable.py:185: error: Argument 2 has incompatible type "str"; expected "list[str]" [arg-type]
constructors_callable.py:187: error: Cannot infer function type argument [misc]
constructors_callable.py:196: note: Revealed type is "def [T] (x: list[T], y: list[T]) -> constructors_callable.Class9"
constructors_callable.py:197: error: Argument 2 has incompatible type "str"; expected "list[str]" [arg-type]
constructors_callable.py:199: error: Cannot infer function type argument [misc]
"""
7 changes: 7 additions & 0 deletions conformance/results/mypy/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ generics_basic.py:208: error: Dynamic metaclass not supported for "GenericMetaIn
generics_basic.py:208: error: Type variable "generics_basic.T" is unbound [valid-type]
generics_basic.py:208: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_basic.py:208: note: (Hint: Use "T" in function signature to bind "T" inside a function)
generics_basic.py:223: error: Argument 2 to "takes_two_lists" has incompatible type "str"; expected "list[int]" [arg-type]
generics_basic.py:225: error: Cannot infer value of type parameter "T" of "takes_two_lists" [misc]
generics_basic.py:232: error: Cannot infer value of type parameter "T" of "takes_two_lists" [misc]
generics_basic.py:240: error: Argument 2 to "takes_two_int_lists" has incompatible type "str"; expected "list[int]" [arg-type]
generics_basic.py:241: error: Cannot infer value of type parameter "T_int" of "takes_two_int_lists" [misc]
generics_basic.py:244: error: Cannot infer value of type parameter "T_int" of "takes_two_int_lists" [misc]
generics_basic.py:251: error: Cannot infer value of type parameter "T_int" of "takes_two_int_lists" [misc]
"""
conformance_automated = "Pass"
errors_diff = """
Expand Down
8 changes: 5 additions & 3 deletions conformance/results/pycroscope/constructors_callable.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ output = """
./constructors_callable.py:146:0: Takes 0 positional arguments but 1 were given [incompatible_call]
./constructors_callable.py:164:4: Revealed type is '(x: ~_Ctor_Class7_T) -> ./constructors_callable.py.Class7[~_Ctor_Class7_T]' [reveal_type]
./constructors_callable.py:184:12: Revealed type is '(x: list[~T@./constructors_callable.py.Class8], y: list[~T@./constructors_callable.py.Class8]) -> ./constructors_callable.py.Class8[~T@./constructors_callable.py.Class8]' [reveal_type]
./constructors_callable.py:186:0: Cannot resolve type variables [incompatible_call]
./constructors_callable.py:195:12: Revealed type is '(x: list[~T@./constructors_callable.py.Class9.__init__.<locals>.__init__], y: list[~T@./constructors_callable.py.Class9.__init__.<locals>.__init__]) -> ./constructors_callable.py.Class9' [reveal_type]
./constructors_callable.py:197:0: Cannot resolve type variables [incompatible_call]
./constructors_callable.py:185:9: Incompatible argument type for y: expected list[~T@./constructors_callable.py.Class8] but got Literal['not a list'] [incompatible_argument]
./constructors_callable.py:187:0: Cannot resolve type variables [incompatible_call]
./constructors_callable.py:196:12: Revealed type is '(x: list[~T@./constructors_callable.py.Class9.__init__.<locals>.__init__], y: list[~T@./constructors_callable.py.Class9.__init__.<locals>.__init__]) -> ./constructors_callable.py.Class9' [reveal_type]
./constructors_callable.py:197:9: Incompatible argument type for y: expected list[~T@./constructors_callable.py.Class9.__init__.<locals>.__init__] but got Literal['not a list'] [incompatible_argument]
./constructors_callable.py:199:0: Cannot resolve type variables [incompatible_call]
"""
6 changes: 6 additions & 0 deletions conformance/results/pycroscope/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ output = """
./generics_basic.py:171:27: All type parameters for the class must appear within Generic or Protocol [invalid_base]
./generics_basic.py:172:27: All type parameters for the class must appear within Generic or Protocol [invalid_base]
./generics_basic.py:208:36: Cannot determine metaclass [invalid_metaclass]
./generics_basic.py:223:21: Incompatible argument type for y: expected list[~T@./generics_basic.py.takes_two_lists.<locals>.takes_two_lists] but got Literal['not a list'] [incompatible_argument]
./generics_basic.py:225:0: Cannot resolve type variables [incompatible_call]
./generics_basic.py:232:4: Cannot resolve type variables [incompatible_call]
./generics_basic.py:240:25: Incompatible argument type for y: expected list[~T_int@./generics_basic.py.takes_two_int_lists.<locals>.takes_two_int_lists] but got Literal['not a list'] [incompatible_argument]
./generics_basic.py:241:25: Incompatible argument type for y: expected list[~T_int@./generics_basic.py.takes_two_int_lists.<locals>.takes_two_int_lists] but got Literal[['']] [incompatible_argument]
./generics_basic.py:251:4: Cannot resolve type variables [incompatible_call]
"""
9 changes: 5 additions & 4 deletions conformance/results/pyrefly/constructors_callable.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Converting constructor to callable does not preserve class-scoped type params.
"""
conformance_automated = "Fail"
errors_diff = """
Line 186: Expected 1 errors
Line 185: Unexpected errors ['assert_type(Class8[Unknown], Class8[str]) failed [assert-type]']
Line 186: Unexpected errors ['assert_type(Class8[Unknown], Class8[str]) failed [assert-type]']
"""
output = """
ERROR constructors_callable.py:38:3-5: Missing argument `x` [missing-argument]
Expand All @@ -21,6 +20,8 @@ ERROR constructors_callable.py:82:3-8: Missing argument `x` [missing-argument]
ERROR constructors_callable.py:82:4-5: Unexpected keyword argument `y` [unexpected-keyword]
ERROR constructors_callable.py:129:4-5: Expected 0 positional arguments, got 1 [bad-argument-count]
ERROR constructors_callable.py:146:8-9: Expected 0 positional arguments, got 1 [bad-argument-count]
ERROR constructors_callable.py:185:12-41: assert_type(Class8[Unknown], Class8[str]) failed [assert-type]
ERROR constructors_callable.py:197:9-13: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` [bad-argument-type]
ERROR constructors_callable.py:185:10-22: Argument `Literal['not a list']` is not assignable to parameter `y` with type `list[Unknown]` [bad-argument-type]
ERROR constructors_callable.py:186:12-41: assert_type(Class8[Unknown], Class8[str]) failed [assert-type]
ERROR constructors_callable.py:197:10-22: Argument `Literal['not a list']` is not assignable to parameter `y` with type `list[str]` [bad-argument-type]
ERROR constructors_callable.py:199:9-13: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` [bad-argument-type]
"""
7 changes: 7 additions & 0 deletions conformance/results/pyrefly/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ ERROR generics_basic.py:163:7-11: Expected a type variable, got `int` [invalid-t
ERROR generics_basic.py:171:7-11: Class `Bad3` uses type variables not specified in `Generic` or `Protocol` base [invalid-type-var]
ERROR generics_basic.py:172:7-11: Class `Bad4` uses type variables not specified in `Generic` or `Protocol` base [invalid-type-var]
ERROR generics_basic.py:208:7-26: Metaclass may not be an unbound generic [invalid-inheritance]
ERROR generics_basic.py:223:22-34: Argument `Literal['not a list']` is not assignable to parameter `y` with type `list[int]` in function `takes_two_lists` [bad-argument-type]
ERROR generics_basic.py:225:22-26: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` in function `takes_two_lists` [bad-argument-type]
ERROR generics_basic.py:232:24-25: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` in function `takes_two_lists` [bad-argument-type]
ERROR generics_basic.py:240:26-38: Argument `Literal['not a list']` is not assignable to parameter `y` with type `list[int]` in function `takes_two_int_lists` [bad-argument-type]
ERROR generics_basic.py:241:20-31: `str` is not assignable to upper bound `int` of type variable `T_int` [bad-specialization]
ERROR generics_basic.py:241:26-30: Argument `list[str]` is not assignable to parameter `y` with type `list[int]` in function `takes_two_int_lists` [bad-argument-type]
ERROR generics_basic.py:251:28-29: Argument `list[bool]` is not assignable to parameter `y` with type `list[int]` in function `takes_two_int_lists` [bad-argument-type]
"""
11 changes: 7 additions & 4 deletions conformance/results/pyright/constructors_callable.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
conformant = "Pass"
conformance_automated = "Pass"
errors_diff = """
"""
Expand All @@ -25,9 +24,13 @@ constructors_callable.py:144:13 - information: Type of "r6_any" is "() -> Any"
constructors_callable.py:146:8 - error: Expected 0 positional arguments (reportCallIssue)
constructors_callable.py:164:5 - information: Type of "r7" is "Overload[(x: int) -> Class7[int], (x: str) -> Class7[str]]"
constructors_callable.py:184:13 - information: Type of "r8" is "(x: list[T@Class8], y: list[T@Class8]) -> Class8[T@Class8]"
constructors_callable.py:186:10 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@Class8]"
constructors_callable.py:185:10 - error: Argument of type "Literal['not a list']" cannot be assigned to parameter "y" of type "list[T@Class8]"
  "Literal['not a list']" is not assignable to "list[str]" (reportArgumentType)
constructors_callable.py:187:10 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@Class8]"
  "Literal['']" is not assignable to "int" (reportArgumentType)
constructors_callable.py:195:13 - information: Type of "r9" is "(x: list[T@__init__], y: list[T@__init__]) -> Class9"
constructors_callable.py:197:10 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@__init__]"
constructors_callable.py:196:13 - information: Type of "r9" is "(x: list[T@__init__], y: list[T@__init__]) -> Class9"
constructors_callable.py:197:10 - error: Argument of type "Literal['not a list']" cannot be assigned to parameter "y" of type "list[T@__init__]"
  "Literal['not a list']" is not assignable to "list[str]" (reportArgumentType)
constructors_callable.py:199:10 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@__init__]"
  "Literal['']" is not assignable to "int" (reportArgumentType)
"""
16 changes: 16 additions & 0 deletions conformance/results/pyright/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ generics_basic.py:171:7 - error: Generic[] or Protocol[] must include all type v
generics_basic.py:172:7 - error: Generic[] or Protocol[] must include all type variables
  Missing type variables: "T_co" (reportGeneralTypeIssues)
generics_basic.py:208:37 - error: Metaclass cannot be generic (reportGeneralTypeIssues)
generics_basic.py:223:22 - error: Argument of type "Literal['not a list']" cannot be assigned to parameter "y" of type "list[T@takes_two_lists]" in function "takes_two_lists"
  "Literal['not a list']" is not assignable to "list[int]" (reportArgumentType)
generics_basic.py:225:23 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@takes_two_lists]" in function "takes_two_lists"
  "Literal['']" is not assignable to "int" (reportArgumentType)
generics_basic.py:232:24 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T@takes_two_lists]" in function "takes_two_lists"
  "list[str]" is not assignable to "list[int]"
    Type parameter "_T@list" is invariant, but "str" is not the same as "int"
    Consider switching from "list" to "Sequence" which is covariant (reportArgumentType)
generics_basic.py:240:26 - error: Argument of type "Literal['not a list']" cannot be assigned to parameter "y" of type "list[T_int@takes_two_int_lists]" in function "takes_two_int_lists"
  "Literal['not a list']" is not assignable to "list[int]" (reportArgumentType)
generics_basic.py:241:27 - error: Argument of type "list[str]" cannot be assigned to parameter "y" of type "list[T_int@takes_two_int_lists]" in function "takes_two_int_lists"
  "Literal['']" is not assignable to "int" (reportArgumentType)
generics_basic.py:251:28 - error: Argument of type "list[bool]" cannot be assigned to parameter "y" of type "list[T_int@takes_two_int_lists]" in function "takes_two_int_lists"
  "list[bool]" is not assignable to "list[int]"
    Type parameter "_T@list" is invariant, but "bool" is not the same as "int"
    Consider switching from "list" to "Sequence" which is covariant (reportArgumentType)
"""
conformance_automated = "Pass"
errors_diff = """
Expand Down
12 changes: 7 additions & 5 deletions conformance/results/ty/constructors_callable.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ constructors_callable.py:164:5: info[revealed-type] Revealed type: `Overload[[T]
constructors_callable.py:166:1: error[type-assertion-failure] Type `Class7[int] | Class7[str]` does not match asserted type `Class7[int]`
constructors_callable.py:167:1: error[type-assertion-failure] Type `Class7[int] | Class7[str]` does not match asserted type `Class7[str]`
constructors_callable.py:184:13: info[revealed-type] Revealed type: `[T](x: list[T], y: list[T]) -> Class8[T]`
constructors_callable.py:186:4: error[invalid-argument-type] Argument is incorrect: Expected `list[int | str]`, found `list[int]`
constructors_callable.py:186:9: error[invalid-argument-type] Argument is incorrect: Expected `list[int | str]`, found `list[str]`
constructors_callable.py:195:13: info[revealed-type] Revealed type: `[T](x: list[T], y: list[T]) -> Class9`
constructors_callable.py:197:4: error[invalid-argument-type] Argument is incorrect: Expected `list[int | str]`, found `list[int]`
constructors_callable.py:197:9: error[invalid-argument-type] Argument is incorrect: Expected `list[int | str]`, found `list[str]`
constructors_callable.py:185:10: error[invalid-argument-type] Argument is incorrect: Expected `list[str]`, found `Literal["not a list"]`
constructors_callable.py:187:4: error[invalid-argument-type] Argument is incorrect: Expected `list[int | str]`, found `list[int]`
constructors_callable.py:187:9: error[invalid-argument-type] Argument is incorrect: Expected `list[int | str]`, found `list[str]`
constructors_callable.py:196:13: info[revealed-type] Revealed type: `[T](x: list[T], y: list[T]) -> Class9`
constructors_callable.py:197:10: error[invalid-argument-type] Argument is incorrect: Expected `list[str]`, found `Literal["not a list"]`
constructors_callable.py:199:4: error[invalid-argument-type] Argument is incorrect: Expected `list[int | str]`, found `list[int]`
constructors_callable.py:199:9: error[invalid-argument-type] Argument is incorrect: Expected `list[int | str]`, found `list[str]`
"""
10 changes: 10 additions & 0 deletions conformance/results/ty/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ generics_basic.py:163:12: error[invalid-argument-type] `<class 'int'>` is not a
generics_basic.py:171:1: error[invalid-generic-class] `Generic` base class must include all type variables used in other base classes
generics_basic.py:172:1: error[invalid-generic-class] `Generic` base class must include all type variables used in other base classes
generics_basic.py:208:27: error[invalid-metaclass] Generic metaclasses are not supported
generics_basic.py:223:22: error[invalid-argument-type] Argument to function `takes_two_lists` is incorrect: Expected `list[int]`, found `Literal["not a list"]`
generics_basic.py:225:17: error[invalid-argument-type] Argument to function `takes_two_lists` is incorrect: Expected `list[int | str]`, found `list[int]`
generics_basic.py:225:22: error[invalid-argument-type] Argument to function `takes_two_lists` is incorrect: Expected `list[int | str]`, found `list[str]`
generics_basic.py:232:21: error[invalid-argument-type] Argument to function `takes_two_lists` is incorrect: Expected `list[int | str]`, found `list[int]`
generics_basic.py:232:24: error[invalid-argument-type] Argument to function `takes_two_lists` is incorrect: Expected `list[int | str]`, found `list[str]`
generics_basic.py:240:26: error[invalid-argument-type] Argument to function `takes_two_int_lists` is incorrect: Expected `list[int]`, found `Literal["not a list"]`
generics_basic.py:241:26: error[invalid-argument-type] Argument to function `takes_two_int_lists` is incorrect: Argument type `str` does not satisfy upper bound `int` of type variable `T_int`
generics_basic.py:241:26: error[invalid-argument-type] Argument to function `takes_two_int_lists` is incorrect: Expected `list[int]`, found `list[str]`
generics_basic.py:244:26: error[invalid-argument-type] Argument to function `takes_two_int_lists` is incorrect: Expected `list[int]`, found `list[bool]`
generics_basic.py:251:28: error[invalid-argument-type] Argument to function `takes_two_int_lists` is incorrect: Expected `list[int]`, found `list[bool]`
"""
8 changes: 5 additions & 3 deletions conformance/results/zuban/constructors_callable.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ constructors_callable.py:144: note: Revealed type is "def () -> Any"
constructors_callable.py:146: error: Too many arguments [call-arg]
constructors_callable.py:164: note: Revealed type is "Overload(def (x: builtins.int) -> tests.constructors_callable.Class7[builtins.int], def (x: builtins.str) -> tests.constructors_callable.Class7[builtins.str])"
constructors_callable.py:184: note: Revealed type is "def [T] (x: builtins.list[T], y: builtins.list[T]) -> tests.constructors_callable.Class8[T]"
constructors_callable.py:186: error: List item 0 has incompatible type "str"; expected "int" [list-item]
constructors_callable.py:195: note: Revealed type is "def [T] (x: builtins.list[T], y: builtins.list[T]) -> tests.constructors_callable.Class9"
constructors_callable.py:197: error: List item 0 has incompatible type "str"; expected "int" [list-item]
constructors_callable.py:185: error: Argument 2 has incompatible type "str"; expected "list[str]" [arg-type]
constructors_callable.py:187: error: List item 0 has incompatible type "str"; expected "int" [list-item]
constructors_callable.py:196: note: Revealed type is "def [T] (x: builtins.list[T], y: builtins.list[T]) -> tests.constructors_callable.Class9"
constructors_callable.py:197: error: Argument 2 has incompatible type "str"; expected "list[str]" [arg-type]
constructors_callable.py:199: error: List item 0 has incompatible type "str"; expected "int" [list-item]
"""
8 changes: 8 additions & 0 deletions conformance/results/zuban/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ generics_basic.py:163: error: Free type variable expected in Protocol[...] [mis
generics_basic.py:171: error: If Generic[...] or Protocol[...] is present it should list all type variables [misc]
generics_basic.py:172: error: If Generic[...] or Protocol[...] is present it should list all type variables [misc]
generics_basic.py:208: error: Invalid metaclass "GenericMeta[T]" [metaclass]
generics_basic.py:223: error: Argument 2 to "takes_two_lists" has incompatible type "str"; expected "list[int]" [arg-type]
generics_basic.py:225: error: List item 0 has incompatible type "str"; expected "int" [list-item]
generics_basic.py:232: error: Argument 2 to "takes_two_lists" has incompatible type "list[str]"; expected "list[int]" [arg-type]
generics_basic.py:240: error: Argument 2 to "takes_two_int_lists" has incompatible type "str"; expected "list[int]" [arg-type]
generics_basic.py:241: error: List item 0 has incompatible type "str"; expected "int" [list-item]
generics_basic.py:251: error: Argument 2 to "takes_two_int_lists" has incompatible type "list[bool]"; expected "list[int]" [arg-type]
generics_basic.py:251: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
generics_basic.py:251: note: Consider using "Sequence" instead, which is covariant
"""
6 changes: 4 additions & 2 deletions conformance/tests/constructors_callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ def __new__(cls, x: list[T], y: list[T]) -> Self:

r8 = accepts_callable(Class8)
reveal_type(r8) # `def [T] (x: list[T], y: list[T]) -> Class8[T]`
r8([""], "not a list") # E: no assignment of T makes the second argument valid
assert_type(r8([""], [""]), Class8[str])
r8([1], [""]) # E
r8([1], [""]) # E?: T = int | str is a potential solution


class Class9:
Expand All @@ -193,5 +194,6 @@ def __init__(self, x: list[T], y: list[T]) -> None:

r9 = accepts_callable(Class9)
reveal_type(r9) # `def [T] (x: list[T], y: list[T]) -> Class9`
r9([""], "not a list") # E: no assignment of T makes the second argument valid
assert_type(r9([""], [""]), Class9)
r9([1], [""]) # E
r9([1], [""]) # E?: T = int | str is a potential solution
Loading