Skip to content

Commit 08c87d7

Browse files
committed
style: apply ruff formatting and update gts-spec submodule
1 parent ea5be19 commit 08c87d7

4 files changed

Lines changed: 13 additions & 15 deletions

File tree

gts/src/gts/entities.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def _get_field_value(self, field: str) -> Optional[str]:
292292

293293
def _first_non_empty_field(self, fields: List[str]) -> Optional[Tuple[str, str]]:
294294
"""Find first non-empty field value in order.
295-
295+
296296
Returns the first non-empty string value without preferring GTS IDs.
297297
This ensures UUID and non-GTS values are returned when they appear first.
298298
"""
@@ -313,7 +313,7 @@ def _calc_json_entity_id(self, cfg: GtsConfig) -> str:
313313

314314
def _calc_json_schema_id(self, cfg: GtsConfig) -> Optional[str]:
315315
"""Calculate schema_id based on entity type and content.
316-
316+
317317
Rules:
318318
- For schemas: extract parent from $id chain, or fallback to $schema
319319
- For instances: look for type/schema fields in schema_id_fields
@@ -335,7 +335,7 @@ def _calc_json_schema_id(self, cfg: GtsConfig) -> Optional[str]:
335335
if prev_tilde > 0:
336336
# Has a parent chain - return first segment (base type)
337337
self.selected_schema_id_field = "$id"
338-
return prefix[:prev_tilde + 1]
338+
return prefix[: prev_tilde + 1]
339339
else:
340340
# Single segment schema - base type, return $schema
341341
schema_val = self._get_field_value("$schema")
@@ -348,7 +348,7 @@ def _calc_json_schema_id(self, cfg: GtsConfig) -> Optional[str]:
348348
self.selected_schema_id_field = "$schema"
349349
return schema_val
350350
return None
351-
351+
352352
# For instances, look in schema_id_fields
353353
cand = self._first_non_empty_field(cfg.schema_id_fields)
354354
if cand:
@@ -359,9 +359,9 @@ def _calc_json_schema_id(self, cfg: GtsConfig) -> Optional[str]:
359359
last_tilde = schema_id.rfind("~")
360360
if last_tilde > 0 and not schema_id.endswith("~"):
361361
# It's an instance ID in type field - extract schema part
362-
return schema_id[:last_tilde + 1]
362+
return schema_id[: last_tilde + 1]
363363
return schema_id
364-
364+
365365
# For instances with chained GTS ID in entity_id field, derive schema_id
366366
# BUT only if the ID is a proper chained instance ID (not a single schema segment)
367367
if self.selected_entity_field and self.selected_entity_field != "$id":
@@ -374,8 +374,8 @@ def _calc_json_schema_id(self, cfg: GtsConfig) -> Optional[str]:
374374
last_tilde = idv.rfind("~")
375375
if last_tilde > 0:
376376
self.selected_schema_id_field = self.selected_entity_field
377-
return idv[:last_tilde + 1]
378-
377+
return idv[: last_tilde + 1]
378+
379379
# No schema reference found for instance
380380
# Note: Single-segment schema IDs in $id don't count as schema_id for instances
381381
return None

gts/src/gts/ops.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,15 @@ def add_entity(
316316
self, content: Dict[str, Any], validate: bool = False
317317
) -> GtsAddEntityResult:
318318
entity = GtsEntity(content=content, cfg=self.cfg)
319-
319+
320320
# For instances (non-schemas), require an id field
321321
if not entity.is_schema:
322322
# Instance must have an id from entity_id_fields (not just derived from schema)
323323
if not entity.raw_id or not entity.selected_entity_field:
324324
return GtsAddEntityResult(
325-
ok=False,
326-
error="Instance must have an id field",
327-
is_schema=False
325+
ok=False, error="Instance must have an id field", is_schema=False
328326
)
329-
327+
330328
# Schemas MUST have a valid GTS ID
331329
if entity.is_schema and not entity.gts_id:
332330
return GtsAddEntityResult(

gts/src/gts/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _populate_from_reader(self) -> None:
135135

136136
def register(self, entity: GtsEntity) -> None:
137137
"""Register a GtsEntity in the store.
138-
138+
139139
If entity has a valid gts_id, use that as the key.
140140
Otherwise, use raw_id for non-GTS entities.
141141
"""

0 commit comments

Comments
 (0)