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-109118: Allow lambdas in annotation scopes in classes by JelleZijlstra · Pull Request #118019 · python/cpython

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Apr 18, 2024 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: Annotation scopes containing nested scopes #109118

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

Sorry, something went wrong.

Uh oh!

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

All reactions
@JelleZijlstra
pythongh-109118: Allow lambdas in annotation scopes in classes
0da5933
@JelleZijlstra
JelleZijlstra requested review from carljm and larryhastings April 18, 2024 00:53
@bedevere-app bedevere-app Bot mentioned this pull request Apr 18, 2024
Annotation scopes containing nested scopes #109118
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Apr 18, 2024
carljm
carljm approved these changes Apr 22, 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 fine! I do think this will probably be the most intuitive behavior, though it's a little weird in principle for visibility to not be transitive. I guess it didn't turn out to be the case at all that this non-transitivity would require re-working abstractions in symtable.c!

I apologize in advance for the difficulties I assume you will encounter in making this work for comprehensions :/

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 Apr 22, 2024
@JelleZijlstra

JelleZijlstra commented Apr 22, 2024

Copy link
Copy Markdown
Member Author

Thanks! Yes, I tried locally to do the same thing for comprehensions and couldn't get it to work yet. The naive change (just remove the code that throws a SyntaxError for comprehensions in annotation scopes) no longer crashes like it did in #109118, but due to inlining it doesn't produce the right scoping semantics. I tried to do something like what we did last year in #104528 but couldn't get it to work yet. I haven't had time yet to get back to this.

All reactions

Sorry, something went wrong.

Uh oh!

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

@JelleZijlstra

JelleZijlstra commented Apr 22, 2024

Copy link
Copy Markdown
Member Author

One approach I thought of was to simply not inline comprehensions in annotation scopes, but that doesn't seem right as comprehensions would now behave differently in annotation scopes versus elsewhere.

All reactions

Sorry, something went wrong.

Uh oh!

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

@JelleZijlstra
JelleZijlstra merged commit 85f727c into python:main Apr 22, 2024
@JelleZijlstra
JelleZijlstra deleted the lambdaanno branch April 22, 2024 19:50
@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 22, 2024
@carljm

carljm commented Apr 22, 2024

Copy link
Copy Markdown
Member

If you want to (at some point when you get back to it, no rush) push a non-working version with inlined comprehensions in annotation scopes, I'm also willing to take a look and see what I can figure out.

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.

@JelleZijlstra

JelleZijlstra commented Apr 22, 2024

Copy link
Copy Markdown
Member Author

Thanks! I opened #118160 with what I have so far.

All reactions

Sorry, something went wrong.

Uh oh!

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

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
@larryhastings larryhastings Awaiting requested review from larryhastings

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.