1010from followthemoney .statement .util import get_prop_type , BASE_ID
1111
1212if TYPE_CHECKING :
13- from followthemoney .statement .entity import SE
13+ from followthemoney .statement .entity import StatementEntity
1414
1515
1616class StatementDict (TypedDict ):
1717 id : Optional [str ]
1818 entity_id : str
1919 canonical_id : str
2020 prop : str
21- prop_type : str
2221 schema : str
2322 value : str
2423 dataset : str
@@ -47,7 +46,6 @@ class Statement(object):
4746 "entity_id" ,
4847 "canonical_id" ,
4948 "prop" ,
50- "prop_type" ,
5149 "schema" ,
5250 "value" ,
5351 "dataset" ,
@@ -76,7 +74,6 @@ def __init__(
7674 self .entity_id = entity_id
7775 self .canonical_id = canonical_id or entity_id
7876 self .prop = prop
79- self .prop_type = get_prop_type (schema , prop )
8077 self .schema = schema
8178 self .value = value
8279 self .dataset = dataset
@@ -89,12 +86,16 @@ def __init__(
8986 id = self .generate_key ()
9087 self .id = id
9188
89+ @property
90+ def prop_type (self ) -> str :
91+ """The type of the property, e.g. 'string', 'number', 'url'."""
92+ return get_prop_type (self .schema , self .prop )
93+
9294 def to_dict (self ) -> StatementDict :
9395 return {
9496 "canonical_id" : self .canonical_id ,
9597 "entity_id" : self .entity_id ,
9698 "prop" : self .prop ,
97- "prop_type" : self .prop_type ,
9899 "schema" : self .schema ,
99100 "value" : self .value ,
100101 "dataset" : self .dataset ,
@@ -109,6 +110,7 @@ def to_dict(self) -> StatementDict:
109110 def to_csv_row (self ) -> Dict [str , Optional [str ]]:
110111 data = cast (Dict [str , Optional [str ]], self .to_dict ())
111112 data ["external" ] = bool_text (self .external )
113+ data ["prop_type" ] = self .prop_type
112114 return data
113115
114116 def to_db_row (self ) -> Dict [str , Any ]:
@@ -206,7 +208,7 @@ def from_db_row(cls, row: Row) -> "Statement":
206208 @classmethod
207209 def from_entity (
208210 cls ,
209- entity : "SE" ,
211+ entity : StatementEntity ,
210212 dataset : str ,
211213 first_seen : Optional [str ] = None ,
212214 last_seen : Optional [str ] = None ,
0 commit comments