From 75360370ffb052fc1dd6a64d0ba144ac256b9776 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 15 Feb 2023 16:47:12 +0200 Subject: [PATCH 1/4] Improve test coverage --- qrcode/image/styledpil.py | 3 +-- qrcode/image/styles/moduledrawers/__init__.py | 2 +- setup.cfg | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qrcode/image/styledpil.py b/qrcode/image/styledpil.py index 7c9d9995..b6b9c3b6 100644 --- a/qrcode/image/styledpil.py +++ b/qrcode/image/styledpil.py @@ -104,8 +104,7 @@ def draw_embeded_image(self): def save(self, stream, format=None, **kwargs): if format is None: format = kwargs.get("kind", self.kind) - if "kind" in kwargs: - del kwargs["kind"] + kwargs.pop("kind", None) self._img.save(stream, format=format, **kwargs) def __getattr__(self, name): diff --git a/qrcode/image/styles/moduledrawers/__init__.py b/qrcode/image/styles/moduledrawers/__init__.py index 99217d49..ff8d33ce 100644 --- a/qrcode/image/styles/moduledrawers/__init__.py +++ b/qrcode/image/styles/moduledrawers/__init__.py @@ -6,5 +6,5 @@ from .pil import RoundedModuleDrawer # noqa: F401 from .pil import SquareModuleDrawer # noqa: F401 from .pil import VerticalBarsDrawer # noqa: F401 -except ImportError: +except ImportError: # pragma: no cover pass diff --git a/setup.cfg b/setup.cfg index 3aff842a..1279c0f5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -80,9 +80,11 @@ parallel = True [coverage:report] exclude_lines = - pragma: no cover + @abc.abstractmethod @overload if (typing\.)?TYPE_CHECKING: + pragma: no cover + raise NotImplementedError skip_covered = True [zest.releaser] From 8c325b5c33e9196a2a71a1faebf985a7319084e8 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Wed, 23 Jul 2025 11:44:00 +0200 Subject: [PATCH 2/4] Coverage settings --- pyproject.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 349d8a28..07236f1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,3 +80,17 @@ date-format =" %%-d %%B %%Y" prereleaser.middle = [ "qrcode.release.update_manpage" ] + +[tool.coverage.run] +source = ["qrcode"] +parallel = true + +[tool.coverage.report] +exclude_lines = [ + "@abc.abstractmethod", + "@overload", + "if (typing\\.)?TYPE_CHECKING:", + "pragma: no cover", + "raise NotImplementedError" +] +skip_covered = true From 6d023dbe82de131fa1c0453bc9b9c0b7a30c149d Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Wed, 23 Jul 2025 11:45:58 +0200 Subject: [PATCH 3/4] Ruff autoformat --- qrcode/image/styles/moduledrawers/__init__.py | 2 +- qrcode/image/styles/moduledrawers/pil.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qrcode/image/styles/moduledrawers/__init__.py b/qrcode/image/styles/moduledrawers/__init__.py index e55e35f5..ae8b22af 100644 --- a/qrcode/image/styles/moduledrawers/__init__.py +++ b/qrcode/image/styles/moduledrawers/__init__.py @@ -1,7 +1,7 @@ # For backwards compatibility, importing the PIL drawers here. try: from .pil import CircleModuleDrawer # noqa: F401 - from .pil import GappedCircleModuleDrawer # noqa: F401 + from .pil import GappedCircleModuleDrawer # noqa: F401 from .pil import GappedSquareModuleDrawer # noqa: F401 from .pil import HorizontalBarsDrawer # noqa: F401 from .pil import RoundedModuleDrawer # noqa: F401 diff --git a/qrcode/image/styles/moduledrawers/pil.py b/qrcode/image/styles/moduledrawers/pil.py index 107cf854..cd3ef83c 100644 --- a/qrcode/image/styles/moduledrawers/pil.py +++ b/qrcode/image/styles/moduledrawers/pil.py @@ -117,7 +117,9 @@ def initialize(self, *args, **kwargs): (0, 0, fake_size, fake_size), fill=self.img.paint_color ) smaller_size = int(self.size_ratio * box_size) - self.circle = self.circle.resize((smaller_size, smaller_size), Image.Resampling.LANCZOS) + self.circle = self.circle.resize( + (smaller_size, smaller_size), Image.Resampling.LANCZOS + ) def drawrect(self, box, is_active: bool): if is_active: From f0f4a21944441e69c71b5e95f825c808895168aa Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Wed, 23 Jul 2025 11:47:13 +0200 Subject: [PATCH 4/4] Update changelog --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index b8fe39d1..1d4133d3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ WIP === - Added ``GappedCircleModuleDrawer`` (PIL) to render QR code modules as non-contiguous circles. (BenwestGate in `#373`_) +- Improved test coveraged (akx in `#315`_) - Migrate pyproject.toml to PEP 621-compliant [project] metadata format. (hroncok in `#399`_) - Allow execution as a Python module. (stefansjs in `#400`_) @@ -13,6 +14,7 @@ WIP python -m qrcode --output qrcode.png "hello world" +.. _#315: https://github.com/lincolnloop/python-qrcode/pull/315 .. _#373: https://github.com/lincolnloop/python-qrcode/pull/373 .. _#399: https://github.com/lincolnloop/python-qrcode/pull/399 .. _#400: https://github.com/lincolnloop/python-qrcode/pull/400