22
33from __future__ import annotations
44
5+ import logging
56import re
67from collections .abc import Callable
78
89from . import const , grammar , types
910
11+ logger = logging .getLogger (__name__ )
12+
1013
1114def cast_value (text : str , type_id : str ) -> types .DataType | None :
1215 if not text :
1316 return None
1417 payload = const .payloads .get (type_id )
1518 if not payload :
19+ logger .warning ("Encountered unknown data type %s" , type_id )
1620 return None
1721 cast_fuction = CAST_FUNCTIONS .get (payload )
1822 if not cast_fuction :
@@ -146,7 +150,11 @@ def _cast_date_period(value: str) -> types.DatePeriod:
146150 if to_date_match :
147151 res ["to" ] = types .Date (
148152 calendar = to_date_match .group ("calendar" ),
149- day = int (to_date_match .group ("day" )) if to_date_match .group ("day" ) else None ,
153+ day = (
154+ int (to_date_match .group ("day" ))
155+ if to_date_match .group ("day" )
156+ else None
157+ ),
150158 month = to_date_match .group ("month" ),
151159 year = int (to_date_match .group ("year" )),
152160 epoch = to_date_match .group ("epoch" ),
@@ -156,7 +164,11 @@ def _cast_date_period(value: str) -> types.DatePeriod:
156164 if from_date_match :
157165 res ["from_" ] = types .Date (
158166 calendar = from_date_match .group ("calendar" ),
159- day = int (from_date_match .group ("day" )) if from_date_match .group ("day" ) else None ,
167+ day = (
168+ int (from_date_match .group ("day" ))
169+ if from_date_match .group ("day" )
170+ else None
171+ ),
160172 month = from_date_match .group ("month" ),
161173 year = int (from_date_match .group ("year" )),
162174 epoch = from_date_match .group ("epoch" ),
0 commit comments