Skip to content

Commit d8f7b9f

Browse files
committed
!squash
1 parent 008ee4d commit d8f7b9f

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/unihan_etl/validator.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import typing as t
2-
1+
"""Experimental pydantic models for unihan data."""
32
import pydantic
43

54
from 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

tests/test_validator.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
"""Test expansion of multi-value fields in UNIHAN."""
22
import typing as t
33

4-
import pytest
5-
6-
from unihan_etl import constants, validator
4+
from unihan_etl import validator
75

86
if t.TYPE_CHECKING:
9-
from typing_extensions import TypeAlias
7+
pass
108

119

1210
def 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

0 commit comments

Comments
 (0)