File tree Expand file tree Collapse file tree
sdks/python/apache_beam/yaml Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -314,20 +314,20 @@ def _validate_compatible(weak_schema, strong_schema):
314314 return
315315 if weak_schema ['type' ] != strong_schema ['type' ]:
316316 raise ValueError (
317- ' Incompatible types: %r vs %r' %
318- ( weak_schema [ 'type' ], strong_schema ['type' ]) )
317+ f" Incompatible types: { weak_schema [ 'type' ]!r } vs "
318+ f" { strong_schema ['type' ]!r } " )
319319 if weak_schema ['type' ] == 'array' :
320320 _validate_compatible (weak_schema ['items' ], strong_schema ['items' ])
321321 elif weak_schema ['type' ] == 'object' :
322322 for required in strong_schema .get ('required' , []):
323323 if required not in weak_schema ['properties' ]:
324- raise ValueError ('Missing or unkown property %r' % required )
324+ raise ValueError (f 'Missing or unknown property { required !r } ' )
325325 for name , spec in weak_schema .get ('properties' , {}).items ():
326326 if name in strong_schema ['properties' ]:
327327 try :
328328 _validate_compatible (spec , strong_schema ['properties' ][name ])
329329 except Exception as exn :
330- raise ValueError ('Incompatible schema for %r' % name ) from exn
330+ raise ValueError (f 'Incompatible schema for { name !r } ' ) from exn
331331 elif not strong_schema .get ('additionalProperties' ):
332332 raise ValueError (
333333 f'Prohibited property: { name } ; '
Original file line number Diff line number Diff line change @@ -160,7 +160,8 @@ def test_row_validator_compatibility_error(self):
160160 type = schema_pb2 .FieldType (atomic_type = schema_pb2 .STRING ))
161161 ])
162162 json_schema = {
163- 'type' : 'object' , 'properties' : {
163+ 'type' : 'object' ,
164+ 'properties' : {
164165 'f' : {
165166 'type' : 'integer'
166167 }
@@ -170,9 +171,11 @@ def test_row_validator_compatibility_error(self):
170171 json_utils .row_validator (beam_schema , json_schema )
171172
172173 def test_json_schema_to_beam_schema_errors (self ):
173- with self .assertRaisesRegex (ValueError , "Expected object type, got not_object" ):
174+ with self .assertRaisesRegex (
175+ ValueError , "Expected object type, got not_object" ):
174176 json_utils .json_schema_to_beam_schema ({'type' : 'not_object' })
175- with self .assertRaisesRegex (ValueError , "Missing properties for" ):
177+ with self .assertRaisesRegex (
178+ ValueError , "Missing properties for" ):
176179 json_utils .json_schema_to_beam_schema ({'type' : 'object' })
177180
178181
You can’t perform that action at this time.
0 commit comments