Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-109118: Make comprehensions work within annotation scopes, but without inlining#118160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 7 commits intopython:mainfromJelleZijlstra:lambdaanno
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Rename "error_cases"
  • Loading branch information
@JelleZijlstra
JelleZijlstra committedApr 26, 2024
commit79e9332f87e5f4a051d03eb52e1dae795d9ae18d
4 changes: 3 additions & 1 deletionDoc/whatsnew/3.13.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -276,7 +276,9 @@ Other Language Changes
(Contributed by Pedro Sousa Lacerda in :gh:`66449`.)

* :ref:`annotation scope <annotation-scopes>` within class scopes can now
contain lambdas. (Contributed by Jelle Zijlstra in :gh:`109118`.)
contain lambdas and comprehensions. Comprehensions that are located within
class scopes are not inliked into their parent scope. (Contributed by
Jelle Zijlstra in :gh:`109118` and :gh:`118160`.)


New Modules
Expand Down
4 changes: 2 additions & 2 deletionsLib/test/test_type_params.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -491,13 +491,13 @@ class C:
T = "class"
{}
"""
error_cases = [
cases = [
"type Alias[T] = (T for _ in (1,))",
"type Alias = (T for _ in (1,))",
"type Alias[T] = [T for _ in (1,)]",
"type Alias = [T for _ in (1,)]",
]
for case inerror_cases:
for case incases:
with self.subTest(case=case):
ns = run_code(code.format(case))
alias = ns["C"].Alias
Expand Down
6 changes: 4 additions & 2 deletionsPython/symtable.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1154,10 +1154,12 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
}
}

// we inline all non-generator-expression comprehensions
// we inline all non-generator-expression comprehensions,
// except those in annotation scopes that are nested in classes
int inline_comp =
entry->ste_comprehension &&
!entry->ste_generator;
!entry->ste_generator &&
!ste->ste_can_see_class_scope;

if (!analyze_child_block(entry, newbound, newfree, newglobal,
type_params, new_class_entry, &child_free))
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp