Skip to content

Commit

Permalink
Fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
asosnovsky-sumologic committed Jul 11, 2023
1 parent f5e329f commit 94b75bf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
16 changes: 5 additions & 11 deletions lang/py/avro/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io
import os
import struct
from typing import Any, NamedTuple, Dict, Tuple
from typing import Any, Dict, NamedTuple, Tuple

import avro.errors
import avro.io
Expand Down Expand Up @@ -161,18 +161,14 @@ def read_handshake_response(self, decoder):
elif match == "CLIENT":
if self.send_protocol:
raise avro.errors.AvroException("Handshake failure.")
self.remote_protocol = avro.protocol.parse(
handshake_response.get("serverProtocol")
)
self.remote_protocol = avro.protocol.parse(handshake_response.get("serverProtocol"))
self.remote_hash = handshake_response.get("serverHash")
self.send_protocol = False
return True
elif match == "NONE":
if self.send_protocol:
raise avro.errors.AvroException("Handshake failure.")
self.remote_protocol = avro.protocol.parse(
handshake_response.get("serverProtocol")
)
self.remote_protocol = avro.protocol.parse(handshake_response.get("serverProtocol"))
self.remote_hash = handshake_response.get("serverHash")
self.send_protocol = True
return False
Expand Down Expand Up @@ -231,7 +227,6 @@ def issue_request(self, call_request, message_name, request_datum):
return self.request(message_name, request_datum)



class AvroHandshake(NamedTuple):
remote_protocol: avro.protocol.Protocol
handshake_response: Dict[str, str]
Expand Down Expand Up @@ -434,6 +429,7 @@ def write_error(self, writers_schema, error_exception, encoder):
datum_writer = avro.io.DatumWriter(writers_schema)
datum_writer.write(str(error_exception), encoder)


#
# Utility classes
#
Expand Down Expand Up @@ -486,9 +482,7 @@ def write_framed_message(self, message):
buffer_length = BUFFER_SIZE
else:
buffer_length = message_length - total_bytes_sent
self.write_buffer(
message[total_bytes_sent : (total_bytes_sent + buffer_length)]
)
self.write_buffer(message[total_bytes_sent : (total_bytes_sent + buffer_length)])
total_bytes_sent += buffer_length
# A message is always terminated by a zero-length buffer.
self.write_buffer_length(0)
Expand Down
27 changes: 22 additions & 5 deletions lang/py/avro/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,20 +873,37 @@ def __init__(
if schema_type == "request":
Schema.__init__(self, schema_type, other_props)
else:
NamedSchema.__init__(self, schema_type, name, namespace, names, other_props, validate_names=validate_names)
NamedSchema.__init__(
self,
schema_type,
name,
namespace,
names,
other_props,
validate_names=validate_names,
)

names = names or Names(validate_names=self.validate_names)
if schema_type == "record":
if (schema_type == "record") or (schema_type == "error"):
old_default = names.default_namespace
names.default_namespace = Name(name, namespace, names.default_namespace, validate_name=validate_names).space
names.default_namespace = Name(
name,
namespace,
names.default_namespace,
validate_name=validate_names,
).space

# Add class members
field_objects = RecordSchema.make_field_objects(fields, names, validate_names=validate_names)
field_objects = RecordSchema.make_field_objects(
fields,
names,
validate_names=validate_names,
)
self.set_prop("fields", field_objects)
if doc is not None:
self.set_prop("doc", doc)

if schema_type == "record":
if (schema_type == "record") or (schema_type == "error"):
names.default_namespace = old_default

# read-only properties
Expand Down
4 changes: 2 additions & 2 deletions lang/py/avro/test/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
servers yet available.
"""

import unittest
import io
import unittest

import avro.ipc
import avro.errors
import avro.ipc


class TestIPC(unittest.TestCase):
Expand Down

0 comments on commit 94b75bf

Please sign in to comment.