Skip to content

Python 3.13 support and other minor renovation #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-22.04 ]
python: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
python: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
variant: [ "py", "py-images" ]
include:
- os: macOS-12
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: debug-statements
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.7.1'
rev: 'v1.15.0'
hooks:
- id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.6'
rev: 'v0.11.9'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ python-barcode
There are no external dependencies when generating SVG files.
Pillow is required for generating images (e.g.: PNGs).

Support Python 3.8 to 3.12.
Support Python 3.8 to 3.13.

.. image:: example-ean13.png
:target: https://github.com/WhyNotHugo/python-barcode
Expand Down
7 changes: 3 additions & 4 deletions barcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
created as SVG objects. If Pillow is installed, the barcodes can also be
rendered as images (all formats supported by Pillow).
"""

from __future__ import annotations

import os
Expand Down Expand Up @@ -65,8 +66,7 @@
@overload
def get(
name: str, code: str, writer: BaseWriter | None = None, options: dict | None = None
) -> Barcode:
...
) -> Barcode: ...


@overload
Expand All @@ -75,8 +75,7 @@ def get(
code: None = None,
writer: BaseWriter | None = None,
options: dict | None = None,
) -> type[Barcode]:
...
) -> type[Barcode]: ...


def get(
Expand Down
3 changes: 1 addition & 2 deletions barcode/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""barcode.base
"""barcode.base"""

"""
from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions barcode/codabar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

:Provided barcodes: Codabar (NW-7)
"""

from __future__ import annotations

__docformat__ = "restructuredtext en"
Expand Down
1 change: 1 addition & 0 deletions barcode/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""barcode.errors"""

from __future__ import annotations

__docformat__ = "restructuredtext en"
Expand Down
1 change: 1 addition & 0 deletions barcode/isxn.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'0132354187'

"""

from __future__ import annotations

from barcode.ean import EuropeanArticleNumber13
Expand Down
1 change: 1 addition & 0 deletions barcode/itf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

:Provided barcodes: Interleaved 2 of 5
"""

from __future__ import annotations

__docformat__ = "restructuredtext en"
Expand Down
1 change: 1 addition & 0 deletions barcode/upc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

:Provided barcodes: UPC-A
"""

from __future__ import annotations

__docformat__ = "restructuredtext en"
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ v0.16.0
included resulting in a transparent background.
* Do not paint text if its size would be zero, to avoid an "invalid ppem value"
error with newer versions of Pillow.
* Add support for Python 3.13.
* Optimization of code creation, avoiding to many charset switch.
This results in shorter codes; according to GS1 codes should not
be longer than 165 mm (6.5"). (#232)


v0.15.1
~~~~~~~
Expand Down
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ write_to = "barcode/version.py"
version_scheme = "post-release"

[tool.ruff]
target-version = "py38"

[tool.ruff.lint]
select = [
"F",
"E",
Expand Down Expand Up @@ -36,13 +39,20 @@ select = [
"PLE",
"RUF",
]
target-version = "py38"

[tool.ruff.isort]
[tool.ruff.lint.isort]
force-single-line = true
required-imports = ["from __future__ import annotations"]

[tool.coverage.report]
exclude_lines = [
"if TYPE_CHECKING:",
]

[tool.pytest.ini_options]
addopts = [
"-vv",
"--cov=barcode",
"--cov-report=term-missing:skip-covered",
"--no-cov-on-fail",
]
6 changes: 0 additions & 6 deletions setup.cfg

This file was deleted.

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Multimedia :: Graphics",
"Topic :: Software Development :: Libraries :: Python Modules",
],
Expand Down
1 change: 1 addition & 0 deletions tests/test_manually.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generates barcodes for visually inspecting the results."""

from __future__ import annotations

import codecs
Expand Down
Loading