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-119180: Use type descriptors to access annotations (PEP 749) by JelleZijlstra · Pull Request #122074 · python/cpython

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Jul 21, 2024 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

A third alternative to #120719 and #120816. See python/peps#3847 (comment).

This PR is on top of #119891.

  • Issue: Implement PEP 649 and PEP 749 #119180

📚 Documentation preview 📚: https://cpython-previews--122074.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
JelleZijlstra added 30 commits May 20, 2024 09:59
@JelleZijlstra
Add __annotate__ descriptors
985f8df
@JelleZijlstra
fix refleaks
c822ffa
@JelleZijlstra
blurb
e80095e
@JelleZijlstra
Fix some tests
90ff2c4
@JelleZijlstra
regen globals
026c0ff
@JelleZijlstra
Some initial work
7968744
@JelleZijlstra
Add bytecode for adding annotate
4e54197
@JelleZijlstra
compiler changes
4469b32
@JelleZijlstra
Functions work
47d672e
@JelleZijlstra
Raise AssertionError on the wrong format
ab9359c
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into pep649-compile
e65d55a
@JelleZijlstra
Modules and classes
e50cd62
@JelleZijlstra
attempts
afae5c0
@JelleZijlstra
Fixes
e5a7b1a
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into pep649-compile
3f26d44
@JelleZijlstra
Fix code object name
31a4471
@JelleZijlstra
Start fixing test_type_annotations
fbb1d88
@JelleZijlstra
Fix class scoping
f452eb2
@JelleZijlstra
unyielding
8c4b4e3
@JelleZijlstra
Fix test_typing
cbf9a3d
@JelleZijlstra
Fix test_type_parmas
5d182fc
@JelleZijlstra
Add test, add to inspect
ce98c19
@JelleZijlstra
Use inspect constants
e0578fc
@JelleZijlstra
test_grammar tweaks
ed16167
@JelleZijlstra
fix test_positional_only_arg
f38de20
@JelleZijlstra
Fix test_module
87baca2
@JelleZijlstra
Fix symtable tests
355d3df
@JelleZijlstra
fix test_pydoc
f9d81b6
@JelleZijlstra
fix test_traceback
dd1f64a
@JelleZijlstra
fix test_opcodes
62f5b3b
JelleZijlstra added 8 commits June 13, 2024 08:51
@JelleZijlstra
Add some tests
9fd65bf
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into pep649-inspect
5ec025b
@JelleZijlstra
unused imports
288fad9
@JelleZijlstra
fix test_annotationlib
2e376e0
@JelleZijlstra
Fix tests
2a1c9a9
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into pep649-inspect
f60f435
@JelleZijlstra
Reapply python#120272
1f3a63c
@JelleZijlstra
pythongh-119180: Yet another approach for fixing metaclass annotations
c87cccd
See python/peps#3847 (comment)
@bedevere-app bedevere-app Bot mentioned this pull request Jul 21, 2024
Implement PEP 649 and PEP 749 #119180
Closed
21 of 30 tasks
This was referenced Jul 23, 2024
gh-119180: Fix annotations lookup on classes with custom metaclasses #120719
Closed
gh-119180: Alternative approach to metaclass annotations: never use the dict #120816
Closed
JelleZijlstra added 4 commits July 23, 2024 14:22
@JelleZijlstra
Merge branch 'main' into pep649-basedescriptor
4a6f0b8
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into pep649-basedescriptor
0cae78f
@JelleZijlstra
news
3eb222c
@JelleZijlstra
add a test
cb34d89
@JelleZijlstra
JelleZijlstra marked this pull request as ready for review July 24, 2024 00:18
@bedevere-app bedevere-app Bot added the awaiting core review label Jul 24, 2024
@JelleZijlstra
JelleZijlstra requested review from AlexWaygood and carljm July 24, 2024 00:18
carljm
carljm approved these changes Jul 26, 2024
View reviewed changes

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

Looks great!

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/annotationlib.py
Returns the __annotate__ function or None.
"""
if isinstance(obj, type):
return _BASE_GET_ANNOTATE(obj)

@carljm carljm Jul 26, 2024

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.

It may be worth explaining, in a comment or docstring (here or somewhere) why we have to go to these odd lengths.

Sorry, something went wrong.

Uh oh!

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

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

@JelleZijlstra JelleZijlstra Jul 26, 2024

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.

Good point, will do that. Thanks for reviewing!

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Jul 26, 2024
@JelleZijlstra
Add comment explaining why we get the type descriptors
0c8bf2e
@JelleZijlstra
JelleZijlstra enabled auto-merge (squash) July 27, 2024 16:13
@JelleZijlstra
JelleZijlstra merged commit 45614ec into python:main Jul 27, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Jul 27, 2024
@JelleZijlstra
JelleZijlstra deleted the pep649-basedescriptor branch July 27, 2024 16:58
JelleZijlstra added a commit to JelleZijlstra/typing_extensions that referenced this pull request Jul 27, 2024
@JelleZijlstra
Add tests for metaclasses and typing_extensions.get_annotations
6a08abe
Tests from python/cpython#122074. We don't have to use the base descriptor
approach here because we find the annotations directly in the `__dict__`
for the class, which avoids metaclass problems.
@JelleZijlstra JelleZijlstra mentioned this pull request Jul 27, 2024
Add tests for metaclasses and typing_extensions.get_annotations python/typing_extensions#440
Merged
JelleZijlstra added a commit to python/typing_extensions that referenced this pull request Sep 23, 2024
@JelleZijlstra
Add tests for metaclasses and typing_extensions.get_annotations (#440)
b6c0558
Tests from python/cpython#122074. We don't have to use the base descriptor
approach here because we find the annotations directly in the `__dict__`
for the class, which avoids metaclass problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@carljm carljm carljm approved these changes
@AlexWaygood AlexWaygood Awaiting requested review from AlexWaygood

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.

2 participants

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