Skip to content

Commit b10c21d

Browse files
committed
change default to None
1 parent 999b212 commit b10c21d

File tree

1 file changed

+76
-72
lines changed

1 file changed

+76
-72
lines changed

synapseclient/models/mixins/json_schema.py

Lines changed: 76 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,22 @@ async def bind_schema_async(
219219
json_schema_version = response.get("jsonSchemaVersionInfo", {})
220220
return JSONSchemaBinding(
221221
json_schema_version_info=JSONSchemaVersionInfo(
222-
organization_id=json_schema_version.get("organizationId", ""),
223-
organization_name=json_schema_version.get("organizationName", ""),
224-
schema_id=json_schema_version.get("schemaId", ""),
225-
id=json_schema_version.get("$id", ""),
226-
schema_name=json_schema_version.get("schemaName", ""),
227-
version_id=json_schema_version.get("versionId", ""),
228-
semantic_version=json_schema_version.get("semanticVersion", ""),
229-
json_sha256_hex=json_schema_version.get("jsonSHA256Hex", ""),
230-
created_on=json_schema_version.get("createdOn", ""),
231-
created_by=json_schema_version.get("createdBy", ""),
222+
organization_id=json_schema_version.get("organizationId", None),
223+
organization_name=json_schema_version.get("organizationName", None),
224+
schema_id=json_schema_version.get("schemaId", None),
225+
id=json_schema_version.get("$id", None),
226+
schema_name=json_schema_version.get("schemaName", None),
227+
version_id=json_schema_version.get("versionId", None),
228+
semantic_version=json_schema_version.get("semanticVersion", None),
229+
json_sha256_hex=json_schema_version.get("jsonSHA256Hex", None),
230+
created_on=json_schema_version.get("createdOn", None),
231+
created_by=json_schema_version.get("createdBy", None),
232232
),
233-
object_id=response.get("objectId", ""),
234-
object_type=response.get("objectType", ""),
235-
created_on=response.get("createdOn", ""),
236-
created_by=response.get("createdBy", ""),
237-
enable_derived_annotations=response.get("enableDerivedAnnotations", False),
233+
object_id=response.get("objectId", None),
234+
object_type=response.get("objectType", None),
235+
created_on=response.get("createdOn", None),
236+
created_by=response.get("createdBy", None),
237+
enable_derived_annotations=response.get("enableDerivedAnnotations", None),
238238
)
239239

240240
async def get_schema_async(
@@ -256,22 +256,24 @@ async def get_schema_async(
256256
json_schema_version_info = response.get("jsonSchemaVersionInfo", {})
257257
return JSONSchemaBinding(
258258
json_schema_version_info=JSONSchemaVersionInfo(
259-
organization_id=json_schema_version_info.get("organizationId", ""),
260-
organization_name=json_schema_version_info.get("organizationName", ""),
261-
schema_id=json_schema_version_info.get("schemaId", ""),
262-
id=json_schema_version_info.get("$id", ""),
263-
schema_name=json_schema_version_info.get("schemaName", ""),
264-
version_id=json_schema_version_info.get("versionId", ""),
265-
semantic_version=json_schema_version_info.get("semanticVersion", ""),
266-
json_sha256_hex=json_schema_version_info.get("jsonSHA256Hex", ""),
267-
created_on=json_schema_version_info.get("createdOn", ""),
268-
created_by=json_schema_version_info.get("createdBy", ""),
259+
organization_id=json_schema_version_info.get("organizationId", None),
260+
organization_name=json_schema_version_info.get(
261+
"organizationName", None
262+
),
263+
schema_id=json_schema_version_info.get("schemaId", None),
264+
id=json_schema_version_info.get("$id", None),
265+
schema_name=json_schema_version_info.get("schemaName", None),
266+
version_id=json_schema_version_info.get("versionId", None),
267+
semantic_version=json_schema_version_info.get("semanticVersion", None),
268+
json_sha256_hex=json_schema_version_info.get("jsonSHA256Hex", None),
269+
created_on=json_schema_version_info.get("createdOn", None),
270+
created_by=json_schema_version_info.get("createdBy", None),
269271
),
270-
object_id=response.get("objectId", ""),
271-
object_type=response.get("objectType", ""),
272-
created_on=response.get("createdOn", ""),
273-
created_by=response.get("createdBy", ""),
274-
enable_derived_annotations=response.get("enableDerivedAnnotations", False),
272+
object_id=response.get("objectId", None),
273+
object_type=response.get("objectType", None),
274+
created_on=response.get("createdOn", None),
275+
created_by=response.get("createdBy", None),
276+
enable_derived_annotations=response.get("enableDerivedAnnotations", None),
275277
)
276278

277279
async def delete_schema_async(
@@ -307,37 +309,39 @@ async def validate_schema_async(
307309
if "validationException" in response:
308310
return InvalidJSONSchemaValidation(
309311
validation_response=JSONSchemaValidation(
310-
object_id=response.get("objectId", ""),
311-
object_type=response.get("objectType", ""),
312-
object_etag=response.get("objectEtag", ""),
313-
id=response.get("schema$id", ""),
314-
is_valid=response.get("isValid", False),
315-
validated_on=response.get("validatedOn", ""),
312+
object_id=response.get("objectId", None),
313+
object_type=response.get("objectType", None),
314+
object_etag=response.get("objectEtag", None),
315+
id=response.get("schema$id", None),
316+
is_valid=response.get("isValid", None),
317+
validated_on=response.get("validatedOn", None),
316318
),
317-
validation_error_message=response.get("validationErrorMessage", ""),
319+
validation_error_message=response.get("validationErrorMessage", None),
318320
all_validation_messages=response.get("allValidationMessages", []),
319321
validation_exception=ValidationException(
320322
pointer_to_violation=response.get("validationException", {}).get(
321-
"pointerToViolation", ""
323+
"pointerToViolation", None
324+
),
325+
message=response.get("validationException", {}).get(
326+
"message", None
322327
),
323-
message=response.get("validationException", {}).get("message", ""),
324328
schema_location=response.get("validationException", {}).get(
325-
"schemaLocation", ""
329+
"schemaLocation", None
326330
),
327331
causing_exceptions=[
328332
CausingException(
329-
keyword=ce.get("keyword", ""),
330-
pointer_to_violation=ce.get("pointerToViolation", ""),
331-
message=ce.get("message", ""),
332-
schema_location=ce.get("schemaLocation", ""),
333+
keyword=ce.get("keyword", None),
334+
pointer_to_violation=ce.get("pointerToViolation", None),
335+
message=ce.get("message", None),
336+
schema_location=ce.get("schemaLocation", None),
333337
causing_exceptions=[
334338
CausingException(
335-
keyword=nce.get("keyword", ""),
339+
keyword=nce.get("keyword", None),
336340
pointer_to_violation=nce.get(
337-
"pointerToViolation", ""
341+
"pointerToViolation", None
338342
),
339-
message=nce.get("message", ""),
340-
schema_location=nce.get("schemaLocation", ""),
343+
message=nce.get("message", None),
344+
schema_location=nce.get("schemaLocation", None),
341345
)
342346
for nce in ce.get("causingExceptions", [])
343347
],
@@ -349,12 +353,12 @@ async def validate_schema_async(
349353
),
350354
)
351355
return JSONSchemaValidation(
352-
object_id=response.get("objectId", ""),
353-
object_type=response.get("objectType", ""),
354-
object_etag=response.get("objectEtag", ""),
355-
id=response.get("schema$id", ""),
356-
is_valid=response.get("isValid", ""),
357-
validated_on=response.get("validatedOn", ""),
356+
object_id=response.get("objectId", None),
357+
object_type=response.get("objectType", None),
358+
object_etag=response.get("objectEtag", None),
359+
id=response.get("schema$id", None),
360+
is_valid=response.get("isValid", None),
361+
validated_on=response.get("validatedOn", None),
358362
)
359363

360364
async def get_schema_derived_keys_async(
@@ -428,37 +432,37 @@ async def get_invalid_validation_async(
428432
async for item in gen:
429433
yield InvalidJSONSchemaValidation(
430434
validation_response=JSONSchemaValidation(
431-
object_id=item.get("objectId", ""),
432-
object_type=item.get("objectType", ""),
433-
object_etag=item.get("objectEtag", ""),
434-
id=item.get("schema$id", ""),
435-
is_valid=item.get("isValid", ""),
436-
validated_on=item.get("validatedOn", ""),
435+
object_id=item.get("objectId", None),
436+
object_type=item.get("objectType", None),
437+
object_etag=item.get("objectEtag", None),
438+
id=item.get("schema$id", None),
439+
is_valid=item.get("isValid", None),
440+
validated_on=item.get("validatedOn", None),
437441
),
438-
validation_error_message=item.get("validationErrorMessage", ""),
442+
validation_error_message=item.get("validationErrorMessage", None),
439443
all_validation_messages=item.get("allValidationMessages", []),
440444
validation_exception=ValidationException(
441445
pointer_to_violation=item.get("validationException", {}).get(
442-
"pointerToViolation", ""
446+
"pointerToViolation", None
443447
),
444-
message=item.get("validationException", {}).get("message", ""),
448+
message=item.get("validationException", {}).get("message", None),
445449
schema_location=item.get("validationException", {}).get(
446-
"schemaLocation", ""
450+
"schemaLocation", None
447451
),
448452
causing_exceptions=[
449453
CausingException(
450-
keyword=ce.get("keyword", ""),
451-
pointer_to_violation=ce.get("pointerToViolation", ""),
452-
message=ce.get("message", ""),
453-
schema_location=ce.get("schemaLocation", ""),
454+
keyword=ce.get("keyword", None),
455+
pointer_to_violation=ce.get("pointerToViolation", None),
456+
message=ce.get("message", None),
457+
schema_location=ce.get("schemaLocation", None),
454458
causing_exceptions=[
455459
CausingException(
456-
keyword=nce.get("keyword", ""),
460+
keyword=nce.get("keyword", None),
457461
pointer_to_violation=nce.get(
458-
"pointerToViolation", ""
462+
"pointerToViolation", None
459463
),
460-
message=nce.get("message", ""),
461-
schema_location=nce.get("schemaLocation", ""),
464+
message=nce.get("message", None),
465+
schema_location=nce.get("schemaLocation", None),
462466
)
463467
for nce in ce.get("causingExceptions", [])
464468
],

0 commit comments

Comments
 (0)