Skip to content

Commit

Permalink
Make container structure just None. (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan authored Aug 5, 2023
1 parent 1cc0347 commit 5c46523
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion docs/source/reference/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ See {doc}`../explanations/structures` for more context.
tiled.structures.array.BuiltinDtype
tiled.structures.array.Endianness
tiled.structures.array.Kind
tiled.structures.container.ContainerStructure
tiled.structures.core.Spec
tiled.structures.core.StructureFamily
tiled.structures.table.TableStructure
Expand Down
3 changes: 1 addition & 2 deletions tiled/adapters/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
StructureFamilyQuery,
)
from ..query_registration import QueryTranslationRegistry
from ..structures.container import ContainerStructure
from ..structures.core import StructureFamily
from ..utils import UNCHANGED
from .utils import IndexersMixin
Expand Down Expand Up @@ -152,7 +151,7 @@ def items(self):
return ItemsView(lambda: len(self), self._items_slice)

def structure(self):
return ContainerStructure(count=len(self._mapping))
return None

@property
def metadata_stale_at(self):
Expand Down
10 changes: 8 additions & 2 deletions tiled/catalog/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ async def register_single_item(
data_sources=[
DataSource(
mimetype=mimetype,
structure=dataclasses.asdict(adapter.structure()),
structure=dict_or_none(adapter.structure()),
parameters={},
management=Management.external,
assets=[
Expand Down Expand Up @@ -365,7 +365,7 @@ async def tiff_sequence(
data_sources=[
DataSource(
mimetype=mimetype,
structure=dataclasses.asdict(adapter.structure()),
structure=dict_or_none(adapter.structure()),
parameters={},
management=Management.external,
assets=[
Expand Down Expand Up @@ -539,3 +539,9 @@ async def create_node_safe(
" COLLISION: Multiple files would result in node at '%s'. Skipping all.",
err.args[0],
)


def dict_or_none(structure):
if structure is None:
return None
return dataclasses.asdict(structure)
2 changes: 2 additions & 0 deletions tiled/server/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ class WrongTypeForRoute(Exception):

def asdict(dc):
"Compat for converting dataclass or pydantic.BaseModel to dict."
if dc is None:
return None
try:
return dataclasses.asdict(dc)
except TypeError:
Expand Down
6 changes: 0 additions & 6 deletions tiled/structures/container.py

This file was deleted.

0 comments on commit 5c46523

Please sign in to comment.