diff --git a/singer_sdk/sinks/core.py b/singer_sdk/sinks/core.py index 5a936a634..10c278ccb 100644 --- a/singer_sdk/sinks/core.py +++ b/singer_sdk/sinks/core.py @@ -611,7 +611,7 @@ def _after_process_record(self, context: dict) -> None: # SDK developer overrides: - def preprocess_record(self, record: dict, context: dict) -> dict: # noqa: ARG002, PLR6301 + def preprocess_record(self, record: dict, context: dict) -> dict: # noqa: PLR6301, ARG002 """Process incoming record and return a modified result. Args: @@ -743,12 +743,15 @@ def process_batch_files( tail, mode="rb", ) as file: - context_file = ( - gzip_open(file) if encoding.compression == "gzip" else file - ) - context = { - "records": [deserialize_json(line) for line in context_file] # type: ignore[attr-defined] - } + if encoding.compression == "gzip": + with gzip_open(file) as context_file: + context = { + "records": [ + deserialize_json(line) for line in context_file + ] + } + else: + context = {"records": [deserialize_json(line) for line in file]} self.process_batch(context) elif ( importlib.util.find_spec("pyarrow") @@ -760,8 +763,7 @@ def process_batch_files( tail, mode="rb", ) as file: - context_file = file - table = pq.read_table(context_file) + table = pq.read_table(file) context = {"records": table.to_pylist()} self.process_batch(context) else: