Skip to content

Commit

Permalink
update supported Python versions: drop 3.8 which is EOL, add regular …
Browse files Browse the repository at this point in the history
…3.13 release
  • Loading branch information
FriedrichFroebel committed Oct 10, 2024
1 parent 16ba991 commit 05302d4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 27 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
12 changes: 4 additions & 8 deletions brother_ql_web/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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")
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions brother_ql_web/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ keywords = [
"label",
"printer",
]
requires-python = ">=3.8, <4"
requires-python = ">=3.9, <4"
dependencies = [
"brother_ql",
"bottle",
Expand Down Expand Up @@ -62,7 +62,6 @@ dev = [
"pep8-naming",
"flake8-bugbear",
"requests",
"importlib-resources; python_version < '3.9'",
]
mypy = [
"mypy",
Expand Down
5 changes: 1 addition & 4 deletions tests/test_labels.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 1 addition & 4 deletions tests/test_web.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 05302d4

Please sign in to comment.