Skip to content

Commit

Permalink
Add a deprecation warning for version and identifier in __init__
Browse files Browse the repository at this point in the history
This new code is a bit more compatible with previous versions, and should at
least work with older versions of WeasyPrint.
  • Loading branch information
liZe committed Apr 25, 2024
1 parent fef52da commit c2bc939
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pydyf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from codecs import BOM_UTF16_BE
from hashlib import md5
from math import ceil, log
from warnings import warn

VERSION = __version__ = '0.9.0'

Expand Down Expand Up @@ -443,8 +444,17 @@ def data(self):

class PDF:
"""PDF document."""
def __init__(self):
def __init__(self, version=None, identifier=None):
"""Create a PDF document."""
if version or identifier: # to be removed in next version
warn(
"PDF objects don’t take version or identifier during initialization "
"anymore. These properties are now stored but ignored, and will be "
"removed and rejected in next version of pydyf. Please pass these "
"properties to the PDF.write() method instead.", DeprecationWarning)
self.version = _to_bytes(version) if version else b'1.7' # to be removed
self.identifier = identifier # to be removed

#: Python :obj:`list` containing the PDF’s objects.
self.objects = []

Expand Down

0 comments on commit c2bc939

Please sign in to comment.