Skip to content

Commit

Permalink
CI,TYP: Bump mypy to 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BvB93 committed Aug 23, 2023
1 parent 09925cf commit a0c70f3
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 116 deletions.
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ dependencies:
- pytest-xdist
- hypothesis
# For type annotations
- mypy=0.981
- typing_extensions>=4.2.0
- mypy=1.3.0
# For building docs
- sphinx>=4.5.0
- sphinx-design
Expand Down
2 changes: 1 addition & 1 deletion numpy/typing/tests/data/fail/modules.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ np.bob # E: Module has no attribute
# Stdlib modules in the namespace by accident
np.warnings # E: Module has no attribute
np.sys # E: Module has no attribute
np.os # E: Module has no attribute
np.os # E: Module "numpy" does not explicitly export
np.math # E: Module has no attribute

# Public sub-modules that are not imported to their parent module by default;
Expand Down
3 changes: 0 additions & 3 deletions numpy/typing/tests/data/fail/npyio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ AR_i8: npt.NDArray[np.int64]
np.load(str_file) # E: incompatible type

np.save(bytes_path, AR_i8) # E: incompatible type
np.save(str_file, AR_i8) # E: incompatible type

np.savez(bytes_path, AR_i8) # E: incompatible type
np.savez(str_file, AR_i8) # E: incompatible type

np.savez_compressed(bytes_path, AR_i8) # E: incompatible type
np.savez_compressed(str_file, AR_i8) # E: incompatible type

np.loadtxt(bytes_path) # E: incompatible type

Expand Down
6 changes: 0 additions & 6 deletions numpy/typing/tests/data/mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,3 @@
plugins = numpy.typing.mypy_plugin
show_absolute_path = True
implicit_reexport = False

[mypy-numpy]
ignore_errors = True

[mypy-numpy.*]
ignore_errors = True
5 changes: 4 additions & 1 deletion numpy/typing/tests/data/pass/lib_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
FILE = StringIO()
AR = np.arange(10, dtype=np.float64)

def func(a: int) -> bool: ...

def func(a: int) -> bool:
return True


np.byte_bounds(AR)
np.byte_bounds(np.float64())
Expand Down
26 changes: 20 additions & 6 deletions numpy/typing/tests/data/pass/ufunc_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,32 @@

import numpy as np

def func1(a: str, b: int) -> None: ...
def func2(a: str, b: int, c: float = ...) -> None: ...
def func3(a: str, b: int) -> int: ...

def func1(a: str, b: int) -> None:
return None


def func2(a: str, b: int, c: float = 1.0) -> None:
return None


def func3(a: str, b: int) -> int:
return 0


class Write1:
def write(self, a: str) -> None: ...
def write(self, a: str) -> None:
return None


class Write2:
def write(self, a: str, b: int = ...) -> None: ...
def write(self, a: str, b: int = 1) -> None:
return None


class Write3:
def write(self, a: str) -> int: ...
def write(self, a: str) -> int:
return 0


_err_default = np.geterr()
Expand Down
104 changes: 44 additions & 60 deletions numpy/typing/tests/data/reveal/arithmetic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -343,184 +343,168 @@ reveal_type(c8 / b_) # E: {complex64}

# Complex

reveal_type(c16 + f16) # E: {complex256}
reveal_type(c16 + f16) # E: complexfloating[Union[_64Bit, _128Bit], Union[_64Bit, _128Bit]]
reveal_type(c16 + c16) # E: {complex128}
reveal_type(c16 + f8) # E: {complex128}
reveal_type(c16 + i8) # E: {complex128}
reveal_type(c16 + c8) # E: {complex128}
reveal_type(c16 + f4) # E: {complex128}
reveal_type(c16 + i4) # E: {complex128}
reveal_type(c16 + c8) # E: complexfloating[Union[_64Bit, _32Bit], Union[_64Bit, _32Bit]]
reveal_type(c16 + f4) # E: complexfloating[Union[_64Bit, _32Bit], Union[_64Bit, _32Bit]]
reveal_type(c16 + i4) # E: complexfloating[Union[_64Bit, _32Bit], Union[_64Bit, _32Bit]]
reveal_type(c16 + b_) # E: {complex128}
reveal_type(c16 + b) # E: {complex128}
reveal_type(c16 + c) # E: {complex128}
reveal_type(c16 + f) # E: {complex128}
reveal_type(c16 + i) # E: {complex128}
reveal_type(c16 + AR_f) # E: Any

reveal_type(f16 + c16) # E: {complex256}
reveal_type(f16 + c16) # E: complexfloating[Union[_64Bit, _128Bit], Union[_64Bit, _128Bit]]
reveal_type(c16 + c16) # E: {complex128}
reveal_type(f8 + c16) # E: {complex128}
reveal_type(i8 + c16) # E: {complex128}
reveal_type(c8 + c16) # E: {complex128}
reveal_type(f4 + c16) # E: {complex128}
reveal_type(i4 + c16) # E: {complex128}
reveal_type(c8 + c16) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(f4 + c16) # E: complexfloating[Union[_64Bit, _32Bit], Union[_64Bit, _32Bit]]
reveal_type(i4 + c16) # E: complexfloating[Union[_64Bit, _32Bit], Union[_64Bit, _32Bit]]
reveal_type(b_ + c16) # E: {complex128}
reveal_type(b + c16) # E: {complex128}
reveal_type(c + c16) # E: {complex128}
reveal_type(f + c16) # E: {complex128}
reveal_type(i + c16) # E: {complex128}
reveal_type(AR_f + c16) # E: Any

reveal_type(c8 + f16) # E: {complex256}
reveal_type(c8 + c16) # E: {complex128}
reveal_type(c8 + f8) # E: {complex128}
reveal_type(c8 + i8) # E: {complex128}
reveal_type(c8 + f16) # E: complexfloating[Union[_32Bit, _128Bit], Union[_32Bit, _128Bit]]
reveal_type(c8 + c16) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(c8 + f8) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(c8 + i8) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(c8 + c8) # E: {complex64}
reveal_type(c8 + f4) # E: {complex64}
reveal_type(c8 + i4) # E: {complex64}
reveal_type(c8 + b_) # E: {complex64}
reveal_type(c8 + b) # E: {complex64}
reveal_type(c8 + c) # E: {complex128}
reveal_type(c8 + f) # E: {complex128}
reveal_type(c8 + i) # E: complexfloating[{_NBitInt}, {_NBitInt}]
reveal_type(c8 + c) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(c8 + f) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(c8 + AR_f) # E: Any

reveal_type(f16 + c8) # E: {complex256}
reveal_type(c16 + c8) # E: {complex128}
reveal_type(f8 + c8) # E: {complex128}
reveal_type(i8 + c8) # E: {complex128}
reveal_type(f16 + c8) # E: complexfloating[Union[_32Bit, _128Bit], Union[_32Bit, _128Bit]]
reveal_type(c16 + c8) # E: complexfloating[Union[_64Bit, _32Bit], Union[_64Bit, _32Bit]]
reveal_type(f8 + c8) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(i8 + c8) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(c8 + c8) # E: {complex64}
reveal_type(f4 + c8) # E: {complex64}
reveal_type(i4 + c8) # E: {complex64}
reveal_type(b_ + c8) # E: {complex64}
reveal_type(b + c8) # E: {complex64}
reveal_type(c + c8) # E: {complex128}
reveal_type(f + c8) # E: {complex128}
reveal_type(i + c8) # E: complexfloating[{_NBitInt}, {_NBitInt}]
reveal_type(c + c8) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(f + c8) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(AR_f + c8) # E: Any

# Float

reveal_type(f8 + f16) # E: {float128}
reveal_type(f8 + f16) # E: floating[Union[_64Bit, _128Bit]]
reveal_type(f8 + f8) # E: {float64}
reveal_type(f8 + i8) # E: {float64}
reveal_type(f8 + f4) # E: {float64}
reveal_type(f8 + i4) # E: {float64}
reveal_type(f8 + f4) # E: floating[Union[_64Bit, _32Bit]]
reveal_type(f8 + i4) # E: floating[Union[_64Bit, _32Bit]]
reveal_type(f8 + b_) # E: {float64}
reveal_type(f8 + b) # E: {float64}
reveal_type(f8 + c) # E: {complex128}
reveal_type(f8 + f) # E: {float64}
reveal_type(f8 + i) # E: {float64}
reveal_type(f8 + AR_f) # E: Any

reveal_type(f16 + f8) # E: {float128}
reveal_type(f16 + f8) # E: floating[Union[_128Bit, _64Bit]]
reveal_type(f8 + f8) # E: {float64}
reveal_type(i8 + f8) # E: {float64}
reveal_type(f4 + f8) # E: {float64}
reveal_type(i4 + f8) # E: {float64}
reveal_type(f4 + f8) # E: floating[Union[_32Bit, _64Bit]]
reveal_type(i4 + f8) # E: floating[Union[_64Bit, _32Bit]]
reveal_type(b_ + f8) # E: {float64}
reveal_type(b + f8) # E: {float64}
reveal_type(c + f8) # E: {complex128}
reveal_type(f + f8) # E: {float64}
reveal_type(i + f8) # E: {float64}
reveal_type(AR_f + f8) # E: Any

reveal_type(f4 + f16) # E: {float128}
reveal_type(f4 + f8) # E: {float64}
reveal_type(f4 + i8) # E: {float64}
reveal_type(f4 + f16) # E: floating[Union[_32Bit, _128Bit]]
reveal_type(f4 + f8) # E: floating[Union[_32Bit, _64Bit]]
reveal_type(f4 + i8) # E: floating[Union[_32Bit, _64Bit]]
reveal_type(f4 + f4) # E: {float32}
reveal_type(f4 + i4) # E: {float32}
reveal_type(f4 + b_) # E: {float32}
reveal_type(f4 + b) # E: {float32}
reveal_type(f4 + c) # E: {complex128}
reveal_type(f4 + f) # E: {float64}
reveal_type(f4 + i) # E: floating[{_NBitInt}]
reveal_type(f4 + c) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(f4 + f) # E: floating[Union[_32Bit, _64Bit]]
reveal_type(f4 + AR_f) # E: Any

reveal_type(f16 + f4) # E: {float128}
reveal_type(f8 + f4) # E: {float64}
reveal_type(i8 + f4) # E: {float64}
reveal_type(f16 + f4) # E: floating[Union[_128Bit, _32Bit]]
reveal_type(f8 + f4) # E: floating[Union[_64Bit, _32Bit]]
reveal_type(i8 + f4) # E: floating[Union[_32Bit, _64Bit]]
reveal_type(f4 + f4) # E: {float32}
reveal_type(i4 + f4) # E: {float32}
reveal_type(b_ + f4) # E: {float32}
reveal_type(b + f4) # E: {float32}
reveal_type(c + f4) # E: {complex128}
reveal_type(f + f4) # E: {float64}
reveal_type(i + f4) # E: floating[{_NBitInt}]
reveal_type(c + f4) # E: complexfloating[Union[_32Bit, _64Bit], Union[_32Bit, _64Bit]]
reveal_type(f + f4) # E: floating[Union[_32Bit, _64Bit]]
reveal_type(AR_f + f4) # E: Any

# Int

reveal_type(i8 + i8) # E: {int64}
reveal_type(i8 + u8) # E: Any
reveal_type(i8 + i4) # E: {int64}
reveal_type(i8 + i4) # E: signedinteger[Union[_64Bit, _32Bit]]
reveal_type(i8 + u4) # E: Any
reveal_type(i8 + b_) # E: {int64}
reveal_type(i8 + b) # E: {int64}
reveal_type(i8 + c) # E: {complex128}
reveal_type(i8 + f) # E: {float64}
reveal_type(i8 + i) # E: {int64}
reveal_type(i8 + AR_f) # E: Any

reveal_type(u8 + u8) # E: {uint64}
reveal_type(u8 + i4) # E: Any
reveal_type(u8 + u4) # E: {uint64}
reveal_type(u8 + u4) # E: signedinteger[Union[_64Bit, _32Bit]]
reveal_type(u8 + b_) # E: {uint64}
reveal_type(u8 + b) # E: {uint64}
reveal_type(u8 + c) # E: {complex128}
reveal_type(u8 + f) # E: {float64}
reveal_type(u8 + i) # E: Any
reveal_type(u8 + AR_f) # E: Any

reveal_type(i8 + i8) # E: {int64}
reveal_type(u8 + i8) # E: Any
reveal_type(i4 + i8) # E: {int64}
reveal_type(i4 + i8) # E: signedinteger[Union[_32Bit, _64Bit]]
reveal_type(u4 + i8) # E: Any
reveal_type(b_ + i8) # E: {int64}
reveal_type(b + i8) # E: {int64}
reveal_type(c + i8) # E: {complex128}
reveal_type(f + i8) # E: {float64}
reveal_type(i + i8) # E: {int64}
reveal_type(AR_f + i8) # E: Any

reveal_type(u8 + u8) # E: {uint64}
reveal_type(i4 + u8) # E: Any
reveal_type(u4 + u8) # E: {uint64}
reveal_type(u4 + u8) # E: unsignedinteger[Union[_32Bit, _64Bit]]
reveal_type(b_ + u8) # E: {uint64}
reveal_type(b + u8) # E: {uint64}
reveal_type(c + u8) # E: {complex128}
reveal_type(f + u8) # E: {float64}
reveal_type(i + u8) # E: Any
reveal_type(AR_f + u8) # E: Any

reveal_type(i4 + i8) # E: {int64}
reveal_type(i4 + i8) # E: signedinteger[Union[_32Bit, _64Bit]]
reveal_type(i4 + i4) # E: {int32}
reveal_type(i4 + i) # E: {int_}
reveal_type(i4 + b_) # E: {int32}
reveal_type(i4 + b) # E: {int32}
reveal_type(i4 + AR_f) # E: Any

reveal_type(u4 + i8) # E: Any
reveal_type(u4 + i4) # E: Any
reveal_type(u4 + u8) # E: {uint64}
reveal_type(u4 + u8) # E: unsignedinteger[Union[_32Bit, _64Bit]]
reveal_type(u4 + u4) # E: {uint32}
reveal_type(u4 + i) # E: Any
reveal_type(u4 + b_) # E: {uint32}
reveal_type(u4 + b) # E: {uint32}
reveal_type(u4 + AR_f) # E: Any

reveal_type(i8 + i4) # E: {int64}
reveal_type(i8 + i4) # E: signedinteger[Union[_64Bit, _32Bit]]
reveal_type(i4 + i4) # E: {int32}
reveal_type(i + i4) # E: {int_}
reveal_type(b_ + i4) # E: {int32}
reveal_type(b + i4) # E: {int32}
reveal_type(AR_f + i4) # E: Any

reveal_type(i8 + u4) # E: Any
reveal_type(i4 + u4) # E: Any
reveal_type(u8 + u4) # E: {uint64}
reveal_type(u8 + u4) # E: unsignedinteger[Union[_64Bit, _32Bit]]
reveal_type(u4 + u4) # E: {uint32}
reveal_type(b_ + u4) # E: {uint32}
reveal_type(b + u4) # E: {uint32}
reveal_type(i + u4) # E: Any
reveal_type(AR_f + u4) # E: Any
16 changes: 5 additions & 11 deletions numpy/typing/tests/data/reveal/bitwise_ops.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,11 @@ reveal_type(i4 | i4) # E: {int32}
reveal_type(i4 ^ i4) # E: {int32}
reveal_type(i4 & i4) # E: {int32}

reveal_type(i8 << i4) # E: {int64}
reveal_type(i8 >> i4) # E: {int64}
reveal_type(i8 | i4) # E: {int64}
reveal_type(i8 ^ i4) # E: {int64}
reveal_type(i8 & i4) # E: {int64}

reveal_type(i8 << i) # E: {int64}
reveal_type(i8 >> i) # E: {int64}
reveal_type(i8 | i) # E: {int64}
reveal_type(i8 ^ i) # E: {int64}
reveal_type(i8 & i) # E: {int64}
reveal_type(i8 << i4) # E: signedinteger[Union[_64Bit, _32Bit]]
reveal_type(i8 >> i4) # E: signedinteger[Union[_64Bit, _32Bit]]
reveal_type(i8 | i4) # E: signedinteger[Union[_64Bit, _32Bit]]
reveal_type(i8 ^ i4) # E: signedinteger[Union[_64Bit, _32Bit]]
reveal_type(i8 & i4) # E: signedinteger[Union[_64Bit, _32Bit]]

reveal_type(i8 << b_) # E: {int64}
reveal_type(i8 >> b_) # E: {int64}
Expand Down
Loading

0 comments on commit a0c70f3

Please sign in to comment.