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