Skip to content

Commit 7528208

Browse files
committed
Revert "Removed backwards-compatible imports for PIL drawers in qrcode.image.styles.moduledrawers."
This reverts commit b132ef9.
1 parent b132ef9 commit 7528208

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

CHANGES.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ WIP
88
- **Added** ``GappedCircleModuleDrawer`` (PIL) to render QR code modules as non-contiguous circles. (BenwestGate in `#373`_)
99
- **Added** ability to execute as a Python module: ``python -m qrcode --output qrcode.png "hello world"`` (stefansjs in `#400`_)
1010
- **Removed** the hardcoded 'id' argument from SVG elements. The fixed element ID caused conflicts when embedding multiple QR codes in a single document. (m000 in `#385`_)
11-
- **Removed** backwards-compatible imports for PIL drawers in ``qrcode.image.styles.moduledrawers``; users are required to import drawers directly from ``qrcode.image.styles.moduledrawers.pil``."
1211
- Improved test coveraged (akx in `#315`_)
1312
- Fixed typos in code that used ``embeded`` instead of ``embedded``. For backwards compatibility, the misspelled parameter names are still accepted but now emit deprecation warnings. These deprecated parameter names will be removed in v9.0. (benjnicholls in `#349`_)
1413
- Migrate pyproject.toml to PEP 621-compliant [project] metadata format. (hroncok in `#399`_)

qrcode/image/styledpil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import qrcode.image.base
1010
from qrcode.image.styles.colormasks import QRColorMask, SolidFillColorMask
11-
from qrcode.image.styles.moduledrawers.pil import SquareModuleDrawer
11+
from qrcode.image.styles.moduledrawers import SquareModuleDrawer
1212

1313

1414
class StyledPilImage(qrcode.image.base.BaseImageWithDrawer):
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# For backwards compatibility, importing the PIL drawers here.
2+
import contextlib
3+
4+
with contextlib.suppress(ImportError):
5+
from .pil import (
6+
CircleModuleDrawer, # noqa: F401
7+
GappedCircleModuleDrawer, # noqa: F401
8+
GappedSquareModuleDrawer, # noqa: F401
9+
HorizontalBarsDrawer, # noqa: F401
10+
RoundedModuleDrawer, # noqa: F401
11+
SquareModuleDrawer, # noqa: F401
12+
VerticalBarsDrawer, # noqa: F401
13+
)

qrcode/tests/test_qrcode_pil.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ def test_render_styled_with_embedded_image_path(tmp_path):
7171
@pytest.mark.parametrize(
7272
"drawer",
7373
[
74-
moduledrawers.pil.CircleModuleDrawer,
75-
moduledrawers.pil.GappedCircleModuleDrawer,
76-
moduledrawers.pil.GappedSquareModuleDrawer,
77-
moduledrawers.pil.HorizontalBarsDrawer,
78-
moduledrawers.pil.RoundedModuleDrawer,
79-
moduledrawers.pil.SquareModuleDrawer,
80-
moduledrawers.pil.VerticalBarsDrawer,
74+
moduledrawers.CircleModuleDrawer,
75+
moduledrawers.GappedCircleModuleDrawer,
76+
moduledrawers.GappedSquareModuleDrawer,
77+
moduledrawers.HorizontalBarsDrawer,
78+
moduledrawers.RoundedModuleDrawer,
79+
moduledrawers.SquareModuleDrawer,
80+
moduledrawers.VerticalBarsDrawer,
8181
],
8282
)
8383
def test_render_styled_with_drawer(drawer):

0 commit comments

Comments
 (0)