Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Jan 14, 2024
1 parent 05d7e7b commit 27026f0
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 49 deletions.
6 changes: 4 additions & 2 deletions conformance/results/mypy/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ conformant = "Pass"
output = """
generics_basic.py:36: error: Value of type variable "AnyStr" of "concat" cannot be "Sequence[object]" [type-var]
generics_basic.py:37: error: Value of type variable "AnyStr" of "concat" cannot be "Sequence[object]" [type-var]
generics_basic.py:44: error: String argument 1 "BadConstraint" to TypeVar(...) does not match variable name "BadConstraint1" [misc]
generics_basic.py:48: error: String argument 1 "BadConstraint" to TypeVar(...) does not match variable name "BadConstraint2" [misc]
generics_basic.py:44: error: TypeVar cannot have only a single constraint [misc]
generics_basic.py:48: error: Type variable "generics_basic.T" is unbound [valid-type]
generics_basic.py:48: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_basic.py:48: note: (Hint: Use "T" in function signature to bind "T" inside a function)
generics_basic.py:59: error: Value of type variable "AnyStr" of "concat" cannot be "Sequence[object]" [type-var]
generics_basic.py:107: error: Duplicate type variables in Generic[...] or Protocol[...] [misc]
generics_basic.py:153: error: Dynamic metaclass not supported for "GenericMetaInstance" [misc]
Expand Down
32 changes: 21 additions & 11 deletions conformance/results/mypy/generics_scoping.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ notes = """
False negative on generic class nested within generic class with same type variable.
"""
output = """
generics_scoping.py:27: error: Argument 1 to "meth_2" of "MyClass" has incompatible type "str"; expected "int" [arg-type]
generics_scoping.py:48: error: Type variable "generics_scoping.S" is unbound [valid-type]
generics_scoping.py:48: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class)
generics_scoping.py:48: note: (Hint: Use "S" in function signature to bind "S" inside a function)
generics_scoping.py:52: error: Type variable "generics_scoping.S" is unbound [valid-type]
generics_scoping.py:52: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class)
generics_scoping.py:52: note: (Hint: Use "S" in function signature to bind "S" inside a function)
generics_scoping.py:63: error: Free type variable expected in Generic[...] [misc]
generics_scoping.py:76: error: Type variable "generics_scoping.T" is unbound [valid-type]
generics_scoping.py:76: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_scoping.py:76: note: (Hint: Use "T" in function signature to bind "T" inside a function)
generics_scoping.py:25: error: Argument 1 to "meth_2" of "MyClass" has incompatible type "str"; expected "int" [arg-type]
generics_scoping.py:46: error: Type variable "generics_scoping.S" is unbound [valid-type]
generics_scoping.py:46: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class)
generics_scoping.py:46: note: (Hint: Use "S" in function signature to bind "S" inside a function)
generics_scoping.py:50: error: Type variable "generics_scoping.S" is unbound [valid-type]
generics_scoping.py:50: note: (Hint: Use "Generic[S]" or "Protocol[S]" base class to bind "S" inside a class)
generics_scoping.py:50: note: (Hint: Use "S" in function signature to bind "S" inside a function)
generics_scoping.py:61: error: Free type variable expected in Generic[...] [misc]
generics_scoping.py:74: error: Type variable "generics_scoping.T" is unbound [valid-type]
generics_scoping.py:74: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_scoping.py:74: note: (Hint: Use "T" in function signature to bind "T" inside a function)
generics_scoping.py:80: error: Can't use bound type variable "T" to define generic alias [valid-type]
generics_scoping.py:84: error: Type variable "generics_scoping.T" is unbound [valid-type]
generics_scoping.py:84: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_scoping.py:84: note: (Hint: Use "T" in function signature to bind "T" inside a function)
generics_scoping.py:85: error: Type variable "generics_scoping.T" is unbound [valid-type]
generics_scoping.py:85: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_scoping.py:85: note: (Hint: Use "T" in function signature to bind "T" inside a function)
generics_scoping.py:86: error: Type variable "generics_scoping.T" is unbound [valid-type]
generics_scoping.py:86: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
generics_scoping.py:86: note: (Hint: Use "T" in function signature to bind "T" inside a function)
"""
2 changes: 1 addition & 1 deletion conformance/results/pyre/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ generics_basic.py:31:15 Incompatible parameter type [6]: In call `bytes.__add__`
generics_basic.py:36:14 Incompatible parameter type [6]: In call `concat`, for 2nd positional argument, expected `Variable[AnyStr <: [str, bytes]]` but got `bytes`.
generics_basic.py:37:14 Incompatible parameter type [6]: In call `concat`, for 2nd positional argument, expected `Variable[AnyStr <: [str, bytes]]` but got `str`.
generics_basic.py:44:0 Invalid type [31]: TypeVar can't have a single explicit constraint. Did you mean `bound=str`?
generics_basic.py:48:0 Invalid type [31]: Expression `Variable[BadConstraint <: [str, Variable[generics_basic.T]]]` is not a valid type. Type variables cannot contain other type variables in their constraints.
generics_basic.py:48:0 Invalid type [31]: Expression `Variable[BadConstraint2 <: [str, Variable[generics_basic.T]]]` is not a valid type. Type variables cannot contain other type variables in their constraints.
generics_basic.py:59:14 Incompatible parameter type [6]: In call `concat`, for 2nd positional argument, expected `Variable[AnyStr <: [str, bytes]]` but got `bytes`.
generics_basic.py:107:0 Duplicate type variables [59]: Duplicate type variable `T` in Generic[...].
generics_basic.py:147:25 Undefined attribute [16]: `typing.Iterator` has no attribute `__getitem__`.
Expand Down
17 changes: 11 additions & 6 deletions conformance/results/pyre/generics_scoping.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ False negative on generic class nested within generic function with same type va
False negative on generic class nested within generic class with same type variable.
"""
output = """
generics_scoping.py:27:9 Incompatible parameter type [6]: In call `MyClass.meth_2`, for 1st positional argument, expected `int` but got `str`.
generics_scoping.py:48:7 Invalid type variable [34]: The type variable `Variable[S]` isn't present in the function's parameters.
generics_scoping.py:52:13 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[S]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[S]`.
generics_scoping.py:72:0 Uninitialized attribute [13]: Attribute `attr` is declared in class `Outer` to have type `Outer.Inner[Variable[T]]` but is never initialized.
generics_scoping.py:75:4 Uninitialized attribute [13]: Attribute `x` is declared in class `Outer.AlsoBad` to have type `typing.List[Variable[T]]` but is never initialized.
generics_scoping.py:76:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[T]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[T]`.
generics_scoping.py:25:9 Incompatible parameter type [6]: In call `MyClass.meth_2`, for 1st positional argument, expected `int` but got `str`.
generics_scoping.py:46:7 Invalid type variable [34]: The type variable `Variable[S]` isn't present in the function's parameters.
generics_scoping.py:50:13 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[S]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[S]`.
generics_scoping.py:70:0 Uninitialized attribute [13]: Attribute `attr` is declared in class `Outer` to have type `Outer.Inner[Variable[T]]` but is never initialized.
generics_scoping.py:73:4 Uninitialized attribute [13]: Attribute `x` is declared in class `Outer.AlsoBad` to have type `typing.List[Variable[T]]` but is never initialized.
generics_scoping.py:74:11 Invalid type variable [34]: The current class isn't generic with respect to the type variable `Variable[T]`. To reference the type variable, you can modify the class to inherit from `typing.Generic[T]`.
generics_scoping.py:80:4 Incompatible attribute type [8]: Attribute `alias` declared in class `Outer` has type `TypeAlias` but is used as type `Type[List[Variable[_T]]]`.
generics_scoping.py:80:28 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T]]` but got `TypeVar`.
generics_scoping.py:84:13 Invalid type variable [34]: The type variable `Variable[T]` can only be used to annotate generic classes or functions.
generics_scoping.py:85:13 Invalid type variable [34]: The type variable `Variable[T]` can only be used to annotate generic classes or functions.
generics_scoping.py:86:5 Incompatible parameter type [6]: In call `typing.GenericMeta.__getitem__`, for 1st positional argument, expected `Type[Variable[_T]]` but got `TypeVar`.
"""
8 changes: 3 additions & 5 deletions conformance/results/pyright/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ generics_basic.py:36:15 - error: Argument of type "bytes" cannot be assigned to
  "bytes" is incompatible with "str" (reportGeneralTypeIssues)
generics_basic.py:37:15 - error: Argument of type "str" cannot be assigned to parameter "y" of type "AnyStr@concat" in function "concat"
  "str" is incompatible with "bytes" (reportGeneralTypeIssues)
generics_basic.py:44:1 - error: TypeVar must be assigned to a variable named "BadConstraint"
generics_basic.py:44:43 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues)
generics_basic.py:48:1 - error: TypeVar must be assigned to a variable named "BadConstraint"
generics_basic.py:48:48 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues)
generics_basic.py:48:48 - error: TypeVar constraint type cannot be generic
generics_basic.py:44:44 - error: TypeVar must have at least two constrained types (reportGeneralTypeIssues)
generics_basic.py:48:49 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues)
generics_basic.py:48:49 - error: TypeVar constraint type cannot be generic
generics_basic.py:59:15 - error: Argument of type "bytes" cannot be assigned to parameter "y" of type "AnyStr@concat" in function "concat"
  "bytes" is incompatible with "str" (reportGeneralTypeIssues)
generics_basic.py:107:24 - error: Type arguments for "Generic" must be unique
Expand Down
16 changes: 10 additions & 6 deletions conformance/results/pyright/generics_scoping.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
conformant = "Pass"
output = """
generics_scoping.py:27:10 - error: Argument of type "Literal['a']" cannot be assigned to parameter "x" of type "int" in function "meth_2"
generics_scoping.py:25:10 - error: Argument of type "Literal['a']" cannot be assigned to parameter "x" of type "int" in function "meth_2"
  "Literal['a']" is incompatible with "int" (reportGeneralTypeIssues)
generics_scoping.py:48:13 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues)
generics_scoping.py:52:19 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues)
generics_scoping.py:63:29 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues)
generics_scoping.py:73:24 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues)
generics_scoping.py:76:17 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues)
generics_scoping.py:46:13 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues)
generics_scoping.py:50:19 - error: Type variable "S" has no meaning in this context (reportGeneralTypeIssues)
generics_scoping.py:61:29 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues)
generics_scoping.py:71:24 - error: TypeVar "T" is already in use by an outer scope (reportGeneralTypeIssues)
generics_scoping.py:74:17 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues)
generics_scoping.py:80:5 - error: Generic type alias within class cannot use bound type variables T
generics_scoping.py:84:14 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues)
generics_scoping.py:85:19 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues)
generics_scoping.py:86:6 - error: Type variable "T" has no meaning in this context (reportGeneralTypeIssues)
"""
2 changes: 0 additions & 2 deletions conformance/results/pytype/generics_basic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ File "generics_basic.py", line 37, in test_concat: Function concat was called wi
Expected: (x, y: bytes)
Actually passed: (x, y: str)
File "generics_basic.py", line 44, in <module>: Invalid TypeVar: the number of constraints must be 0 or more than 1 [invalid-typevar]
File "generics_basic.py", line 44, in <module>: Invalid TypeVar: TypeVar('BadConstraint') must be stored as 'BadConstraint', not 'BadConstraint1' [invalid-typevar]
File "generics_basic.py", line 48, in <module>: Invalid TypeVar: constraint cannot contain TypeVars [invalid-typevar]
File "generics_basic.py", line 48, in <module>: Invalid TypeVar: TypeVar('BadConstraint') must be stored as 'BadConstraint', not 'BadConstraint2' [invalid-typevar]
File "generics_basic.py", line 57, in test_concat_subtype: MyStr [assert-type]
Expected: str
Actual: MyStr
Expand Down
36 changes: 20 additions & 16 deletions conformance/results/pytype/generics_scoping.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
conformant = "Pass"
output = """
File "generics_scoping.py", line 11, in fun_1: bad return type [bad-return-type]
File "generics_scoping.py", line 9, in fun_1: bad return type [bad-return-type]
Expected: int
Actually returned: None
Called from (traceback):
line 14, in current file
File "generics_scoping.py", line 12, in fun_2: bad return type [bad-return-type]
line 12, in current file
File "generics_scoping.py", line 10, in fun_2: bad return type [bad-return-type]
Expected: str
Actually returned: None
Called from (traceback):
line 15, in current file
File "generics_scoping.py", line 22, in meth_1: bad return type [bad-return-type]
line 13, in current file
File "generics_scoping.py", line 20, in meth_1: bad return type [bad-return-type]
Expected: int
Actually returned: None
Called from (traceback):
line 26, in current file
File "generics_scoping.py", line 27, in <module>: Function MyClass.meth_2 was called with the wrong arguments [wrong-arg-types]
line 24, in current file
File "generics_scoping.py", line 25, in <module>: Function MyClass.meth_2 was called with the wrong arguments [wrong-arg-types]
Expected: (self, x: int)
Actually passed: (self, x: str)
File "generics_scoping.py", line 37, in method: bad return type [bad-return-type]
File "generics_scoping.py", line 35, in method: bad return type [bad-return-type]
Expected: str
Actually returned: None
Called from (traceback):
line 40, in current file
File "generics_scoping.py", line 37, in method: bad return type [bad-return-type]
line 38, in current file
File "generics_scoping.py", line 35, in method: bad return type [bad-return-type]
Expected: bytes
Actually returned: None
Called from (traceback):
line 41, in current file
File "generics_scoping.py", line 48, in fun_3: Invalid type annotation 'List[S]' for z [invalid-annotation]
line 39, in current file
File "generics_scoping.py", line 46, in fun_3: Invalid type annotation 'List[S]' for z [invalid-annotation]
TypeVar(s) 'S' not in scope for method 'fun_3'
File "generics_scoping.py", line 52, in Bar: Invalid type annotation 'List[S]' for an_attr [invalid-annotation]
File "generics_scoping.py", line 50, in Bar: Invalid type annotation 'List[S]' for an_attr [invalid-annotation]
TypeVar(s) 'S' not in scope for class 'Bar'
File "generics_scoping.py", line 61, in fun_4: Invalid type annotation 'T' [invalid-annotation]
File "generics_scoping.py", line 59, in fun_4: Invalid type annotation 'T' [invalid-annotation]
Function [fun_4] and its nested generic class [MyGeneric] cannot use the same type variable T
File "generics_scoping.py", line 72, in <module>: Invalid type annotation 'Outer' [invalid-annotation]
File "generics_scoping.py", line 70, in <module>: Invalid type annotation 'Outer' [invalid-annotation]
Generic class [Outer] and its nested generic class [Bad] cannot use the same type variable T.
File "generics_scoping.py", line 76, in AlsoBad: Invalid type annotation 'List[T]' for x [invalid-annotation]
File "generics_scoping.py", line 74, in AlsoBad: Invalid type annotation 'List[T]' for x [invalid-annotation]
TypeVar(s) 'T' not in scope for class 'Outer.AlsoBad'
File "generics_scoping.py", line 84, in <module>: Invalid type annotation 'T' for global_var1 [invalid-annotation]
TypeVar(s) 'T' not in scope
File "generics_scoping.py", line 85, in <module>: Invalid type annotation 'List[T]' for global_var2 [invalid-annotation]
TypeVar(s) 'T' not in scope
"""

0 comments on commit 27026f0

Please sign in to comment.