diff --git a/cubed/primitive/memory.py b/cubed/primitive/memory.py index 8c49f22aa..d7ae67586 100644 --- a/cubed/primitive/memory.py +++ b/cubed/primitive/memory.py @@ -16,7 +16,7 @@ class BufferCopies: """The number of copies made when writing an array to storage.""" -def get_buffer_copies(spec: Optional[Spec]): +def get_buffer_copies(spec: Optional[Spec]) -> BufferCopies: """Return the number of buffer copies to use, based on the spec. Using cloud storage will result in more buffer copies being accounted for. @@ -84,10 +84,10 @@ class MemoryModeller: current_mem: int = 0 peak_mem: int = 0 - def allocate(self, num_bytes): + def allocate(self, num_bytes: int) -> None: self.current_mem += num_bytes self.peak_mem = max(self.peak_mem, self.current_mem) - def free(self, num_bytes): + def free(self, num_bytes: int) -> None: self.current_mem -= num_bytes self.peak_mem = max(self.peak_mem, self.current_mem) diff --git a/cubed/utils.py b/cubed/utils.py index f7946ecac..5878d406a 100644 --- a/cubed/utils.py +++ b/cubed/utils.py @@ -1,7 +1,6 @@ import collections import inspect import itertools -import numbers import platform import sys import sysconfig @@ -386,8 +385,8 @@ def normalize_shape(shape: Union[int, Tuple[int, ...], None]) -> Tuple[int, ...] if shape is None: raise TypeError("shape is None") - if isinstance(shape, numbers.Integral): - shape = (int(shape),) + if isinstance(shape, int): + shape = (shape,) shape = cast(Tuple[int, ...], shape) shape = tuple(int(s) for s in shape) diff --git a/pyproject.toml b/pyproject.toml index e253f0549..53828884c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -146,3 +146,22 @@ known-third-party = [ "toolz", "zarr", ] + +[tool.mypy] +files = "cubed" +python_version = "3.11" +strict = false +enable_error_code = ["truthy-bool"] +ignore_missing_imports = true +allow_redefinition= true +exclude = [ + "cubed/array_api", + "cubed/tests", + "cubed/vendor", + "docs" +] + +[[tool.mypy.overrides]] +# Ignore vendored libraries +module = [ "cubed.array_api.*", "cubed.vendor.*", ] +ignore_errors = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 51c35ec15..000000000 --- a/setup.cfg +++ /dev/null @@ -1,87 +0,0 @@ -[mypy] -exclude = tests|doc -files = . -show_error_codes = True -allow_redefinition = True - -# Ignore vendored libraries -[mypy-cubed.vendor.*] -ignore_errors = True - -# Most of the numerical computing stack doesn't have type annotations yet. -[mypy-anywidget.*] -ignore_missing_imports = True -[mypy-apache_beam.*] -ignore_missing_imports = True -[mypy-aiostream.*] -ignore_missing_imports = True -[mypy-array_api_compat.*] -ignore_missing_imports = True -[mypy-cloudpickle.*] -ignore_missing_imports = True -[mypy-coiled.*] -ignore_missing_imports = True -[mypy-cupy.*] -ignore_missing_imports = True -[mypy-dask.*] -ignore_missing_imports = True -[mypy-donfig.*] -ignore_missing_imports = True -[mypy-distributed.*] -ignore_missing_imports = True -[mypy-fsspec.*] -ignore_missing_imports = True -[mypy-icechunk.*] -ignore_missing_imports = True -[mypy-ipywidgets.*] -ignore_missing_imports = True -[mypy-IPython.*] -ignore_missing_imports = True -[mypy-lithops.*] -ignore_missing_imports = True -[mypy-memray.*] -ignore_missing_imports = True -[mypy-modal.*] -ignore_missing_imports = True -[mypy-matplotlib.*] -ignore_missing_imports = True -[mypy-ndindex.*] -ignore_missing_imports = True -[mypy-networkx.*] -ignore_missing_imports = True -[mypy-numcodecs.*] -ignore_missing_imports = True -[mypy-numpy.*] -ignore_missing_imports = True -[mypy-obstore.*] -ignore_missing_imports = True -[mypy-pandas.*] -ignore_missing_imports = True -[mypy-psutil.*] -ignore_missing_imports = True -[mypy-pytest.*] -ignore_missing_imports = True -[mypy-ray.*] -ignore_missing_imports = True -[mypy-rechunker.*] -ignore_missing_imports = True -[mypy-seaborn.*] -ignore_missing_imports = True -[mypy-six.*] -ignore_missing_imports = True -[mypy-tenacity.*] -ignore_missing_imports = True -[mypy-tensorstore.*] -ignore_missing_imports = True -[mypy-tlz.*] -ignore_missing_imports = True -[mypy-toolz.*] -ignore_missing_imports = True -[mypy-tqdm.*] -ignore_missing_imports = True -[mypy-zarr.*] -ignore_missing_imports = True -[mypy-zarrs.*] -ignore_missing_imports = True -[mypy-pyspark.*] -ignore_missing_imports = True