Skip to content

Commit af9bd8d

Browse files
committed
Apply ruff-format fixes to AttributeType implementation
1 parent 055c9c6 commit af9bd8d

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

src/datajoint/attribute_adapter.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ def dtype(self) -> str:
8383
attr_type = self.attribute_type
8484
if attr_type is None:
8585
raise NotImplementedError(
86-
f"{self.__class__.__name__} must define 'attribute_type' "
87-
"(or migrate to AttributeType with 'dtype')"
86+
f"{self.__class__.__name__} must define 'attribute_type' " "(or migrate to AttributeType with 'dtype')"
8887
)
8988
return attr_type
9089

@@ -109,9 +108,7 @@ def put(self, obj: Any) -> Any:
109108
Returns:
110109
Value to store in the database.
111110
"""
112-
raise NotImplementedError(
113-
f"{self.__class__.__name__} must implement put() or migrate to encode()"
114-
)
111+
raise NotImplementedError(f"{self.__class__.__name__} must implement put() or migrate to encode()")
115112

116113
def get(self, value: Any) -> Any:
117114
"""
@@ -126,9 +123,7 @@ def get(self, value: Any) -> Any:
126123
Returns:
127124
Object of the adapted type.
128125
"""
129-
raise NotImplementedError(
130-
f"{self.__class__.__name__} must implement get() or migrate to decode()"
131-
)
126+
raise NotImplementedError(f"{self.__class__.__name__} must implement get() or migrate to decode()")
132127

133128

134129
def get_adapter(context: dict | None, adapter_name: str) -> AttributeType:
@@ -158,8 +153,7 @@ def get_adapter(context: dict | None, adapter_name: str) -> AttributeType:
158153
# Fall back to context-based lookup (legacy system)
159154
if context is None:
160155
raise DataJointError(
161-
f"Attribute type <{adapter_name}> is not registered. "
162-
"Use @dj.register_type to register custom types."
156+
f"Attribute type <{adapter_name}> is not registered. " "Use @dj.register_type to register custom types."
163157
)
164158

165159
try:
@@ -184,8 +178,6 @@ def get_adapter(context: dict | None, adapter_name: str) -> AttributeType:
184178
# Validate the dtype/attribute_type
185179
dtype = adapter.dtype
186180
if not isinstance(dtype, str) or not re.match(r"^\w", dtype):
187-
raise DataJointError(
188-
f"Invalid dtype '{dtype}' in attribute type <{adapter_name}>"
189-
)
181+
raise DataJointError(f"Invalid dtype '{dtype}' in attribute type <{adapter_name}>")
190182

191183
return adapter

src/datajoint/attribute_type.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ class GraphType(dj.AttributeType):
232232
existing = _type_registry[name]
233233
if type(existing) is not cls:
234234
raise DataJointError(
235-
f"Type <{name}> is already registered by "
236-
f"{type(existing).__module__}.{type(existing).__name__}"
235+
f"Type <{name}> is already registered by " f"{type(existing).__module__}.{type(existing).__name__}"
237236
)
238237
# Same class registered twice - idempotent, no error
239238
return cls
@@ -290,8 +289,7 @@ def get_type(name: str) -> AttributeType:
290289
return _type_registry[name]
291290

292291
raise DataJointError(
293-
f"Unknown attribute type: <{name}>. "
294-
f"Ensure the type is registered via @dj.register_type or installed as a package."
292+
f"Unknown attribute type: <{name}>. " f"Ensure the type is registered via @dj.register_type or installed as a package."
295293
)
296294

297295

src/datajoint/heading.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def decode(self, stored, *, key=None):
4646
"Register it with @dj.register_type or include it in the schema context."
4747
)
4848

49+
4950
logger = logging.getLogger(__name__.split(".")[0])
5051

5152
default_attribute_properties = dict( # these default values are set in computed attributes
@@ -322,9 +323,7 @@ def _init_from_database(self):
322323
else:
323324
attr.update(type=attr["adapter"].dtype)
324325
if not any(r.match(attr["type"]) for r in TYPE_PATTERN.values()):
325-
raise DataJointError(
326-
f"Invalid dtype '{attr['type']}' in attribute type <{adapter_name}>."
327-
)
326+
raise DataJointError(f"Invalid dtype '{attr['type']}' in attribute type <{adapter_name}>.")
328327
special = not any(TYPE_PATTERN[c].match(attr["type"]) for c in NATIVE_TYPES)
329328

330329
if special:

0 commit comments

Comments
 (0)