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-101561: Add typing.override decorator by stroxler · Pull Request #101564 · python/cpython

Conversation

@stroxler

@stroxler stroxler commented Feb 4, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

The code is pulled almost unchanged from typing_extensions:

  • decorator implementation
  • tests

Question that came up was where to put the type variable and what to name it:

  • In typing_extensions the type variables use underscore prefixes to indicate that they are not public, but typing doesn't appear to use that convention so I named the type variable F.
  • I couldn't put the type variable next to all of the other ones (used in generic container definitions) because it relies on Callable which is defined below. If this is a problem I could correct it using a forward reference, or we could try to rearrange the module to put special forms above type variables.

Testing the code:

First set up the repo, following instructions
at https://devguide.python.org/ by running:

./configure --with-pydebug && make -j

Then run the typing tests:

./python -m test test_typing -v

I ran the full test suite with

./python -m test -j3

and it came back clean except for a test_grp failure which I seem to get on trunk as well - likely something in my build is misconfigured but I'm pretty sure it is unrelated to the changes here.

  • Issue: Add typing.override decorator #101561

Make sure the docs build:

cd Doc
make venv
make html

Sorry, something went wrong.

Uh oh!

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

All reactions
@stroxler
stroxler requested review from AlexWaygood, Fidget-Spinner, JelleZijlstra and gvanrossum as code owners February 4, 2023 16:27
@bedevere-bot bedevere-bot added the awaiting review label Feb 4, 2023
@bedevere-bot

bedevere-bot commented Feb 4, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

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

@stroxler stroxler changed the title PEP 698: Add typing.override decorator gh-101561: Add typing.override decorator Feb 4, 2023
@bedevere-bot bedevere-bot mentioned this pull request Feb 4, 2023
Add typing.override decorator #101561
Closed
@bedevere-bot

bedevere-bot commented Feb 4, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

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

AlexWaygood
AlexWaygood reviewed Feb 4, 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.

Thanks! Haven't looked in depth yet at all, but we'll also need:

  • A news entry, as @bedevere-bot says
  • An entry in Doc/whatsnew/3.12.rst
  • (optionally) you can add your name to Misc/ACKS

Sorry, something went wrong.

Uh oh!

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

stroxler reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
JelleZijlstra
JelleZijlstra reviewed Feb 4, 2023
View reviewed changes
Comment thread Doc/library/typing.rst Resolved

Uh oh!

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

@arhadthedev arhadthedev added stdlib Standard Library Python modules in the Lib/ directory topic-typing labels Feb 4, 2023
@AlexWaygood AlexWaygood added type-feature A feature request or enhancement 3.12 only security fixes labels Feb 4, 2023
AlexWaygood
AlexWaygood reviewed Feb 4, 2023
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2023-02-04-16-35-46.gh-issue-101561.Xo6pIZ.rst Resolved

Uh oh!

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

TeamSpen210
TeamSpen210 reviewed Feb 4, 2023
View reviewed changes
Comment thread Lib/typing.py Resolved

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Feb 7, 2023

Copy link
Copy Markdown
Member

The implementation for override LGTM.

stroxler 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.

facebook-github-bot referenced this pull request in meta/pyre-check Feb 9, 2023
@stroxler @facebook-github-bot
Support {typing,typing_extensions}.override
0a1ebee
Summary:
THe `typing_extensions.override` was added a few months ago,
we should support it.

The `typing.override` decorator isn't landed yet, but that's okay - we
should support it in override checks; it will still raise a "no such name"
method when Pyre is being run against a typeshed that doens't have it yet.

The PR to add `typing.override` to CPython is out for review now:
https://github.com/python/cpython/pull/101564`

Reviewed By: grievejia

Differential Revision: D43055550

fbshipit-source-id: 3f51f643063afea75bf54ef38ae3a48681b99bd9
@bersbersbers bersbersbers mentioned this pull request Feb 12, 2023
nuitka is incompatible with overrides Nuitka/Nuitka#2048
Closed
stroxler and others added 9 commits February 27, 2023 11:55
@stroxler
PEP 698: Add typing.override decorator
e2349bb
Testing:

First set up the repo, following instructions
at https://devguide.python.org/ by running:
```
./configure --with-pydebug && make -j
```

Then run the typing tests:
```
./python -m test test_typing -v
```

I ran the full test suite with
```
./python -m test -j3
```
and it came back clean except for a `test_grp` failure which I seem to
get on trunk as well - likely something in my build is misconfigured
but I'm pretty sure it is unrelated to the changes here.
@stroxler
Add missing For example:: in the rst doc
bd3b6ac
@blurb-it @stroxler
📜🤖 Added by blurb_it.
c3b9b7f
@stroxler @JelleZijlstra
Update Doc/library/typing.rst
c7cecf8
Correct `s/final/override` (from reusing a similar block of documentation on the `@final` decorator)

Co-authored-by: Jelle Zijlstra <[email protected]>
@stroxler
Add whatsnew entry, as per Alex Waygood's suggestion
2acf32f
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@stroxler
Add ACKS entry, fix rst errors
6bd3356
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@stroxler
Fix title underline length in whatisnew doc.
42277cb
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@stroxler @AlexWaygood
Update Misc/NEWS.d/next/Library/2023-02-04-16-35-46.gh-issue-101561.X…
afb74de
…o6pIZ.rst

Co-authored-by: Alex Waygood <[email protected]>
@stroxler
Use a positional-only argument named method
090d9d2
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@stroxler
stroxler force-pushed the gh-101561-typing-override branch from 4a04527 to 090d9d2 Compare February 27, 2023 19:56
@stroxler

stroxler commented Feb 27, 2023

Copy link
Copy Markdown
Contributor Author

(Rebase on main)

@gvanrossum I think this is waiting on review from you

All reactions

Sorry, something went wrong.

Uh oh!

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

JelleZijlstra
JelleZijlstra approved these changes Feb 27, 2023
View reviewed changes

@JelleZijlstra JelleZijlstra 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.

Sorry for dropping this; I have a few nits but I'm happy to merge the PR. I'll leave it open for a few days in case Guido does want to take a look himself.

Sorry, something went wrong.

Uh oh!

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

stroxler reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Library/2023-02-04-16-35-46.gh-issue-101561.Xo6pIZ.rst Resolved

Uh oh!

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

@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Feb 27, 2023
@JelleZijlstra JelleZijlstra self-assigned this Feb 27, 2023
@gvanrossum

gvanrossum commented Feb 27, 2023

Copy link
Copy Markdown
Member

I defer to @JelleZijlstra if that's okay.

JelleZijlstra 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.

@stroxler @JelleZijlstra
Apply suggestions from code review
f6c00e5
Thanks, looks good

Co-authored-by: Jelle Zijlstra <[email protected]>
@JelleZijlstra
JelleZijlstra merged commit 0f89acf into python:main Feb 27, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Feb 27, 2023
@sobolevn sobolevn mentioned this pull request Feb 28, 2023
gh-102324: Improve tests of typing.override #102325
Merged
@sobolevn

sobolevn commented Feb 28, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Sorry for being late with a review, I've opened a follow-up for this: #102324

Thanks a lot for adding this decorator! Great work, it would be very useful! 👍

All reactions

Sorry, something went wrong.

Uh oh!

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

carljm added a commit to carljm/cpython that referenced this pull request Feb 28, 2023
@carljm
Merge branch 'main' into inlinecomp2
73dc0ed
* main: (67 commits)
  pythongh-99108: Add missing md5/sha1 defines to Modules/Setup (python#102308)
  pythongh-100227: Move _str_replace_inf to PyInterpreterState (pythongh-102333)
  pythongh-100227: Move the dtoa State to PyInterpreterState (pythongh-102331)
  pythonGH-102305: Expand some macros in generated_cases.c.h (python#102309)
  Migrate to new PSF mailgun account (python#102284)
  pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Python/) (python#102193)
  pythonGH-90744: Fix erroneous doc links in the sys module (python#101319)
  pythongh-87092: Make jump target label equal to the offset of the target in the instructions sequence (python#102093)
  pythongh-101101: Unstable C API tier (PEP 689) (pythonGH-101102)
  IDLE: Simplify DynOptionsMenu __init__code (python#101371)
  pythongh-101561: Add typing.override decorator (python#101564)
  pythongh-101825: Clarify that as_integer_ratio() output is always normalized (python#101843)
  pythongh-101773: Optimize creation of Fractions in private methods (python#101780)
  pythongh-102251: Updates to test_imp Toward Fixing Some Refleaks (pythongh-102254)
  pythongh-102296 Document that inspect.Parameter kinds support ordering (pythonGH-102297)
  pythongh-102250: Fix double-decref in COMPARE_AND_BRANCH error case (pythonGH-102287)
  pythongh-101100: Fix sphinx warnings in `types` module (python#102274)
  pythongh-91038: Change default argument value to `False` instead of `0` (python#31621)
  pythongh-101765: unicodeobject: use Py_XDECREF correctly (python#102283)
  [doc] Improve grammar/fix missing word (pythonGH-102060)
  ...
JelleZijlstra pushed a commit that referenced this pull request Mar 3, 2023
@sobolevn
gh-102324: Improve tests of typing.override (#102325)
12011dd
Fixes #101564
@coderabbitai coderabbitai Bot mentioned this pull request Apr 15, 2026
refactor: update type hints and add overrides MountainGod2/cb-events#110
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AlexWaygood AlexWaygood AlexWaygood left review comments
@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner
+1 more reviewer
@TeamSpen210 TeamSpen210 TeamSpen210 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@JelleZijlstra JelleZijlstra

Labels

3.12 only security fixes stdlib Standard Library Python modules in the Lib/ directory topic-typing type-feature A feature request or enhancement

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.

9 participants

@stroxler @bedevere-bot @Fidget-Spinner @gvanrossum @sobolevn @JelleZijlstra @TeamSpen210 @AlexWaygood @arhadthedev
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.