Skip to content

Commit 736860e

Browse files
Make Codec.get_dtype() an abstractmethod for consistency
All required codec methods (get_dtype, encode, decode) now use @AbstractMethod to catch missing implementations at class definition time rather than runtime. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent aa1db4f commit 736860e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/datajoint/codecs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def __init_subclass__(cls, *, register: bool = True, **kwargs):
119119
_codec_registry[cls.name] = cls()
120120
logger.debug(f"Registered codec <{cls.name}> from {cls.__module__}.{cls.__name__}")
121121

122+
@abstractmethod
122123
def get_dtype(self, is_external: bool) -> str:
123124
"""
124125
Return the storage dtype for this codec.
@@ -136,12 +137,10 @@ def get_dtype(self, is_external: bool) -> str:
136137
137138
Raises
138139
------
139-
NotImplementedError
140-
If not overridden by subclass.
141140
DataJointError
142141
If external storage not supported but requested.
143142
"""
144-
raise NotImplementedError(f"Codec <{self.name}> must implement get_dtype()")
143+
...
145144

146145
@abstractmethod
147146
def encode(self, value: Any, *, key: dict | None = None, store_name: str | None = None) -> Any:

0 commit comments

Comments
 (0)