Skip to content

Commit 34e2948

Browse files
Refine formatting, fix typo, and use f-strings in json_utils.py
1 parent 75a1a9f commit 34e2948

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

sdks/python/apache_beam/yaml/json_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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}; '

sdks/python/apache_beam/yaml/json_utils_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)