From 2b866d88d4c0a43136ff2d7d6417462491022307 Mon Sep 17 00:00:00 2001 From: Anderson Herzogenrath da Costa Date: Fri, 17 May 2024 10:20:42 -0400 Subject: [PATCH] fix new pylint alarms (#1173) --- fpdf/image_parsing.py | 4 +++- fpdf/text_region.py | 2 ++ test/text_shaping/test_bidirectional.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fpdf/image_parsing.py b/fpdf/image_parsing.py index 031dc1efb..6fec6d187 100644 --- a/fpdf/image_parsing.py +++ b/fpdf/image_parsing.py @@ -269,8 +269,10 @@ def get_img_info(filename, img=None, image_filter="AUTO", dims=None): elif img.mode == "CMYK": dpn, bpc, colspace = 4, 8, "DeviceCMYK" jpeg_inverted = True - if img.mode == "L": + elif img.mode == "L": dpn, bpc, colspace = 1, 8, "DeviceGray" + else: + raise ValueError(f"Unsupported image mode: {img.mode}") img_raw_data.seek(0) info.update( { diff --git a/fpdf/text_region.py b/fpdf/text_region.py index 5c3e24b1b..90a1ccea3 100644 --- a/fpdf/text_region.py +++ b/fpdf/text_region.py @@ -194,6 +194,8 @@ def render(self, col_left, col_width, max_height): "ImageParagraph.build_line() must be called before render()." ) is_svg = isinstance(self.info, VectorImageInfo) + + # pylint: disable=possibly-used-before-assignment if self.height: h = self.height else: diff --git a/test/text_shaping/test_bidirectional.py b/test/text_shaping/test_bidirectional.py index 5a25953ef..3ee8f14a8 100644 --- a/test/text_shaping/test_bidirectional.py +++ b/test/text_shaping/test_bidirectional.py @@ -127,13 +127,14 @@ def test_bidi_character(): string = "" for char in test_data[0].split(" "): string += chr(int(char, 16)) - assert test_data[1] in ("0", "1", "2") if test_data[1] == "0": base_direction = TextDirection.LTR elif test_data[1] == "1": base_direction = TextDirection.RTL elif test_data[1] == "2": base_direction = None # auto + else: + raise ValueError(f"Invalid base direction {test_data[1]}") if not base_direction: # test the auto detect direction algorithm