Skip to content

Commit 758a156

Browse files
committed
Prepare for higlass-schema pydantic migration
1 parent c16e2b5 commit 758a156

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/higlass/api.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@
1414
)
1515

1616
import higlass_schema as hgs
17-
from pydantic import BaseModel
17+
from pydantic import RootModel
1818

1919
import higlass._display as display
2020
import higlass._utils as utils
2121

2222
__all__ = [
23+
"CombinedTrack",
2324
"EnumTrack",
2425
"HeatmapTrack",
2526
"IndependentViewportProjectionTrack",
26-
"CombinedTrack",
2727
"PluginTrack",
2828
"TrackT",
2929
"View",
3030
"ViewT",
3131
"Viewconf",
32+
"combine",
3233
"concat",
34+
"divide",
3335
"hconcat",
34-
"vconcat",
36+
"lock",
3537
"track",
38+
"vconcat",
3639
"view",
37-
"combine",
38-
"divide",
39-
"lock",
4040
]
4141

4242
if TYPE_CHECKING:
@@ -634,18 +634,18 @@ def mapper(view):
634634
# TODO: register plugins globally to work here?
635635

636636

637-
class _TrackCreator(BaseModel):
637+
class _TrackCreator(RootModel):
638638
"""Create track instances from their track type.
639639
640640
Used internally by `hg.track` to leverage pydantic's ability to get
641641
the appropriate base model by the track type.
642642
643643
Example:
644644
-------
645-
>>> assert isinstance(_TrackCreator(type="heatmap").__root__, HeatmapTrack)
645+
>>> assert isinstance(_TrackCreator(type="heatmap").root, HeatmapTrack)
646646
"""
647647

648-
__root__: Track
648+
root: Track
649649

650650

651651
@overload
@@ -688,7 +688,7 @@ def track(
688688
if uid is None:
689689
uid = utils.uid()
690690
data = dict(type=type_, uid=uid, **kwargs)
691-
return _TrackCreator.parse_obj(data).__root__
691+
return _TrackCreator.model_validate(data).root
692692

693693

694694
def view(

0 commit comments

Comments
 (0)