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

MAINT: Deprecate features with PyPDF2==3.0.0 #1489

Merged
merged 11 commits into from Dec 17, 2022
Merged

MAINT: Deprecate features with PyPDF2==3.0.0 #1489

merged 11 commits into from Dec 17, 2022

Conversation

MartinThoma
Copy link
Member

@MartinThoma MartinThoma commented Dec 10, 2022

Deprecate features, but keep helpful exceptions. That means that the names still need to be there. They will stay until 4.0.0. Let's hope the community can transition in that time.

@MartinThoma MartinThoma added this to the PyPDF2==3.0.0 milestone Dec 10, 2022
@MartinThoma MartinThoma marked this pull request as draft December 10, 2022 23:17
@codecov
Copy link

codecov bot commented Dec 11, 2022

Codecov Report

❗ No coverage uploaded for pull request base (main@74b8a63). Click here to learn what that means.
Patch coverage: 96.87% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1489   +/-   ##
=======================================
  Coverage        ?   92.03%           
=======================================
  Files           ?       32           
  Lines           ?     5977           
  Branches        ?     1163           
=======================================
  Hits            ?     5501           
  Misses          ?      312           
  Partials        ?      164           
Impacted Files Coverage Δ
PyPDF2/_page.py 89.56% <ø> (ø)
PyPDF2/_reader.py 90.32% <ø> (ø)
PyPDF2/generic/_base.py 99.64% <ø> (ø)
PyPDF2/generic/_data_structures.py 89.97% <ø> (ø)
PyPDF2/types.py 100.00% <ø> (ø)
PyPDF2/_utils.py 97.46% <90.90%> (ø)
PyPDF2/_merger.py 93.18% <100.00%> (ø)
PyPDF2/_writer.py 83.94% <100.00%> (ø)
PyPDF2/errors.py 100.00% <100.00%> (ø)
PyPDF2/generic/_outline.py 100.00% <100.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MartinThoma MartinThoma marked this pull request as ready for review December 11, 2022 09:32
@@ -1966,7 +1971,7 @@ def xfa(self) -> Optional[Dict[str, Any]]:

class PdfFileReader(PdfReader): # pragma: no cover
def __init__(self, *args: Any, **kwargs: Any) -> None:
deprecate_with_replacement("PdfFileReader", "PdfReader")
deprecation_with_replacement("PdfFileReader", "PdfReader", "3.0.0")
Copy link
Member

Choose a reason for hiding this comment

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

As opposed to having this continue to work just fine, but having a message say that "This was removed in 3.0.0", maybe better to just have this hard error, forcing the user to change? Otherwise, feels weird to have a deprecation message saying some functionality was removed in 3.0.0 and wasn't, and would read to me as a bug of some sort.

Copy link
Member Author

Choose a reason for hiding this comment

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

The deprecation_with_replacement raises an exception instead of using warnings.warn. So it will stop working.

The point that I want to address by leaving it here is that (1) many people don't have warnings enabled and (2) a lot of deprecated code still gets written to new tutorials / answers on StackExchange. I see PdfFileParse all the time.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes, I missed the new deprecation utils function and thought these were just calling deprecate with a different string, as well as that the code following this function call wasn't removed. I feel like should maybe remove all code that follows the deprecation call should be removed to better signal that everything ends subsequent to the deprecation call.

I do think having a second release of more strongly removing them while still having it be callable makes sense given the very long tail of Internet tutorials, and also using the opportunity of pypdf to remove it since usage of the new package should be a good separation signal from outdated guides.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had two ideas in mind when I didn't remove the function body:

  1. The diff is a little bit cleaner. It is still very messy, though.
  2. If anybody really needs it, they could overwrite the deprecation_X functions and the code would still work
  3. I'm looking forward to a big commit where we remove hundreds of lines 😄

Those arguments are pretty weak, though.

I do think having a second release of more strongly removing them while still having it be callable makes sense given the very long tail of Internet tutorials, and also using the opportunity of pypdf to remove it since usage of the new package should be a good separation signal from outdated guides.

I'm not sure if I can follow. What do you think how we should proceed (with this PR and the versions of PyPDF2/pypdf)?

@MartinThoma MartinThoma merged commit a4629d3 into main Dec 17, 2022
@MartinThoma MartinThoma deleted the deprecate-3 branch December 17, 2022 04:53
MartinThoma added a commit that referenced this pull request Dec 22, 2022
BREAKING CHANGES:
-  Deprecate features with PyPDF2==3.0.0 (#1489)
-  Refactor Fit / Zoom parameters (#1437)

New Features (ENH):
-  Add Cloning  (#1371)
-  Allow int for indirect_reference in PdfWriter.get_object (#1490)

Documentation (DOC):
-  How to read PDFs from S3 (#1509)
-  Make MyST parse all links as simple hyperlinks (#1506)
-  Changed 'latest' for 'stable' generated docs (#1495)
-  Adjust deprecation procedure (#1487)

Maintenance (MAINT):
-  Use typing.IO for file streams (#1498)

[Full Changelog](2.12.1...3.0.0)
raimonesteve added a commit to NaN-tic/tryton-config that referenced this pull request Dec 27, 2022
raimonesteve added a commit to NaN-tic/tryton-config that referenced this pull request Dec 27, 2022
raimonesteve added a commit to NaN-tic/tryton-config that referenced this pull request Dec 27, 2022
raimonesteve added a commit to NaN-tic/tryton-config that referenced this pull request Dec 27, 2022
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.

None yet

2 participants