Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Incorrectly show deprecation warnings on internal usage #887

Merged
merged 2 commits into from
May 22, 2022

Conversation

MasterOdin
Copy link
Member

Fixes #886

PR fixes a bug where the codebase was internally relying on deprecated functions and so would trigger the warnings even though there's no action the user could meaningful taken. Now, the internal usage relies on an internal version of the function that executes as before sans deprecation warning while leaving in place a user facing version of the function that has the deprecation warning (and relies on the new internal function to keep behavior consistent).

@codecov
Copy link

codecov bot commented May 22, 2022

Codecov Report

Merging #887 (6268096) into main (560d2a7) will decrease coverage by 0.06%.
The diff coverage is 77.77%.

@@            Coverage Diff             @@
##             main     #887      +/-   ##
==========================================
- Coverage   77.25%   77.18%   -0.07%     
==========================================
  Files          17       17              
  Lines        4326     4335       +9     
  Branches      819      820       +1     
==========================================
+ Hits         3342     3346       +4     
- Misses        809      814       +5     
  Partials      175      175              
Impacted Files Coverage Δ
PyPDF2/_reader.py 76.69% <66.66%> (ø)
PyPDF2/merger.py 64.32% <66.66%> (ø)
PyPDF2/_utils.py 89.13% <75.00%> (-2.30%) ⬇️
PyPDF2/_writer.py 79.93% <100.00%> (ø)
PyPDF2/pagerange.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 560d2a7...6268096. Read the comment docs.

@@ -162,13 +174,8 @@ def readUntilRegex(stream, regex, ignore_eof=False):
return name


class ConvertFunctionsToVirtualList(object):
class _VirtualList(object):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the name you used in 2.0.0-dev branch for this to hopefully make the merge commit a bit easier.

@@ -66,23 +66,35 @@
DEPR_MSG = "{} is deprecated and will be removed in PyPDF2 2.0.0. Use {} instead."


def _isString(s):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to go with the camel case for these functions to make the diff a bit easier to read imo, and since these functions are not user facing and are going to be removed anyway in 2.0.0, it does not matter much on their naming convention imo.

@MartinThoma MartinThoma merged commit ce1cb66 into main May 22, 2022
@MartinThoma MartinThoma deleted the fix-dep-warnings branch May 22, 2022 19:09
MartinThoma added a commit that referenced this pull request May 22, 2022
Bug Fixes (BUG):
-  Incorrectly show deprecation warnings on internal usage (#887)

Maintenance (MAINT):
-  Add stacklevel=2 to deprecation warnings (#889)
-  Remove duplicate warnings imports (#888)

Full Changelog: 1.28.0...1.28.1
MartinThoma pushed a commit that referenced this pull request May 23, 2022
Fixes a deprecation warning being raised when trying to use the PdfMerger class. This regression of #887 is caused by #889 which reversed the changes done to the PyPDF2/merger.py module so that it once again used the deprecated user-facing isString method as opposed to the internal _isString method.

Additionally, this PR fixes the deprecation warning raised by referencing reader.namedDestinations as opposed to reader.named_destinations.

Closes #890
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Basic usage triggers deprecation warning
2 participants