Unpin Mypy (#1155)
This commit is contained in:
parent
7c264ad4a5
commit
4461e2ce47
|
@ -39,8 +39,8 @@ tests-no-zope = [
|
|||
"pytest-xdist[psutil]",
|
||||
# Since the mypy error messages keep changing, we have to keep updating this
|
||||
# pin.
|
||||
'mypy>=1.1.1,<1.4; python_implementation == "CPython"',
|
||||
'pytest-mypy-plugins; python_implementation == "CPython" and python_version<"3.11"',
|
||||
'mypy>=1.4; python_implementation == "CPython"',
|
||||
'pytest-mypy-plugins; python_implementation == "CPython"',
|
||||
]
|
||||
tests = ["attrs[tests-no-zope]", "zope.interface"]
|
||||
cov = [
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" [call-arg]
|
||||
|
||||
- case: testAttrsAnnotated
|
||||
regex: true
|
||||
main: |
|
||||
import attr
|
||||
from typing import List, ClassVar
|
||||
|
@ -53,13 +54,14 @@
|
|||
_d: int = attr.ib(validator=None, default=18)
|
||||
E = 7
|
||||
F: ClassVar[int] = 22
|
||||
reveal_type(A) # N: Revealed type is "def (a: builtins.int, b: builtins.list[builtins.int], c: builtins.str =, d: builtins.int =) -> main.A"
|
||||
reveal_type(A) # N: Revealed type is "def \(a: builtins\.int, b: builtins\.list\[builtins\.int\], c: builtins\.str =, d: builtins\.int =\) -> main\.A"
|
||||
A(1, [2])
|
||||
A(1, [2], '3', 4)
|
||||
A(1, 2, 3, 4) # E: Argument 2 to "A" has incompatible type "int"; expected "List[int]" [arg-type] # E: Argument 3 to "A" has incompatible type "int"; expected "str" [arg-type]
|
||||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" [call-arg]
|
||||
A(1, 2, 3, 4) # E: Argument 2 to "A" has incompatible type "int"; expected "[Ll]ist\[int\]" \[arg-type\] # E: Argument 3 to "A" has incompatible type "int"; expected "str" \[arg-type\]
|
||||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" \[call-arg\]
|
||||
|
||||
- case: testAttrsPython2Annotations
|
||||
regex: true
|
||||
main: |
|
||||
import attr
|
||||
from typing import List, ClassVar
|
||||
|
@ -71,13 +73,14 @@
|
|||
_d = attr.ib(validator=None, default=18) # type: int
|
||||
E = 7
|
||||
F: ClassVar[int] = 22
|
||||
reveal_type(A) # N: Revealed type is "def (a: builtins.int, b: builtins.list[builtins.int], c: builtins.str =, d: builtins.int =) -> main.A"
|
||||
reveal_type(A) # N: Revealed type is "def \(a: builtins\.int, b: builtins\.list\[builtins\.int\], c: builtins\.str =, d: builtins\.int =\) -> main\.A"
|
||||
A(1, [2])
|
||||
A(1, [2], '3', 4)
|
||||
A(1, 2, 3, 4) # E: Argument 2 to "A" has incompatible type "int"; expected "List[int]" [arg-type] # E: Argument 3 to "A" has incompatible type "int"; expected "str" [arg-type]
|
||||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" [call-arg]
|
||||
A(1, 2, 3, 4) # E: Argument 2 to "A" has incompatible type "int"; expected "[Ll]ist\[int\]" \[arg-type\] # E: Argument 3 to "A" has incompatible type "int"; expected "str" \[arg-type\]
|
||||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" \[call-arg\]
|
||||
|
||||
- case: testAttrsAutoAttribs
|
||||
regex: true
|
||||
main: |
|
||||
import attr
|
||||
from typing import List, ClassVar
|
||||
|
@ -89,11 +92,11 @@
|
|||
_d: int = attr.ib(validator=None, default=18)
|
||||
E = 7
|
||||
F: ClassVar[int] = 22
|
||||
reveal_type(A) # N: Revealed type is "def (a: builtins.int, b: builtins.list[builtins.int], c: builtins.str =, d: builtins.int =) -> main.A"
|
||||
reveal_type(A) # N: Revealed type is "def \(a: builtins\.int, b: builtins.list\[builtins.int\], c: builtins\.str =, d: builtins\.int =\) -> main\.A"
|
||||
A(1, [2])
|
||||
A(1, [2], '3', 4)
|
||||
A(1, 2, 3, 4) # E: Argument 2 to "A" has incompatible type "int"; expected "List[int]" [arg-type] # E: Argument 3 to "A" has incompatible type "int"; expected "str" [arg-type]
|
||||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" [call-arg]
|
||||
A(1, 2, 3, 4) # E: Argument 2 to "A" has incompatible type "int"; expected "[Ll]ist\[int\]" \[arg-type\] # E: Argument 3 to "A" has incompatible type "int"; expected "str" \[arg-type\]
|
||||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" \[call-arg\]
|
||||
|
||||
- case: testAttrsUntypedNoUntypedDefs
|
||||
mypy_config: |
|
||||
|
@ -133,6 +136,7 @@
|
|||
return self.x # E: Incompatible return value type (got "int", expected "str") [return-value]
|
||||
|
||||
- case: testAttrsSeriousNames
|
||||
regex: true
|
||||
main: |
|
||||
from attr import attrib, attrs
|
||||
from typing import List
|
||||
|
@ -143,11 +147,11 @@
|
|||
c = attrib(18)
|
||||
_d = attrib(validator=None, default=18)
|
||||
CLASS_VAR = 18
|
||||
reveal_type(A) # N: Revealed type is "def (a: Any, b: builtins.list[builtins.int], c: Any =, d: Any =) -> main.A"
|
||||
reveal_type(A) # N: Revealed type is "def \(a: Any, b: builtins.list\[builtins.int\], c: Any =, d: Any =\) -> main\.A"
|
||||
A(1, [2])
|
||||
A(1, [2], '3', 4)
|
||||
A(1, 2, 3, 4) # E: Argument 2 to "A" has incompatible type "int"; expected "List[int]" [arg-type]
|
||||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" [call-arg]
|
||||
A(1, 2, 3, 4) # E: Argument 2 to "A" has incompatible type "int"; expected "[Ll]ist\[int\]" \[arg-type\]
|
||||
A(1, [2], '3', 4, 5) # E: Too many arguments for "A" \[call-arg\]
|
||||
|
||||
- case: testAttrsDefaultErrors
|
||||
main: |
|
||||
|
@ -451,6 +455,7 @@
|
|||
reveal_type(A) # N: Revealed type is "def (x: builtins.list[builtins.int], y: builtins.list[builtins.str]) -> main.A"
|
||||
|
||||
- case: testAttrsGeneric
|
||||
regex: true
|
||||
main: |
|
||||
from typing import TypeVar, Generic, List
|
||||
import attr
|
||||
|
@ -464,15 +469,15 @@
|
|||
def bar(self) -> T:
|
||||
return self.x[0]
|
||||
def problem(self) -> T:
|
||||
return self.x # E: Incompatible return value type (got "List[T]", expected "T") [return-value]
|
||||
reveal_type(A) # N: Revealed type is "def [T] (x: builtins.list[T`1], y: T`1) -> main.A[T`1]"
|
||||
return self.x # E: Incompatible return value type \(got "[Ll]ist\[T\]", expected "T"\) \[return-value\]
|
||||
reveal_type(A) # N: Revealed type is "def \[T\] \(x: builtins\.list\[T`1\], y: T`1\) -> main.A\[T`1\]"
|
||||
a = A([1], 2)
|
||||
reveal_type(a) # N: Revealed type is "main.A[builtins.int]"
|
||||
reveal_type(a.x) # N: Revealed type is "builtins.list[builtins.int]"
|
||||
reveal_type(a.y) # N: Revealed type is "builtins.int"
|
||||
reveal_type(a) # N: Revealed type is "main\.A\[builtins.int\]"
|
||||
reveal_type(a.x) # N: Revealed type is "builtins\.list\[builtins\.int\]"
|
||||
reveal_type(a.y) # N: Revealed type is "builtins\.int"
|
||||
|
||||
A(['str'], 7) # E: Cannot infer type argument 1 of "A" [misc]
|
||||
A([1], '2') # E: Cannot infer type argument 1 of "A" [misc]
|
||||
A(['str'], 7) # E: Cannot infer type argument 1 of "A" \[misc\]
|
||||
A([1], '2') # E: Cannot infer type argument 1 of "A" \[misc\]
|
||||
|
||||
- case: testAttrsUntypedGenericInheritance
|
||||
main: |
|
||||
|
@ -1063,14 +1068,15 @@
|
|||
x: int = attr.ib(factory=int, default=7) # E: Can't pass both "default" and "factory". [misc]
|
||||
|
||||
- case: testAttrsFactoryBadReturn
|
||||
regex: true
|
||||
main: |
|
||||
import attr
|
||||
def my_factory() -> int:
|
||||
return 7
|
||||
@attr.s
|
||||
class A:
|
||||
x: int = attr.ib(factory=list) # E: Incompatible types in assignment (expression has type "List[_T]", variable has type "int") [assignment]
|
||||
y: str = attr.ib(factory=my_factory) # E: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment]
|
||||
x: int = attr.ib(factory=list) # E: Incompatible types in assignment \(expression has type "[Ll]ist\[_T\]", variable has type "int"\) \[assignment\]
|
||||
y: str = attr.ib(factory=my_factory) # E: Incompatible types in assignment \(expression has type "int", variable has type "str"\) \[assignment\]
|
||||
|
||||
- case: testAttrsDefaultAndInit
|
||||
main: |
|
||||
|
@ -1363,6 +1369,7 @@
|
|||
reveal_type(fields(A)) # N: Revealed type is "Any"
|
||||
|
||||
- case: testFieldsError
|
||||
regex: true
|
||||
main: |
|
||||
from attrs import fields
|
||||
|
||||
|
@ -1370,7 +1377,7 @@
|
|||
a: int
|
||||
b: str
|
||||
|
||||
fields(A) # E: Argument 1 to "fields" has incompatible type "Type[A]"; expected "Type[AttrsInstance]" [arg-type]
|
||||
fields(A) # E: Argument 1 to "fields" has incompatible type "[Tt]ype\[A\]"; expected "[Tt]ype\[AttrsInstance\]" \[arg-type\]
|
||||
|
||||
- case: testAsDict
|
||||
main: |
|
||||
|
|
Loading…
Reference in New Issue