Skip to content

Commit 9087e34

Browse files
committed
Remove deprecated code and warnings for embeded_* parameters and PIL drawer imports.
1 parent eed1cda commit 9087e34

File tree

6 files changed

+19
-224
lines changed

6 files changed

+19
-224
lines changed

CHANGES.rst

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@
22
Changes
33
=======
44

5-
Deprecation Warnings
6-
====================
5+
Change Log
6+
==========
77

8-
Removed in v9.0:
9-
----------------
8+
WIP (9.0)
9+
---------
1010

11-
- Importing a PIL drawer from ``qrcode.image.styles.moduledrawers`` has been deprecated.
12-
Update your code to import directly from the ``pil`` module instead:
11+
**Backwards incompatible changes:**
12+
13+
- The ``width`` and ``height`` attributes was removed from the ``<svg>`` tag.
14+
Instead, the ``viewBox`` attribute is now used for defining the dimensions.
15+
Additionally, all SVG elements now utilize pixel units rather than millimeters,
16+
which may cause rendering differences in browsers.
17+
18+
- Importing a PIL drawer from ``qrcode.image.styles.moduledrawers`` is no longer
19+
supported. Update your code to import directly from the ``pil`` module instead:
1320

1421
.. code-block:: python
1522
1623
from qrcode.image.styles.moduledrawers import SquareModuleDrawer # Old
1724
from qrcode.image.styles.moduledrawers.pil import SquareModuleDrawer # New
1825
1926
- Calling ``QRCode.make_image`` or ``StyledPilImage`` with the arguments ``embeded_image``
20-
or ``embeded_image_path`` have been deprecated due to typographical errors. Update
27+
or ``embeded_image_path`` has been removed to typographical errors. Update
2128
your code to use the correct arguments ``embedded_image`` and ``embededd_image_path``:
2229

2330
.. code-block:: python
@@ -29,20 +36,6 @@ Removed in v9.0:
2936
StyledPilImage(embeded_image=..., embeded_image_path=...) # Old
3037
StyledPilImage(embedded_image=..., embedded_image_path=...) # New
3138
32-
- The ``width`` and ``height`` attributes will be removed from the ``<svg>`` tag.
33-
Instead, the ``viewBox`` attribute is now used for defining the dimensions.
34-
Additionally, all SVG elements now utilize pixel units rather than millimeters,
35-
which may cause rendering differences in browsers.
36-
37-
Change Log
38-
==========
39-
40-
WIP (9.0)
41-
---------
42-
43-
- **Removed** ``width=.. height=...`` attributes from SVG tag, using viewBox instead. SVG elements now use pixel units instead of millimeters.
44-
45-
4639
WIP 8.x
4740
-------
4841

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ classifiers = [
3131
requires-python = "~=3.9"
3232
dependencies = [
3333
"colorama; sys_platform == 'win32'",
34-
"deprecation",
3534
]
3635

3736

qrcode/image/styledpil.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from __future__ import annotations
22

3-
import warnings
43
from typing import overload
54

6-
import deprecation
75
from PIL import Image
86

97
import qrcode.image.base
@@ -49,26 +47,12 @@ class StyledPilImage(qrcode.image.base.BaseImageWithDrawer):
4947
def __init__(self, *args, **kwargs):
5048
self.color_mask = kwargs.get("color_mask", SolidFillColorMask())
5149

52-
if kwargs.get("embeded_image_path") or kwargs.get("embeded_image"):
53-
warnings.warn(
54-
"The 'embeded_*' parameters are deprecated. Use 'embedded_image_path' "
55-
"or 'embedded_image' instead. The 'embeded_*' parameters will be "
56-
"removed in v9.0.",
57-
category=DeprecationWarning,
58-
stacklevel=2,
59-
)
60-
6150
# allow embeded_ parameters with typos for backwards compatibility
62-
embedded_image_path = kwargs.get(
63-
"embedded_image_path", kwargs.get("embeded_image_path")
64-
)
65-
self.embedded_image = kwargs.get("embedded_image", kwargs.get("embeded_image"))
66-
self.embedded_image_ratio = kwargs.get(
67-
"embedded_image_ratio", kwargs.get("embeded_image_ratio", 0.25)
68-
)
51+
embedded_image_path = kwargs.get("embedded_image_path")
52+
self.embedded_image = kwargs.get("embedded_image")
53+
self.embedded_image_ratio = kwargs.get("embedded_image_ratio", 0.25)
6954
self.embedded_image_resample = kwargs.get(
70-
"embedded_image_resample",
71-
kwargs.get("embeded_image_resample", Image.Resampling.LANCZOS),
55+
"embedded_image_resample", Image.Resampling.LANCZOS
7256
)
7357
if not self.embedded_image and embedded_image_path:
7458
self.embedded_image = Image.open(embedded_image_path)
@@ -111,15 +95,6 @@ def process(self):
11195
if self.embedded_image:
11296
self.draw_embedded_image()
11397

114-
@deprecation.deprecated(
115-
deprecated_in="9.0",
116-
removed_in="8.3",
117-
current_version="8.2",
118-
details="Use draw_embedded_image() instead",
119-
)
120-
def draw_embeded_image(self):
121-
return self.draw_embedded_image()
122-
12398
def draw_embedded_image(self):
12499
if not self.embedded_image:
125100
return
Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +0,0 @@
1-
"""
2-
Module for lazy importing of PIL drawers with a deprecation warning.
3-
4-
Currently, importing a PIL drawer from this module is allowed for backwards
5-
compatibility but will raise a DeprecationWarning.
6-
7-
This will be removed in v9.0.
8-
"""
9-
10-
import warnings
11-
12-
from qrcode.constants import PIL_AVAILABLE
13-
14-
15-
def __getattr__(name):
16-
"""Lazy import with deprecation warning for PIL drawers."""
17-
# List of PIL drawer names that should trigger deprecation warnings
18-
pil_drawers = {
19-
"CircleModuleDrawer",
20-
"GappedCircleModuleDrawer",
21-
"GappedSquareModuleDrawer",
22-
"HorizontalBarsDrawer",
23-
"RoundedModuleDrawer",
24-
"SquareModuleDrawer",
25-
"VerticalBarsDrawer",
26-
}
27-
28-
if name in pil_drawers:
29-
# Only render a warning if PIL is actually installed. Otherwise it would
30-
# raise an ImportError directly, which is fine.
31-
if PIL_AVAILABLE:
32-
warnings.warn(
33-
f"Importing '{name}' directly from this module is deprecated."
34-
f"Please use 'from qrcode.image.styles.moduledrawers.pil import {name}' "
35-
f"instead. This backwards compatibility import will be removed in v9.0.",
36-
DeprecationWarning,
37-
stacklevel=2,
38-
)
39-
40-
# Import and return the drawer from the pil module
41-
from . import pil # noqa: PLC0415
42-
43-
return getattr(pil, name)
44-
45-
# For any other attribute, raise AttributeError
46-
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

qrcode/main.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import sys
4-
import warnings
54
from bisect import bisect_left
65
from typing import Generic, Literal, NamedTuple, Optional, TypeVar, cast, overload
76

@@ -335,22 +334,8 @@ def make_image(self, image_factory=None, **kwargs):
335334
336335
If the data has not been compiled yet, make it first.
337336
"""
338-
# Raise a warning that 'embeded' is still used
339-
if kwargs.get("embeded_image_path") or kwargs.get("embeded_image"):
340-
warnings.warn(
341-
"The 'embeded_*' parameters are deprecated. Use 'embedded_image_path' "
342-
"or 'embedded_image' instead. The 'embeded_*' parameters will be "
343-
"removed in v9.0.",
344-
category=DeprecationWarning,
345-
stacklevel=2,
346-
)
347-
348-
# allow embeded_ parameters with typos for backwards compatibility
349337
if (
350-
kwargs.get("embedded_image_path")
351-
or kwargs.get("embedded_image")
352-
or kwargs.get("embeded_image_path")
353-
or kwargs.get("embeded_image")
338+
kwargs.get("embedded_image_path") or kwargs.get("embedded_image")
354339
) and self.error_correction != constants.ERROR_CORRECT_H:
355340
raise ValueError(
356341
"Error correction level must be ERROR_CORRECT_H if an embedded image is provided"

qrcode/tests/test_deprecation.py

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)