Skip to content

Commit

Permalink
fix non-subscriptable type objects for Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedrichFroebel committed Nov 22, 2023
1 parent 6eb9477 commit fcffab0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions brother_ql_web/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging
from dataclasses import dataclass
from io import BytesIO
from typing import cast, Literal
# TODO: Remove `Tuple` after dropping Python 3.8.
from typing import cast, Literal, Tuple

from brother_ql import BrotherQLRaster, create_label
from brother_ql.devicedependent import (
Expand Down Expand Up @@ -68,7 +69,7 @@ def margin_right_scaled(self) -> int:
return self._scale_margin(self.margin_right)

@property
def fill_color(self) -> tuple[int, int, int]:
def fill_color(self) -> Tuple[int, int, int]:
return (255, 0, 0) if "red" in self.label_size else (0, 0, 0)

@property
Expand All @@ -85,10 +86,10 @@ def font_path(self) -> str:
return path

@property
def width_height(self) -> tuple[int, int]:
def width_height(self) -> Tuple[int, int]:
try:
width, height = cast(
tuple[int, int], label_type_specs[self.label_size]["dots_printable"]
Tuple[int, int], label_type_specs[self.label_size]["dots_printable"]
)
except KeyError:
raise LookupError("Unknown label_size")
Expand All @@ -110,7 +111,7 @@ def height(self) -> int:

def _determine_image_dimensions(
text: str, image_font: ImageFont.FreeTypeFont, parameters: LabelParameters
) -> tuple[int, int, int, int]:
) -> Tuple[int, int, int, int]:
image = Image.new("L", (20, 20), "white")
draw = ImageDraw.Draw(image)

Expand Down Expand Up @@ -142,7 +143,7 @@ def _determine_text_offsets(
text_height: int,
text_width: int,
parameters: LabelParameters,
) -> tuple[int, int]:
) -> Tuple[int, int]:
if parameters.orientation == "standard":
if parameters.kind in (DIE_CUT_LABEL, ROUND_DIE_CUT_LABEL):
vertical_offset = (height - text_height) // 2
Expand Down

0 comments on commit fcffab0

Please sign in to comment.