Skip to content

Commit ca68b09

Browse files
committed
Add deprecation warnings for 'embeded_*' parameters and update dependencies
- Introduced warnings for deprecated 'embeded_*' parameters, which will be removed in v9.0. - Added `deprecation` to dependencies in `pyproject.toml`. - Added `@deprecation.deprecated` decorator to mark `draw_embeded_image` as deprecated.
1 parent e968a1b commit ca68b09

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

pyproject.toml

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

3637

qrcode/image/styledpil.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from __future__ import annotations
22

3+
import warnings
34
from typing import overload
45

5-
import qrcode.image.base
6+
import deprecation
67
from PIL import Image
8+
9+
import qrcode.image.base
710
from qrcode.image.styles.colormasks import QRColorMask, SolidFillColorMask
811
from qrcode.image.styles.moduledrawers import SquareModuleDrawer
912

@@ -45,6 +48,16 @@ class StyledPilImage(qrcode.image.base.BaseImageWithDrawer):
4548

4649
def __init__(self, *args, **kwargs):
4750
self.color_mask = kwargs.get("color_mask", SolidFillColorMask())
51+
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+
4861
# allow embeded_ parameters with typos for backwards compatibility
4962
embedded_image_path = kwargs.get(
5063
"embedded_image_path", kwargs.get("embeded_image_path", None)
@@ -100,6 +113,15 @@ def process(self):
100113
if self.embedded_image:
101114
self.draw_embedded_image()
102115

116+
@deprecation.deprecated(
117+
deprecated_in="9.0",
118+
removed_in="8.3",
119+
current_version="8.2",
120+
details="Use draw_embedded_image() instead",
121+
)
122+
def draw_embeded_image(self):
123+
return self.draw_embedded_image()
124+
103125
def draw_embedded_image(self):
104126
if not self.embedded_image:
105127
return

qrcode/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import warnings
23
from bisect import bisect_left
34
from typing import (
45
Generic,
@@ -342,6 +343,16 @@ def make_image(self, image_factory=None, **kwargs):
342343
343344
If the data has not been compiled yet, make it first.
344345
"""
346+
# Raise a warning that 'embeded' is still used
347+
if kwargs.get("embeded_image_path") or kwargs.get("embeded_image"):
348+
warnings.warn(
349+
"The 'embeded_*' parameters are deprecated. Use 'embedded_image_path' "
350+
"or 'embedded_image' instead. The 'embeded_*' parameters will be "
351+
"removed in v9.0.",
352+
category=DeprecationWarning,
353+
stacklevel=2,
354+
)
355+
345356
# allow embeded_ parameters with typos for backwards compatibility
346357
if (
347358
kwargs.get("embedded_image_path")
@@ -352,6 +363,7 @@ def make_image(self, image_factory=None, **kwargs):
352363
raise ValueError(
353364
"Error correction level must be ERROR_CORRECT_H if an embedded image is provided"
354365
)
366+
355367
_check_box_size(self.box_size)
356368
if self.data_cache is None:
357369
self.make()

0 commit comments

Comments
 (0)