File tree Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Original file line number Diff line number Diff line change 1- import typing as t
2-
1+ """Experimental pydantic models for unihan data."""
32import pydantic
43
54from unihan_etl .expansion import expand_kTGHZ2013
@@ -19,7 +18,10 @@ class kTGHZ2013Location(pydantic.BaseModel):
1918 # 0 for a main entry and greater than 0 for a parenthesized or bracketed variant #
2019 # of the main entry
2120 entry_type : int = pydantic .Field (
22- description = "0 for a main entry and greater than 0 for a parenthesized or bracketed variant of the main entry"
21+ description = (
22+ "0 for a main entry and greater than 0 for a parenthesized or bracketed "
23+ + "variant of the main entry"
24+ )
2325 )
2426
2527
@@ -64,16 +66,6 @@ def from_string(cls, value: str) -> "kTGHZ2013":
6466 for out in outs
6567 ],
6668 )
67- # reading=out["reading"],
68- # locations=[
69- # kTGHZ2013Location(
70- # page=location["page"],
71- # position=location["position"],
72- # entry_type=location["entry_type"],
73- # )
74- # for location in out["locations"]
75- # ],
76- # )
7769 elif isinstance (value , dict ):
7870 return pydantic .parse_obj_as (cls , value )
7971 raise pydantic .ValidationError ("Invalid input for kTGHZ2013 model." ) # noqa: TRY003
Original file line number Diff line number Diff line change 11"""Test expansion of multi-value fields in UNIHAN."""
22import typing as t
33
4- import pytest
5-
6- from unihan_etl import constants , validator
4+ from unihan_etl import validator
75
86if t .TYPE_CHECKING :
9- from typing_extensions import TypeAlias
7+ pass
108
119
1210def test_kTGHZ2013 () -> None :
11+ """Example of kTGHZ2013 being parsed via pydantic."""
1312 model = validator .kTGHZ2013 .from_string ("U+3447 kTGHZ2013 482.140:zhòu" )
1413 assert model .ucn == "U+3447"
1514
You can’t perform that action at this time.
0 commit comments