I found a self-triggered deprecation warning while running tests for a project I maintain which depends on PyPDF2. We treat warnings as errors in our CI.
Environment
Which environment were you using when you encountered the problem?
$ python -m platform
macOS-12.3.1-x86_64-i386-64bit
$ python -c "import PyPDF2;print(PyPDF2.__version__)"
1.28.1
Code
This is a minimal, complete example that shows the issue:
# t.py
from PyPDF2 import PdfReader, PdfMerger
merger = PdfMerger()
merger.append(PdfReader("example.pdf", "rb"))
Running python -Werror t.py raises:
Traceback (most recent call last):
File "/Users/robcleme/dev/friends/AMICAL/t.py", line 6, in <module>
merger.append(PdfReader(ifile, "rb"))
File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/PyPDF2/merger.py", line 234, in append
self.merge(len(self.pages), fileobj, bookmark, pages, import_bookmarks)
File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/PyPDF2/merger.py", line 133, in merge
if isString(fileobj):
File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/PyPDF2/_utils.py", line 76, in isString
warnings.warn(DEPR_MSG_NO_REPLACEMENT.format("isString"))
UserWarning: isString is deprecated and will be removed in PyPDF2 2.0.0.
So the warning is triggered from PyPDF2.merger.py, meaning some internal functionalities are still relying on deprecated API, but it's out of my control to deal with it from the user side.
PDF
any pdf works as example.pdf here.
I further note that ignoring this single warning in my CI isn't enough, as I get into another, similarly self-triggered warning, i.e.
UserWarning: namedDestinations will be removed in PyPDF2 2.0.0. Use `named_destinations` instead.
I suggest maintainers to start treating warnings as errors in PyPDF2's CI so this kind of problem can be detected ahead of releases.
I found a self-triggered deprecation warning while running tests for a project I maintain which depends on PyPDF2. We treat warnings as errors in our CI.
Environment
Which environment were you using when you encountered the problem?
$ python -m platform macOS-12.3.1-x86_64-i386-64bit $ python -c "import PyPDF2;print(PyPDF2.__version__)" 1.28.1Code
This is a minimal, complete example that shows the issue:
Running
python -Werror t.pyraises:So the warning is triggered from
PyPDF2.merger.py, meaning some internal functionalities are still relying on deprecated API, but it's out of my control to deal with it from the user side.PDF
any pdf works as
example.pdfhere.I further note that ignoring this single warning in my CI isn't enough, as I get into another, similarly self-triggered warning, i.e.
I suggest maintainers to start treating warnings as errors in PyPDF2's CI so this kind of problem can be detected ahead of releases.