Skip to content

MAINT: Use typing_extensions.deprecated (PEP 702) for deprecations - #3928

Open
prateek-dagar wants to merge 2 commits into
py-pdf:mainfrom
prateek-dagar:issue-2036-typing-deprecated
Open

MAINT: Use typing_extensions.deprecated (PEP 702) for deprecations#3928
prateek-dagar wants to merge 2 commits into
py-pdf:mainfrom
prateek-dagar:issue-2036-typing-deprecated

Conversation

@prateek-dagar

Copy link
Copy Markdown

Description

Closes #2036.

This PR adds @deprecated decorators to deprecated methods and properties. This helps IDEs and type checkers show warning messages directly to developers.

Changes

  • Require typing_extensions >= 4.5.0 for Python < 3.13.
  • Import deprecated from the standard warnings module (Python 3.13+) or typing_extensions (older versions).
  • Add @deprecated to PageObject.inline_images and XmpInformation.write_to_stream.
  • Commented out old warning calls inside these methods.

@prateek-dagar prateek-dagar changed the title Use typing_extensions.deprecated (PEP 702) for deprecations MAINT: Use typing_extensions.deprecated (PEP 702) for deprecations Jul 24, 2026
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.86%. Comparing base (11a0f77) to head (fcb7243).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3928      +/-   ##
==========================================
- Coverage   97.87%   97.86%   -0.01%     
==========================================
  Files          57       57              
  Lines       10760    10743      -17     
  Branches     2014     2012       -2     
==========================================
- Hits        10531    10514      -17     
  Misses        127      127              
  Partials      102      102              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stefan6419846

Copy link
Copy Markdown
Collaborator

Which benefits does this have compared to the existing solution? How does this align with our general deprecation process?

At the moment, I am tempted to close this PR and the corresponding issue without merging anything in.

@prateek-dagar

Copy link
Copy Markdown
Author

Which benefits does this have compared to the existing solution? How does this align with our general deprecation process?

At the moment, I am tempted to close this PR and the corresponding issue without merging anything in.

Hi @stefan6419846 ,
The main benefit of adopting typing_extensions.deprecated (PEP 702) is standardization across the Python ecosystem.
Also, type checkers like mypy and pyright don't warn about deprecation's under our current solution, but using this decorator fixes that.

@stefan6419846

stefan6419846 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

This still does not answer how this aligns with our deprecation process. We currently wrap warnings.warn with different utility functions to reduce the manual overhead, and using typing_extensions.deprecated (or warnings.deprecated) directly would be a step back here.

Additionally, we would still need an approach for cases where a decorator might not work, like wrong internal types, replaced parameters etc.

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.

Use typing_extensions.deprecated

2 participants