Skip to content

Commit 6d63fef

Browse files
committed
Scripts: Linting.
1 parent 171a2e1 commit 6d63fef

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

nifi/user_python_extensions/convert_json_record_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def map_record(self, record: dict, json_mapper_schema: dict) -> dict:
293293
parts: list[str] = []
294294
for sub_field in old_field:
295295
rendered = self._value_for_composite(record, sub_field)
296-
if rendered not in (None, ""):
296+
if rendered is not None and rendered != "":
297297
parts.append(rendered)
298298
self._set_field(new_record, new_field, "\n".join(parts) if parts else None)
299299

nifi/user_python_extensions/record_decompress_cerner_blob.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def process(self, context: ProcessContext, flowFile: JavaObject) -> FlowFileTran
232232
try:
233233

234234
# attempt to see if not a proper compressed blob
235-
output_bytes_decompressed = None
235+
output_bytes_decompressed: bytes | bytearray | None = None
236236
try:
237237
if full_compressed_blob.find(b"%PDF") != -1:
238238
pdf_start = full_compressed_blob.find(b"%PDF-")
@@ -256,7 +256,10 @@ def process(self, context: ProcessContext, flowFile: JavaObject) -> FlowFileTran
256256
decompress_blob.decompress(full_compressed_blob)
257257
output_bytes_decompressed = bytes(decompress_blob.output_stream)
258258

259-
output_merged_record[self.binary_field_name] = output_bytes_decompressed
259+
if output_bytes_decompressed is None:
260+
raise ValueError("Could not locate or decompress blob payload")
261+
262+
output_merged_record[self.binary_field_name] = bytes(output_bytes_decompressed)
260263

261264
except Exception as exception:
262265
raise RuntimeError("Error decompressing Cerner LZW blob") from exception

nifi/user_python_extensions/sample_processor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,10 @@ def process(self, context: ProcessContext, flowFile: JavaObject) -> FlowFileTran
145145
output_byte_buffer.seek(0)
146146

147147
# add properties to flowfile attributes
148-
attributes: dict = {k: str(v) for k, v in flowFile.getAttributes().items()}
149148
attributes["sample_property_one"] = str(self.sample_property_one)
150149
attributes["sample_property_two"] = str(self.sample_property_two)
151150
attributes["sample_property_three"] = str(self.sample_property_three)
152151

153152
return FlowFileTransformResult(relationship="success",
154153
attributes=attributes,
155-
contents=json.dumps(output_contents))
154+
contents=json.dumps(output_contents).encode("utf-8"))

typings/nifiapi/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import nifiapi.relationship # noqa: F401
1414
from .flowfiletransform import (
1515
FlowFileTransform,
1616
FlowFileTransformResult,
17-
ProcessContext,
1817
)
1918
from .properties import (
19+
ProcessContext,
2020
PropertyDescriptor,
2121
StandardValidators,
2222
)

0 commit comments

Comments
 (0)