@@ -79,6 +79,7 @@ def append_type(type_dict: dict, new_type: str) -> dict:
79
79
return result
80
80
81
81
82
+ @lru_cache
82
83
def is_secret_type (type_dict : dict ) -> bool :
83
84
"""Return True if JSON Schema type definition appears to be a secret.
84
85
@@ -109,6 +110,7 @@ def is_secret_type(type_dict: dict) -> bool:
109
110
return False
110
111
111
112
113
+ @lru_cache
112
114
def is_object_type (property_schema : dict ) -> bool | None :
113
115
"""Return true if the JSON Schema type is an object or None if detection fails."""
114
116
if "anyOf" not in property_schema and "type" not in property_schema :
@@ -122,6 +124,7 @@ def is_object_type(property_schema: dict) -> bool | None:
122
124
)
123
125
124
126
127
+ @lru_cache
125
128
def is_uniform_list (property_schema : dict ) -> bool | None :
126
129
"""Return true if the JSON Schema type is an array with a single schema.
127
130
@@ -136,6 +139,7 @@ def is_uniform_list(property_schema: dict) -> bool | None:
136
139
)
137
140
138
141
142
+ @lru_cache
139
143
def is_datetime_type (type_dict : dict ) -> bool :
140
144
"""Return True if JSON Schema type definition is a 'date-time' type.
141
145
@@ -155,6 +159,7 @@ def is_datetime_type(type_dict: dict) -> bool:
155
159
raise ValueError (msg )
156
160
157
161
162
+ @lru_cache
158
163
def is_date_or_datetime_type (type_dict : dict ) -> bool :
159
164
"""Return True if JSON Schema type definition is a 'date'/'date-time' type.
160
165
@@ -186,6 +191,7 @@ def is_date_or_datetime_type(type_dict: dict) -> bool:
186
191
raise ValueError (msg )
187
192
188
193
194
+ @lru_cache
189
195
def get_datelike_property_type (property_schema : dict ) -> str | None :
190
196
"""Return one of 'date-time', 'time', or 'date' if property is date-like.
191
197
@@ -200,6 +206,7 @@ def get_datelike_property_type(property_schema: dict) -> str | None:
200
206
return None
201
207
202
208
209
+ @lru_cache
203
210
def _is_string_with_format (type_dict : dict [str , t .Any ]) -> bool | None :
204
211
if "string" in type_dict .get ("type" , []) and type_dict .get ("format" ) in {
205
212
"date-time" ,
@@ -236,6 +243,7 @@ def handle_invalid_timestamp_in_record(
236
243
raise ValueError (msg )
237
244
238
245
246
+ @lru_cache
239
247
def is_string_array_type (type_dict : dict ) -> bool :
240
248
"""Return True if JSON Schema type definition is a string array."""
241
249
if not type_dict :
@@ -254,6 +262,7 @@ def is_string_array_type(type_dict: dict) -> bool:
254
262
return "array" in type_dict ["type" ] and bool (is_string_type (type_dict ["items" ]))
255
263
256
264
265
+ @lru_cache
257
266
def is_array_type (type_dict : dict ) -> bool :
258
267
"""Return True if JSON Schema type is an array."""
259
268
if not type_dict :
@@ -272,6 +281,7 @@ def is_array_type(type_dict: dict) -> bool:
272
281
return "array" in type_dict ["type" ]
273
282
274
283
284
+ @lru_cache
275
285
def is_boolean_type (property_schema : dict ) -> bool | None :
276
286
"""Return true if the JSON Schema type is a boolean or None if detection fails."""
277
287
if "anyOf" not in property_schema and "type" not in property_schema :
@@ -287,6 +297,7 @@ def is_boolean_type(property_schema: dict) -> bool | None:
287
297
return False
288
298
289
299
300
+ @lru_cache
290
301
def _is_exclusive_boolean_type (property_schema : dict ) -> bool :
291
302
if "type" not in property_schema :
292
303
return False
@@ -298,6 +309,7 @@ def _is_exclusive_boolean_type(property_schema: dict) -> bool:
298
309
)
299
310
300
311
312
+ @lru_cache
301
313
def is_integer_type (property_schema : dict ) -> bool | None :
302
314
"""Return true if the JSON Schema type is an integer or None if detection fails."""
303
315
if "anyOf" not in property_schema and "type" not in property_schema :
@@ -313,6 +325,7 @@ def is_integer_type(property_schema: dict) -> bool | None:
313
325
return False
314
326
315
327
328
+ @lru_cache
316
329
def is_string_type (property_schema : dict ) -> bool | None :
317
330
"""Return true if the JSON Schema type is a string or None if detection fails."""
318
331
if "anyOf" not in property_schema and "type" not in property_schema :
@@ -328,6 +341,7 @@ def is_string_type(property_schema: dict) -> bool | None:
328
341
return False
329
342
330
343
344
+ @lru_cache
331
345
def is_null_type (property_schema : dict ) -> bool | None :
332
346
"""Return true if the JSON Schema type is a null or None if detection fails."""
333
347
if "anyOf" not in property_schema and "type" not in property_schema :
@@ -343,6 +357,7 @@ def is_null_type(property_schema: dict) -> bool | None:
343
357
return False
344
358
345
359
360
+ @lru_cache
346
361
def is_number_type (property_schema : dict ) -> bool | None :
347
362
"""Return true if the JSON Schema type is a number or None if detection fails."""
348
363
if "anyOf" not in property_schema and "type" not in property_schema :
0 commit comments