diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f74b37b..a3ed276 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,12 +10,11 @@ jobs: strategy: matrix: include: - - python: 3.8 - - python: 3.9 + - python: '3.9' - python: '3.10' - python: '3.11' - python: '3.12' - - python: '3.13-dev' + - python: '3.13' runs-on: ubuntu-latest name: Python ${{ matrix.python }} steps: @@ -40,17 +39,16 @@ jobs: run: python -m pip install .[dev,mypy] - name: run tests with fontconfig - run: + run: | + python -c "from brother_ql_web.font_helpers import _has_fontra; assert not _has_fontra()" python -m unittest discover --verbose --start-directory tests - name: install fontra run: python -m pip install .[fontra] - if: ${{ matrix.python != '3.8' }} - name: run tests with fontra run: | python -c "from brother_ql_web.font_helpers import _has_fontra; assert _has_fontra()" python -m unittest discover --verbose --start-directory tests - if: ${{ matrix.python != '3.8' }} - name: run flake8 run: python -m flake8 @@ -60,7 +58,6 @@ jobs: - name: run mypy run: mypy brother_ql_web/ tests/ - if: ${{ matrix.python != '3.8' }} - name: codespell run: codespell --skip "*.min.js*,*.min.css*" * .github diff --git a/brother_ql_web/labels.py b/brother_ql_web/labels.py index d420bca..163c180 100644 --- a/brother_ql_web/labels.py +++ b/brother_ql_web/labels.py @@ -3,11 +3,7 @@ import logging from dataclasses import dataclass from io import BytesIO -from typing import ( - cast, - Literal, - Tuple, -) # TODO: Remove `Tuple` after dropping Python 3.8. +from typing import cast, Literal from brother_ql import BrotherQLRaster, create_label from brother_ql.devicedependent import ( @@ -94,7 +90,7 @@ def font_path(self) -> str: 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") @@ -116,7 +112,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) @@ -148,7 +144,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 diff --git a/brother_ql_web/web.py b/brother_ql_web/web.py index ce20a1e..8ebefd8 100644 --- a/brother_ql_web/web.py +++ b/brother_ql_web/web.py @@ -3,7 +3,7 @@ import logging from io import BytesIO from pathlib import Path -from typing import Any, cast, Dict # TODO: Remove `Dict` after dropping Python 3.8. +from typing import Any, cast import bottle from brother_ql import BrotherQLRaster @@ -42,7 +42,7 @@ def serve_static(filename: str) -> bottle.HTTPResponse: @bottle.route("/labeldesigner") # type: ignore[misc] @bottle.jinja2_view("labeldesigner.jinja2") # type: ignore[misc] def labeldesigner() -> dict[str, Any]: - fonts = cast(Dict[str, Dict[str, str]], get_config("brother_ql_web.fonts")) + fonts = cast(dict[str, dict[str, str]], get_config("brother_ql_web.fonts")) font_family_names = sorted(list(fonts.keys())) configuration = cast(Configuration, get_config("brother_ql_web.configuration")) return { diff --git a/pyproject.toml b/pyproject.toml index 43c2e09..ce386ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ keywords = [ "label", "printer", ] -requires-python = ">=3.8, <4" +requires-python = ">=3.9, <4" dependencies = [ "brother_ql", "bottle", @@ -62,7 +62,6 @@ dev = [ "pep8-naming", "flake8-bugbear", "requests", - "importlib-resources; python_version < '3.9'", ] mypy = [ "mypy", diff --git a/tests/test_labels.py b/tests/test_labels.py index 6fd56a1..7ce2ff5 100644 --- a/tests/test_labels.py +++ b/tests/test_labels.py @@ -1,9 +1,6 @@ from __future__ import annotations -try: - from importlib.resources import as_file, files -except ImportError: - from importlib_resources import as_file, files # type: ignore[import-not-found,no-redef] # noqa: E501 +from importlib.resources import as_file, files from tempfile import NamedTemporaryFile from unittest import mock diff --git a/tests/test_web.py b/tests/test_web.py index 19c8baa..8036e24 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -1,12 +1,9 @@ from __future__ import annotations -try: - from importlib.resources import as_file, files -except ImportError: - from importlib_resources import as_file, files # type: ignore[import-not-found,no-redef] # noqa: E501 import base64 import os import subprocess +from importlib.resources import as_file, files from tempfile import NamedTemporaryFile from threading import Thread from time import sleep