From 21dc538dd6ee20253b9f03f0dc5ac0b045008a35 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:07:10 +0200 Subject: [PATCH] Type-checking requires `torch` --- pyproject.toml | 5 +++-- src/blosc2/core.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 106820dc..8c23ee26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", ] requires-python = ">=3.10" -# Follow guidlines from https://scientific-python.org/specs/spec-0000/ +# Follow guidelines from https://scientific-python.org/specs/spec-0000/ dependencies = [ "numpy>=1.23.0", "ndindex", @@ -45,7 +45,8 @@ dynamic = ["version"] test = [ "pytest", "psutil", - ] + "torch", +] doc = [ "sphinx", "pydata-sphinx-theme", diff --git a/src/blosc2/core.py b/src/blosc2/core.py index f4f0b8aa..e9905b2c 100644 --- a/src/blosc2/core.py +++ b/src/blosc2/core.py @@ -17,8 +17,8 @@ import pickle import platform import sys -from collections.abc import Callable from dataclasses import asdict +from typing import TYPE_CHECKING import cpuinfo import numpy as np @@ -26,6 +26,11 @@ import blosc2 from blosc2 import blosc2_ext +if TYPE_CHECKING: + from collections.abc import Callable + + import torch + def _check_typesize(typesize): if not 1 <= typesize <= blosc2_ext.MAX_TYPESIZE: