FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-109118: Allow lambdas in annotation scopes in classes by JelleZijlstra · Pull Request #118019 · python/cpython · GitHub

/ cpython Public

gh-109118: Allow lambdas in annotation scopes in classes - #118019

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
JelleZijlstra:lambdaanno
Apr 22, 2024
Merged

gh-109118: Allow lambdas in annotation scopes in classes#118019
JelleZijlstra merged 1 commit into
python:mainfrom
JelleZijlstra:lambdaanno

Conversation

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

Copy link
Copy Markdown
Member

carljm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 :/

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.

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.

JelleZijlstra merged commit 85f727c into python:main Apr 22, 2024
JelleZijlstra deleted the lambdaanno branch April 22, 2024 19:50

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.

Copy link
Copy Markdown
Member Author

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

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL