GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-104003: Implement PEP 702 by JelleZijlstra · Pull Request #104004 · python/cpython

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Apr 30, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Implement PEP 702: Marking deprecations using the type system #104003

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JelleZijlstra
pythongh-104003: Implement PEP 702
93e11d6
@JelleZijlstra JelleZijlstra added the DO-NOT-MERGE label Apr 30, 2023
@JelleZijlstra
JelleZijlstra requested review from AlexWaygood, Fidget-Spinner and gvanrossum as code owners April 30, 2023 03:45
@bedevere-bot bedevere-bot mentioned this pull request Apr 30, 2023
Implement PEP 702: Marking deprecations using the type system #104003
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Apr 30, 2023
@JelleZijlstra
blurb
d8d3157
@JelleZijlstra

JelleZijlstra commented Apr 30, 2023

Copy link
Copy Markdown
Member Author

This is copied from python/typing_extensions#105.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hauntsaninja
hauntsaninja reviewed Apr 30, 2023
View reviewed changes
Comment thread Lib/test/test_typing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_typing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra
Add more tests
342f28b
gvanrossum
gvanrossum approved these changes Apr 30, 2023
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Apr 30, 2023
JelleZijlstra added 2 commits May 6, 2023 08:30
@JelleZijlstra
describe runtime behavior
9b167e8
@JelleZijlstra
steal the typing-extensions wording instead, it's better
0ed9d41
gvanrossum
gvanrossum approved these changes May 6, 2023
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Waiting for the other reviewers to pipe in? This seems pretty straightforward.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AlexWaygood

AlexWaygood commented May 6, 2023

Copy link
Copy Markdown
Member

Waiting for the other reviewers to pipe in? This seems pretty straightforward.

The PEP hasn't been accepted yet!

erlend-aasland reacted with thumbs up emoji gvanrossum reacted with laugh emoji
All reactions
  • 👍 1 reaction
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra

JelleZijlstra commented May 6, 2023

Copy link
Copy Markdown
Member Author

Planning to hit the merge button the moment the PEP is accepted :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra

JelleZijlstra commented Nov 7, 2023

Copy link
Copy Markdown
Member Author

PEP 702 has been accepted, but it's changed since this PR. I'll update the PR soon to put the decorator in warnings and sync the implementation from typing-extensions.

AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra added 4 commits November 7, 2023 19:02
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into pep702
2f69b4e
@JelleZijlstra
Put it in warnings, copy over from typing-extensions
815591b
@JelleZijlstra
docs
4098e62
@JelleZijlstra
fix test
d6625b9
@JelleZijlstra JelleZijlstra removed the DO-NOT-MERGE label Nov 8, 2023
JelleZijlstra
JelleZijlstra commented Nov 8, 2023
View reviewed changes
Comment thread Doc/glossary.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra JelleZijlstra mentioned this pull request Nov 8, 2023
Glossary: Add "static type checker" #111837
Merged
hugovk
hugovk reviewed Nov 8, 2023
View reviewed changes
Comment thread Doc/library/warnings.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/warnings.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

AlexWaygood
AlexWaygood reviewed Nov 8, 2023
View reviewed changes
Comment thread Doc/library/warnings.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/warnings.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.13.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2023-04-29-20-49-13.gh-issue-104003.-8Ruk2.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra @hugovk
Update Doc/library/warnings.rst
0870a16
Co-authored-by: Hugo van Kemenade <[email protected]>
@AlexWaygood

AlexWaygood commented Nov 26, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Doesn't seem to be get_origin's primary use

It's already sorta awkwardly overloaded in what it means tbh — the __origin__ attribute of ParamSpecArgs instances doesn't really have the same semantics as the __origin__ attribute of generic aliases :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Zac-HD

Zac-HD commented Nov 26, 2023

Copy link
Copy Markdown
Contributor

A class seems somewhat more elegant to me, but yeah, that would work.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra

JelleZijlstra commented Nov 27, 2023

Copy link
Copy Markdown
Member Author

I'm OK with making it a class. It's not what the object is meant for, but it's a reasonable extension.

Using __origin__ feels hacky and wouldn't provide an easy way to get the deprecation message out.

Zac-HD, AlexWaygood, and Viicos reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra added 2 commits November 26, 2023 17:25
@JelleZijlstra
make it a class
ed9a10c
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into pep702
6ab4584
AlexWaygood
AlexWaygood reviewed Nov 27, 2023
View reviewed changes
Comment thread Lib/warnings.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/warnings.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.13.rst Outdated
Comment on lines +338 to +340
* The new :func:`warnings.deprecated` decorator provides a way to communicate
deprecations to :term:`static type checkers <static type checker>` and
to warn on usage of deprecated classes and functions.

@AlexWaygood AlexWaygood Nov 27, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Despite static typing being the original motivation for the feature, I would actually put the runtime effect first here:

Suggested change
* The new :func:`warnings.deprecated` decorator provides a way to communicate
deprecations to :term:`static type checkers <static type checker>` and
to warn on usage of deprecated classes and functions.
* The new :func:`warnings.deprecated` decorator provides an ergonomic way to
mark a class or function as deprecated. A deprecation warning will be
emitted whenever a decorated function or class is used at runtime. The
decorator is also understood by
:term:`static type checkers <static type checker>`, which will emit warnings
if they identify a decorated function or class being used.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JelleZijlstra JelleZijlstra Nov 29, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I still want to put the type checker effect first because that's the unique part. You can write a decorator that generates runtime warnings yourself; the new and exciting part is that this decorator is also understood by static type checkers.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood Nov 29, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You can do, sure, but do people? It was possible to reimplement itertools.batched in a few lines of code before Python 3.12, but lots of people were still very excited by its inclusion in the stdlib in Python 3.12.

I think this new decorator here could prove pretty popular with people who don't use static typing! But, I don't feel strongly; it looks fine to me now :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JelleZijlstra JelleZijlstra Nov 29, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Sure, there are lots of third-party deprecation decorators. The Deprecated library, I think Flask has one internally (David Lord mentioned it in PEP 702 discussions), I know at Quora we have one internally.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AlexWaygood AlexWaygood Nov 29, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm not sure if that's meant to be a point in agreement or in disagreement with the point I'm making that this decorator could prove pretty popular with people who don't use static typing. Anyway, as I say, I'm happy with the docs now!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/warnings.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/warnings.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra added 5 commits November 28, 2023 18:34
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into pep702
e60ad5c
@JelleZijlstra
Forward-port typing-extensions change
d528dc8
@JelleZijlstra
Add test suggested by Alex
e323502
@JelleZijlstra
Adjust docs
acf49b3
@JelleZijlstra
Add to Whats New
1d663ef
@JelleZijlstra

JelleZijlstra commented Nov 29, 2023

Copy link
Copy Markdown
Member Author

Thanks @AlexWaygood for the review! I pushed some changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra added 2 commits November 28, 2023 18:44
@JelleZijlstra
Now that this is semi-public, use a better name
b94255d
@JelleZijlstra
sync docstring
e7a361b
@JelleZijlstra JelleZijlstra mentioned this pull request Nov 29, 2023
Update @deprecated implementation python/typing_extensions#302
Merged
@JelleZijlstra
Update error msg
08efe4d
AlexWaygood
AlexWaygood reviewed Nov 29, 2023
View reviewed changes
Comment thread Doc/library/warnings.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_warnings/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_warnings/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/warnings.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood
Apply suggestions from code review
f4eb075
AlexWaygood
AlexWaygood approved these changes Nov 29, 2023
View reviewed changes

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
AlexWaygood
AlexWaygood reviewed Nov 29, 2023
View reviewed changes
Comment thread Lib/warnings.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra @AlexWaygood
Update Lib/warnings.py
c02f66f
Co-authored-by: Alex Waygood <[email protected]>
@JelleZijlstra
JelleZijlstra merged commit d4a6229 into python:main Nov 29, 2023
@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 29, 2023
@JelleZijlstra
JelleZijlstra deleted the pep702 branch November 29, 2023 17:38
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@JelleZijlstra @hugovk
@AlexWaygood @aisk
pythongh-104003: Implement PEP 702 (python#104004)
81b8aeb
Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@JelleZijlstra @hugovk
@AlexWaygood @Glyphack
pythongh-104003: Implement PEP 702 (python#104004)
82d9ee3
Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
@dolfinus dolfinus mentioned this pull request Aug 22, 2025
[PROPOSAL] Add deprecation API decorator (Python) and annotation (Java) for better API lifecycle OpenLineage/OpenLineage#3984
Open
@Viicos Viicos mentioned this pull request May 19, 2026
Clarify warnings.deprecated public API #150076
Open
@fedonman fedonman mentioned this pull request Jul 19, 2026
gh-150076: Fix the documented signature of warnings.deprecated #153879
Merged
@flying-sheep flying-sheep mentioned this pull request Sep 4, 2026
warnings.deprecated has no skip_file_prefixes #156929
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk left review comments
@hauntsaninja hauntsaninja hauntsaninja left review comments
@AlexWaygood AlexWaygood AlexWaygood approved these changes
@gvanrossum gvanrossum gvanrossum approved these changes
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@JelleZijlstra @AlexWaygood @Zac-HD @Viicos @hugovk @gvanrossum @hauntsaninja @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.