Skip to content

Commit 3ac4195

Browse files
committed
cleanup
1 parent 5db0ee3 commit 3ac4195

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/anyvlm/storage/mapper_registry.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Central registry for all object mappers."""
22

3+
from types import MappingProxyType
34
from typing import TypeVar
45

56
from ga4gh.va_spec.base import CohortAlleleFrequencyStudyResult
@@ -13,15 +14,13 @@
1314
class MapperRegistry:
1415
"""Central registry for all object mappers."""
1516

16-
def __init__(self) -> None:
17-
"""Initialize the MapperRegistry with known mappers."""
18-
self.anyvlm_to_db_mapping = {
19-
CohortAlleleFrequencyStudyResult: orm.AlleleFrequencyData
20-
}
17+
va_model_to_db_mapping: MappingProxyType = MappingProxyType(
18+
{CohortAlleleFrequencyStudyResult: orm.AlleleFrequencyData}
19+
)
2120

22-
self._mappers: dict[type, BaseMapper] = {
23-
orm.AlleleFrequencyData: AlleleFrequencyMapper()
24-
}
21+
_mappers: MappingProxyType[type, BaseMapper] = MappingProxyType(
22+
{orm.AlleleFrequencyData: AlleleFrequencyMapper()}
23+
)
2524

2625
def get_mapper(self, entity_type: type[T]) -> BaseMapper:
2726
"""Get mapper for the given entity type."""
@@ -37,7 +36,7 @@ def from_db_entity(self, db_entity): # noqa: ANN201, ANN001
3736

3837
def to_db_entity(self, anyvlm_entity) -> orm.Base: # noqa: ANN001
3938
"""Convert any VA-Spec model to its corresponding DB entity."""
40-
db_type = self.anyvlm_to_db_mapping.get(type(anyvlm_entity))
39+
db_type = self.va_model_to_db_mapping.get(type(anyvlm_entity))
4140
if db_type is None:
4241
raise ValueError(
4342
f"No DB entity type mapped for VRS model: {type(anyvlm_entity)}"

0 commit comments

Comments
 (0)