Skip to content

Commit

Permalink
remove pylint issues with too many returns
Browse files Browse the repository at this point in the history
  • Loading branch information
libretto committed May 8, 2024
1 parent 6515f2c commit c250295
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions karapace/schema_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,9 @@ def _handle_msg_schema(self, key: dict, value: dict | None) -> None:

try:
schema_type_parsed = SchemaType(schema_type)
except ValueError:
except ValueError as e:
LOG.warning("Invalid schema type: %s", schema_type)
return
raise e

# This does two jobs:
# - Validates the schema's JSON
Expand All @@ -519,18 +519,18 @@ def _handle_msg_schema(self, key: dict, value: dict | None) -> None:
candidate_references = [reference_from_mapping(reference_data) for reference_data in schema_references]
resolved_references, resolved_dependencies = self.resolve_references(candidate_references)
schema_str = json.dumps(json.loads(schema_str), sort_keys=True)
except json.JSONDecodeError:
except json.JSONDecodeError as e:
LOG.warning("Schema is not valid JSON")
return
except InvalidReferences:
raise e
except InvalidReferences as e:
LOG.exception("Invalid AVRO references")
return
raise e
elif schema_type_parsed == SchemaType.JSONSCHEMA:
try:
schema_str = json.dumps(json.loads(schema_str), sort_keys=True)
except json.JSONDecodeError:
except json.JSONDecodeError as e:
LOG.warning("Schema is not valid JSON")
return
raise e
elif schema_type_parsed == SchemaType.PROTOBUF:
try:
if schema_references:
Expand All @@ -544,12 +544,12 @@ def _handle_msg_schema(self, key: dict, value: dict | None) -> None:
normalize=False,
)
schema_str = str(parsed_schema)
except InvalidSchema:
except InvalidSchema as e:
LOG.exception("Schema is not valid ProtoBuf definition")
return
except InvalidReferences:
raise e
except InvalidReferences as e:
LOG.exception("Invalid Protobuf references")
return
raise e

try:
typed_schema = TypedSchema(
Expand All @@ -559,8 +559,8 @@ def _handle_msg_schema(self, key: dict, value: dict | None) -> None:
dependencies=resolved_dependencies,
schema=parsed_schema,
)
except (InvalidSchema, JSONDecodeError):
return
except (InvalidSchema, JSONDecodeError) as e:
raise e

self.database.insert_schema_version(
subject=schema_subject,
Expand Down

0 comments on commit c250295

Please sign in to comment.