Skip to content

Commit d2e9949

Browse files
authored
Move mypy configuration to pyproject.toml (#869)
Fix type in util More type annotations
1 parent 54b0851 commit d2e9949

4 files changed

Lines changed: 24 additions & 93 deletions

File tree

cubed/primitive/memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BufferCopies:
1616
"""The number of copies made when writing an array to storage."""
1717

1818

19-
def get_buffer_copies(spec: Optional[Spec]):
19+
def get_buffer_copies(spec: Optional[Spec]) -> BufferCopies:
2020
"""Return the number of buffer copies to use, based on the spec.
2121
2222
Using cloud storage will result in more buffer copies being accounted for.
@@ -84,10 +84,10 @@ class MemoryModeller:
8484
current_mem: int = 0
8585
peak_mem: int = 0
8686

87-
def allocate(self, num_bytes):
87+
def allocate(self, num_bytes: int) -> None:
8888
self.current_mem += num_bytes
8989
self.peak_mem = max(self.peak_mem, self.current_mem)
9090

91-
def free(self, num_bytes):
91+
def free(self, num_bytes: int) -> None:
9292
self.current_mem -= num_bytes
9393
self.peak_mem = max(self.peak_mem, self.current_mem)

cubed/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import collections
22
import inspect
33
import itertools
4-
import numbers
54
import platform
65
import sys
76
import sysconfig
@@ -386,8 +385,8 @@ def normalize_shape(shape: Union[int, Tuple[int, ...], None]) -> Tuple[int, ...]
386385
if shape is None:
387386
raise TypeError("shape is None")
388387

389-
if isinstance(shape, numbers.Integral):
390-
shape = (int(shape),)
388+
if isinstance(shape, int):
389+
shape = (shape,)
391390

392391
shape = cast(Tuple[int, ...], shape)
393392
shape = tuple(int(s) for s in shape)

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,22 @@ known-third-party = [
146146
"toolz",
147147
"zarr",
148148
]
149+
150+
[tool.mypy]
151+
files = "cubed"
152+
python_version = "3.11"
153+
strict = false
154+
enable_error_code = ["truthy-bool"]
155+
ignore_missing_imports = true
156+
allow_redefinition= true
157+
exclude = [
158+
"cubed/array_api",
159+
"cubed/tests",
160+
"cubed/vendor",
161+
"docs"
162+
]
163+
164+
[[tool.mypy.overrides]]
165+
# Ignore vendored libraries
166+
module = [ "cubed.array_api.*", "cubed.vendor.*", ]
167+
ignore_errors = true

setup.cfg

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)