Skip to content

Commit f614ab9

Browse files
authored
Merge pull request #11 from OpenHCSDev/fix/mypy-0.4.1
0.4.1: mypy-clean ArrayOperations cache; mypy blocks CI
2 parents 64b5e76 + 984f123 commit f614ab9

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,5 @@ jobs:
153153
black --check src/
154154
155155
- name: Run mypy (type checking)
156-
continue-on-error: true # Scientific code often has complex types
157156
run: |
158157
mypy src/

‎src/arraybridge/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
NumPy/numcodecs import cost.
1111
"""
1212

13-
__version__ = "0.4.0"
13+
__version__ = "0.4.1"
1414

1515
_LAZY_EXPORTS: dict[str, str] = {
1616
"MemoryType": ".types",

‎src/arraybridge/array_operations.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def _mapped_dtype(target_dtype: Any, module: Any) -> Any:
7878

7979

8080
@cache
81-
def _leaf_instance(leaf: type[ArrayOperations]) -> ArrayOperations:
82-
return leaf()
81+
def _leaf_instance(memory_type_value: str) -> ArrayOperations:
82+
return ArrayOperations.__registry__[memory_type_value]()
8383

8484

8585
class ArrayOperations(metaclass=AutoRegisterMeta):
@@ -98,13 +98,15 @@ class ArrayOperations(metaclass=AutoRegisterMeta):
9898
@classmethod
9999
def for_memory(cls, memory_type: MemoryType) -> ArrayOperations:
100100
"""Return the operations leaf declared for ``memory_type``."""
101-
return _leaf_instance(cls.__registry__[memory_type.value])
101+
return _leaf_instance(memory_type.value)
102102

103103
@cached_property
104104
def module(self) -> Any:
105105
"""The framework module, imported on first use."""
106106
from arraybridge.types import MemoryType
107107

108+
# Only registered leaves are instantiated, and each declares memory_type.
109+
assert self.memory_type is not None
108110
return MemoryType(self.memory_type).import_module()
109111

110112
@property

0 commit comments

Comments
 (0)