PyPDFForm 4.7.6__tar.gz → 4.7.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. {pypdfform-4.7.6 → pypdfform-4.7.8}/PKG-INFO +1 -1
  2. {pypdfform-4.7.6 → pypdfform-4.7.8}/PyPDFForm/__init__.py +9 -9
  3. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/annotations/__init__.py +1 -1
  4. pypdfform-4.7.8/PyPDFForm/lib/assets/__init__.py +0 -0
  5. pypdfform-4.7.8/PyPDFForm/lib/deprecation.py +74 -0
  6. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/middleware/__init__.py +1 -1
  7. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/raw/__init__.py +1 -1
  8. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/template.py +1 -1
  9. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/widgets/__init__.py +1 -1
  10. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/wrapper.py +3 -0
  11. {pypdfform-4.7.6 → pypdfform-4.7.8}/PyPDFForm.egg-info/PKG-INFO +1 -1
  12. pypdfform-4.7.8/PyPDFForm.egg-info/SOURCES.txt +72 -0
  13. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_font_widths.py +5 -5
  14. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_functional.py +68 -4
  15. pypdfform-4.7.6/PyPDFForm/deprecation.py +0 -43
  16. pypdfform-4.7.6/PyPDFForm.egg-info/SOURCES.txt +0 -71
  17. {pypdfform-4.7.6 → pypdfform-4.7.8}/LICENSE +0 -0
  18. {pypdfform-4.7.6/PyPDFForm/assets → pypdfform-4.7.8/PyPDFForm/lib}/__init__.py +0 -0
  19. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/adapter.py +0 -0
  20. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/annotations/base.py +0 -0
  21. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/annotations/link.py +0 -0
  22. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/annotations/stamp.py +0 -0
  23. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/annotations/text.py +0 -0
  24. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/annotations/text_markup.py +0 -0
  25. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/assets/bedrock.py +0 -0
  26. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/assets/blank.py +0 -0
  27. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/constants.py +0 -0
  28. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/coordinate.py +0 -0
  29. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/egress.py +0 -0
  30. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/filler.py +0 -0
  31. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/font.py +0 -0
  32. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/hooks.py +0 -0
  33. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/image.py +0 -0
  34. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/middleware/base.py +0 -0
  35. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/middleware/checkbox.py +0 -0
  36. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/middleware/dropdown.py +0 -0
  37. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/middleware/image.py +0 -0
  38. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/middleware/radio.py +0 -0
  39. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/middleware/signature.py +0 -0
  40. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/middleware/text.py +0 -0
  41. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/patterns.py +0 -0
  42. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/raw/circle.py +0 -0
  43. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/raw/ellipse.py +0 -0
  44. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/raw/image.py +0 -0
  45. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/raw/line.py +0 -0
  46. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/raw/rect.py +0 -0
  47. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/raw/text.py +0 -0
  48. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/types.py +0 -0
  49. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/utils.py +0 -0
  50. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/watermark.py +0 -0
  51. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/widgets/base.py +0 -0
  52. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/widgets/checkbox.py +0 -0
  53. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/widgets/dropdown.py +0 -0
  54. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/widgets/image.py +0 -0
  55. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/widgets/radio.py +0 -0
  56. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/widgets/signature.py +0 -0
  57. {pypdfform-4.7.6/PyPDFForm → pypdfform-4.7.8/PyPDFForm/lib}/widgets/text.py +0 -0
  58. {pypdfform-4.7.6 → pypdfform-4.7.8}/PyPDFForm.egg-info/dependency_links.txt +0 -0
  59. {pypdfform-4.7.6 → pypdfform-4.7.8}/PyPDFForm.egg-info/requires.txt +0 -0
  60. {pypdfform-4.7.6 → pypdfform-4.7.8}/PyPDFForm.egg-info/top_level.txt +0 -0
  61. {pypdfform-4.7.6 → pypdfform-4.7.8}/README.md +0 -0
  62. {pypdfform-4.7.6 → pypdfform-4.7.8}/pyproject.toml +0 -0
  63. {pypdfform-4.7.6 → pypdfform-4.7.8}/setup.cfg +0 -0
  64. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_bulk_create_fields.py +0 -0
  65. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_create_widget.py +0 -0
  66. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_draw_elements.py +0 -0
  67. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_dropdown.py +0 -0
  68. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_extract_middleware_attributes.py +0 -0
  69. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_fill_max_length_text_field.py +0 -0
  70. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_generate_appearance_streams.py +0 -0
  71. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_js.py +0 -0
  72. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_need_appearances.py +0 -0
  73. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_paragraph.py +0 -0
  74. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_signature.py +0 -0
  75. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_use_full_widget_name.py +0 -0
  76. {pypdfform-4.7.6 → pypdfform-4.7.8}/tests/test_widget_attr_trigger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPDFForm
3
- Version: 4.7.6
3
+ Version: 4.7.8
4
4
  Summary: The Python library for PDF forms.
5
5
  Author: Jinge Li
6
6
  License-Expression: MIT
@@ -22,15 +22,15 @@ PyPDFForm aims to simplify PDF form manipulation, making it accessible to develo
22
22
 
23
23
  import logging
24
24
 
25
- __version__ = "4.7.6"
26
-
27
- from .annotations import Annotations
28
- from .assets.blank import BlankPage
29
- from .middleware import Widgets
30
- from .raw import RawElements
31
- from .types import PdfArray
32
- from .widgets import Fields
33
- from .wrapper import PdfWrapper
25
+ __version__ = "4.7.8"
26
+
27
+ from .lib.annotations import Annotations
28
+ from .lib.assets.blank import BlankPage
29
+ from .lib.middleware import Widgets
30
+ from .lib.raw import RawElements
31
+ from .lib.types import PdfArray
32
+ from .lib.widgets import Fields
33
+ from .lib.wrapper import PdfWrapper
34
34
 
35
35
  # TODO: figure out why `Annotation sizes differ:`
36
36
  for logger in [
@@ -34,7 +34,7 @@ class Annotations:
34
34
  A container class that provides convenient access to all available PDF annotation types.
35
35
 
36
36
  This class acts as a namespace for the various `Annotation` classes defined in the
37
- `PyPDFForm.annotations` package, making it easier to reference them (e.g., `Annotations.TextAnnotation`).
37
+ `PyPDFForm.lib.annotations` package, making it easier to reference them (e.g., `Annotations.TextAnnotation`).
38
38
  """
39
39
 
40
40
  TextAnnotation = TextAnnotation
File without changes
@@ -0,0 +1,74 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ A module for handling deprecation notices within the PyPDFForm library.
4
+
5
+ This module provides utility functions to issue standard DeprecationWarning
6
+ messages, ensuring consistency across the library when notifying users of
7
+ deprecated features.
8
+ """
9
+
10
+ from functools import wraps
11
+ from warnings import warn
12
+
13
+ from .constants import DEPRECATION_NOTICE, DEPRECATION_REPLACE_NOTICE
14
+
15
+
16
+ def deprecation_notice(to_replace: str, param: str = "") -> callable:
17
+ """
18
+ Issues a DeprecationWarning when a deprecated method is called. Can also be called
19
+ directly within a method to emit deprecation warnings conditionally.
20
+
21
+ Args:
22
+ to_replace (str): The name of the method to use instead.
23
+ param (str): Optional parameter name to include in the deprecation notice.
24
+
25
+ Returns:
26
+ callable: A decorator function. The decorator has an `emit_notice` method
27
+ that can be called directly within a method body for conditional emission.
28
+
29
+ Examples:
30
+ As a decorator (emits on every call)::
31
+
32
+ @deprecation_notice(to_replace="new_method")
33
+ def old_method(self):
34
+ pass
35
+
36
+ As a decorator with a parameter (emits on every call)::
37
+
38
+ @deprecation_notice(to_replace="old_method.new_param.", param="old_param")
39
+ def old_method(self, old_param=None):
40
+ pass
41
+
42
+ Conditionally within a method body::
43
+
44
+ def my_method(self, use_legacy=False):
45
+ if use_legacy:
46
+ deprecation_notice(to_replace="", param="use_legacy").emit_notice(self, "my_method")
47
+ # legacy logic here
48
+ """
49
+
50
+ def _emit(class_name: str, method_name: str, stacklevel: int):
51
+ to_deprecate = (
52
+ f"{class_name}.{method_name}.{param}"
53
+ if param
54
+ else f"{class_name}.{method_name}"
55
+ )
56
+ notice = DEPRECATION_NOTICE.format(to_deprecate)
57
+ if to_replace:
58
+ replacement = f"{class_name}.{to_replace}"
59
+ notice = f"{notice} {DEPRECATION_REPLACE_NOTICE.format(replacement)}"
60
+ warn(notice, DeprecationWarning, stacklevel=stacklevel)
61
+
62
+ def decorator(func: callable) -> callable:
63
+ @wraps(func)
64
+ def wrapper(*args, **kwargs):
65
+ _emit(args[0].__class__.__name__, func.__name__, stacklevel=3)
66
+ return func(*args, **kwargs)
67
+
68
+ return wrapper
69
+
70
+ def emit_notice(obj, method_name: str):
71
+ _emit(obj.__class__.__name__, method_name, stacklevel=4)
72
+
73
+ decorator.emit_notice = emit_notice
74
+ return decorator
@@ -26,7 +26,7 @@ class Widgets:
26
26
  A container class that provides convenient access to all available middleware widget classes.
27
27
 
28
28
  This class acts as a namespace for the various middleware classes defined in the
29
- `PyPDFForm.middleware` package, making it easier to reference them (e.g., `Widgets.Text`).
29
+ `PyPDFForm.lib.middleware` package, making it easier to reference them (e.g., `Widgets.Text`).
30
30
  """
31
31
 
32
32
  Text = Text
@@ -25,7 +25,7 @@ class RawElements:
25
25
  A container class that provides convenient access to all available raw drawable elements.
26
26
 
27
27
  This class acts as a namespace for the various `Raw` classes defined in the
28
- `PyPDFForm.raw` package, making it easier to reference them (e.g., `RawElements.RawText`).
28
+ `PyPDFForm.lib.raw` package, making it easier to reference them (e.g., `RawElements.RawText`).
29
29
  """
30
30
 
31
31
  RawText = RawText
@@ -325,7 +325,7 @@ def create_annotations(
325
325
 
326
326
  This function takes a PDF template and a list of annotation objects, and
327
327
  renders each annotation onto its specified page in the PDF. It supports
328
- various annotation types defined in the `PyPDFForm.annotations` package.
328
+ various annotation types defined in the `PyPDFForm.lib.annotations` package.
329
329
 
330
330
  Args:
331
331
  template (bytes): The PDF template to add annotations to.
@@ -29,7 +29,7 @@ class Fields:
29
29
  A container class that provides convenient access to all available PDF form field types.
30
30
 
31
31
  This class acts as a namespace for the various `Field` classes defined in the
32
- `PyPDFForm.widgets` package, making it easier to reference them (e.g., `Fields.TextField`).
32
+ `PyPDFForm.lib.widgets` package, making it easier to reference them (e.g., `Fields.TextField`).
33
33
  """
34
34
 
35
35
  TextField = TextField
@@ -712,6 +712,9 @@ class PdfWrapper:
712
712
  raise NotImplementedError
713
713
 
714
714
  if defer:
715
+ deprecation_notice(to_replace="", param="defer").emit_notice(
716
+ self, "update_widget_key"
717
+ )
715
718
  self._keys_to_update.append((old_key, new_key, index))
716
719
  return self
717
720
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPDFForm
3
- Version: 4.7.6
3
+ Version: 4.7.8
4
4
  Summary: The Python library for PDF forms.
5
5
  Author: Jinge Li
6
6
  License-Expression: MIT
@@ -0,0 +1,72 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ PyPDFForm/__init__.py
5
+ PyPDFForm.egg-info/PKG-INFO
6
+ PyPDFForm.egg-info/SOURCES.txt
7
+ PyPDFForm.egg-info/dependency_links.txt
8
+ PyPDFForm.egg-info/requires.txt
9
+ PyPDFForm.egg-info/top_level.txt
10
+ PyPDFForm/lib/__init__.py
11
+ PyPDFForm/lib/adapter.py
12
+ PyPDFForm/lib/constants.py
13
+ PyPDFForm/lib/coordinate.py
14
+ PyPDFForm/lib/deprecation.py
15
+ PyPDFForm/lib/egress.py
16
+ PyPDFForm/lib/filler.py
17
+ PyPDFForm/lib/font.py
18
+ PyPDFForm/lib/hooks.py
19
+ PyPDFForm/lib/image.py
20
+ PyPDFForm/lib/patterns.py
21
+ PyPDFForm/lib/template.py
22
+ PyPDFForm/lib/types.py
23
+ PyPDFForm/lib/utils.py
24
+ PyPDFForm/lib/watermark.py
25
+ PyPDFForm/lib/wrapper.py
26
+ PyPDFForm/lib/annotations/__init__.py
27
+ PyPDFForm/lib/annotations/base.py
28
+ PyPDFForm/lib/annotations/link.py
29
+ PyPDFForm/lib/annotations/stamp.py
30
+ PyPDFForm/lib/annotations/text.py
31
+ PyPDFForm/lib/annotations/text_markup.py
32
+ PyPDFForm/lib/assets/__init__.py
33
+ PyPDFForm/lib/assets/bedrock.py
34
+ PyPDFForm/lib/assets/blank.py
35
+ PyPDFForm/lib/middleware/__init__.py
36
+ PyPDFForm/lib/middleware/base.py
37
+ PyPDFForm/lib/middleware/checkbox.py
38
+ PyPDFForm/lib/middleware/dropdown.py
39
+ PyPDFForm/lib/middleware/image.py
40
+ PyPDFForm/lib/middleware/radio.py
41
+ PyPDFForm/lib/middleware/signature.py
42
+ PyPDFForm/lib/middleware/text.py
43
+ PyPDFForm/lib/raw/__init__.py
44
+ PyPDFForm/lib/raw/circle.py
45
+ PyPDFForm/lib/raw/ellipse.py
46
+ PyPDFForm/lib/raw/image.py
47
+ PyPDFForm/lib/raw/line.py
48
+ PyPDFForm/lib/raw/rect.py
49
+ PyPDFForm/lib/raw/text.py
50
+ PyPDFForm/lib/widgets/__init__.py
51
+ PyPDFForm/lib/widgets/base.py
52
+ PyPDFForm/lib/widgets/checkbox.py
53
+ PyPDFForm/lib/widgets/dropdown.py
54
+ PyPDFForm/lib/widgets/image.py
55
+ PyPDFForm/lib/widgets/radio.py
56
+ PyPDFForm/lib/widgets/signature.py
57
+ PyPDFForm/lib/widgets/text.py
58
+ tests/test_bulk_create_fields.py
59
+ tests/test_create_widget.py
60
+ tests/test_draw_elements.py
61
+ tests/test_dropdown.py
62
+ tests/test_extract_middleware_attributes.py
63
+ tests/test_fill_max_length_text_field.py
64
+ tests/test_font_widths.py
65
+ tests/test_functional.py
66
+ tests/test_generate_appearance_streams.py
67
+ tests/test_js.py
68
+ tests/test_need_appearances.py
69
+ tests/test_paragraph.py
70
+ tests/test_signature.py
71
+ tests/test_use_full_widget_name.py
72
+ tests/test_widget_attr_trigger.py
@@ -13,10 +13,10 @@ from fontTools.ttLib import TTLibError
13
13
  from pypdf import PdfWriter
14
14
 
15
15
  from PyPDFForm import PdfWrapper
16
- from PyPDFForm.constants import (DEFAULT_ASSUMED_GLYPH_WIDTH, DR,
17
- ENCODING_TABLE_SIZE, AcroForm, Font,
18
- FontDescriptor, MissingWidth, Widths)
19
- from PyPDFForm.font import compute_font_glyph_widths
16
+ from PyPDFForm.lib.constants import (DEFAULT_ASSUMED_GLYPH_WIDTH, DR,
17
+ ENCODING_TABLE_SIZE, AcroForm, Font,
18
+ FontDescriptor, MissingWidth, Widths)
19
+ from PyPDFForm.lib.font import compute_font_glyph_widths
20
20
 
21
21
 
22
22
  @pytest.fixture
@@ -72,7 +72,7 @@ def test_compute_font_widths_raises_for_invalid_ttf():
72
72
 
73
73
 
74
74
  def test_compute_font_glyph_widths_with_missing_tables():
75
- with patch("PyPDFForm.font.FT_TTFont") as mock_ttfont:
75
+ with patch("PyPDFForm.lib.font.FT_TTFont") as mock_ttfont:
76
76
  mock_font = MagicMock()
77
77
  mock_font.get.side_effect = lambda table: None
78
78
  mock_ttfont.return_value = mock_font
@@ -7,10 +7,10 @@ import pytest
7
7
  from jsonschema import ValidationError, validate
8
8
 
9
9
  from PyPDFForm import Annotations, BlankPage, Fields, PdfArray, PdfWrapper
10
- from PyPDFForm.constants import DA, UNIQUE_SUFFIX_LENGTH, T, V
11
- from PyPDFForm.deprecation import deprecation_notice
12
- from PyPDFForm.middleware.base import Widget
13
- from PyPDFForm.template import get_widgets_by_page
10
+ from PyPDFForm.lib.constants import DA, UNIQUE_SUFFIX_LENGTH, T, V
11
+ from PyPDFForm.lib.deprecation import deprecation_notice
12
+ from PyPDFForm.lib.middleware.base import Widget
13
+ from PyPDFForm.lib.template import get_widgets_by_page
14
14
 
15
15
 
16
16
  def test_deprecation_warning():
@@ -27,6 +27,70 @@ def test_deprecation_warning():
27
27
  assert obj.old_method() == "result"
28
28
 
29
29
 
30
+ def test_deprecation_warning_with_param():
31
+ class MockClass:
32
+ @deprecation_notice(to_replace="old_method.new_param", param="old_param")
33
+ def old_method(self):
34
+ return "result"
35
+
36
+ obj = MockClass()
37
+ with pytest.warns(
38
+ DeprecationWarning,
39
+ match="MockClass.old_method.old_param will be deprecated soon. Use MockClass.old_method.new_param instead.",
40
+ ):
41
+ assert obj.old_method() == "result"
42
+
43
+
44
+ def test_deprecation_warning_empty_replace():
45
+ class MockClass:
46
+ @deprecation_notice(to_replace="")
47
+ def old_method(self):
48
+ return "result"
49
+
50
+ obj = MockClass()
51
+ with pytest.warns(
52
+ DeprecationWarning,
53
+ match="MockClass.old_method will be deprecated soon.",
54
+ ) as record:
55
+ assert obj.old_method() == "result"
56
+ assert "Use" not in str(record[0].message)
57
+
58
+
59
+ def test_deprecation_warning_direct_call():
60
+ class MockClass:
61
+ def my_method(self, use_legacy=False):
62
+ if use_legacy:
63
+ deprecation_notice(to_replace="", param="use_legacy").emit_notice(
64
+ self, "my_method"
65
+ )
66
+ return "result"
67
+
68
+ obj = MockClass()
69
+ assert obj.my_method(use_legacy=False) == "result"
70
+ with pytest.warns(
71
+ DeprecationWarning,
72
+ match="MockClass.my_method.use_legacy will be deprecated soon.",
73
+ ):
74
+ assert obj.my_method(use_legacy=True) == "result"
75
+
76
+
77
+ def test_deprecation_warning_direct_call_with_replace():
78
+ class MockClass:
79
+ def my_method(self, use_legacy=False):
80
+ if use_legacy:
81
+ deprecation_notice(
82
+ to_replace="my_method.new_param", param="use_legacy"
83
+ ).emit_notice(self, "my_method")
84
+ return "result"
85
+
86
+ obj = MockClass()
87
+ with pytest.warns(
88
+ DeprecationWarning,
89
+ match="MockClass.my_method.use_legacy will be deprecated soon. Use MockClass.my_method.new_param instead.",
90
+ ):
91
+ assert obj.my_method(use_legacy=True) == "result"
92
+
93
+
30
94
  def test_base_schema_definition():
31
95
  assert Widget("foo").schema_definition == {}
32
96
 
@@ -1,43 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- A module for handling deprecation notices within the PyPDFForm library.
4
-
5
- This module provides utility functions to issue standard DeprecationWarning
6
- messages, ensuring consistency across the library when notifying users of
7
- deprecated features.
8
- """
9
-
10
- from functools import wraps
11
- from warnings import warn
12
-
13
- from .constants import DEPRECATION_NOTICE, DEPRECATION_REPLACE_NOTICE
14
-
15
-
16
- def deprecation_notice(to_replace: str) -> callable:
17
- """
18
- A decorator that issues a DeprecationWarning when a deprecated method is called.
19
-
20
- Args:
21
- to_replace: The name of the method to use instead.
22
-
23
- Returns:
24
- callable: A decorator function.
25
- """
26
-
27
- def decorator(func: callable) -> callable:
28
- @wraps(func)
29
- def wrapper(*args, **kwargs):
30
- class_name = args[0].__class__.__name__
31
- method_name = func.__name__
32
- to_deprecate = f"{class_name}.{method_name}"
33
- replacement = f"{class_name}.{to_replace}"
34
- warn(
35
- f"{DEPRECATION_NOTICE.format(to_deprecate)} {DEPRECATION_REPLACE_NOTICE.format(replacement)}",
36
- DeprecationWarning,
37
- stacklevel=2,
38
- )
39
- return func(*args, **kwargs)
40
-
41
- return wrapper
42
-
43
- return decorator
@@ -1,71 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- PyPDFForm/__init__.py
5
- PyPDFForm/adapter.py
6
- PyPDFForm/constants.py
7
- PyPDFForm/coordinate.py
8
- PyPDFForm/deprecation.py
9
- PyPDFForm/egress.py
10
- PyPDFForm/filler.py
11
- PyPDFForm/font.py
12
- PyPDFForm/hooks.py
13
- PyPDFForm/image.py
14
- PyPDFForm/patterns.py
15
- PyPDFForm/template.py
16
- PyPDFForm/types.py
17
- PyPDFForm/utils.py
18
- PyPDFForm/watermark.py
19
- PyPDFForm/wrapper.py
20
- PyPDFForm.egg-info/PKG-INFO
21
- PyPDFForm.egg-info/SOURCES.txt
22
- PyPDFForm.egg-info/dependency_links.txt
23
- PyPDFForm.egg-info/requires.txt
24
- PyPDFForm.egg-info/top_level.txt
25
- PyPDFForm/annotations/__init__.py
26
- PyPDFForm/annotations/base.py
27
- PyPDFForm/annotations/link.py
28
- PyPDFForm/annotations/stamp.py
29
- PyPDFForm/annotations/text.py
30
- PyPDFForm/annotations/text_markup.py
31
- PyPDFForm/assets/__init__.py
32
- PyPDFForm/assets/bedrock.py
33
- PyPDFForm/assets/blank.py
34
- PyPDFForm/middleware/__init__.py
35
- PyPDFForm/middleware/base.py
36
- PyPDFForm/middleware/checkbox.py
37
- PyPDFForm/middleware/dropdown.py
38
- PyPDFForm/middleware/image.py
39
- PyPDFForm/middleware/radio.py
40
- PyPDFForm/middleware/signature.py
41
- PyPDFForm/middleware/text.py
42
- PyPDFForm/raw/__init__.py
43
- PyPDFForm/raw/circle.py
44
- PyPDFForm/raw/ellipse.py
45
- PyPDFForm/raw/image.py
46
- PyPDFForm/raw/line.py
47
- PyPDFForm/raw/rect.py
48
- PyPDFForm/raw/text.py
49
- PyPDFForm/widgets/__init__.py
50
- PyPDFForm/widgets/base.py
51
- PyPDFForm/widgets/checkbox.py
52
- PyPDFForm/widgets/dropdown.py
53
- PyPDFForm/widgets/image.py
54
- PyPDFForm/widgets/radio.py
55
- PyPDFForm/widgets/signature.py
56
- PyPDFForm/widgets/text.py
57
- tests/test_bulk_create_fields.py
58
- tests/test_create_widget.py
59
- tests/test_draw_elements.py
60
- tests/test_dropdown.py
61
- tests/test_extract_middleware_attributes.py
62
- tests/test_fill_max_length_text_field.py
63
- tests/test_font_widths.py
64
- tests/test_functional.py
65
- tests/test_generate_appearance_streams.py
66
- tests/test_js.py
67
- tests/test_need_appearances.py
68
- tests/test_paragraph.py
69
- tests/test_signature.py
70
- tests/test_use_full_widget_name.py
71
- tests/test_widget_attr_trigger.py
File without changes
File without changes
File without changes
File without changes
File without changes