gh-125072: Add label for assignment expressions; update tracked section for assignment expression topic (#125074)

This commit is contained in:
Emily Morehouse 2024-10-07 16:51:14 -06:00 committed by GitHub
parent a7f0727ca5
commit 447a15190d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 29 deletions

View File

@ -1809,6 +1809,8 @@ returns a boolean value regardless of the type of its argument
single: named expression single: named expression
pair: assignment; expression pair: assignment; expression
.. _assignment-expressions:
Assignment expressions Assignment expressions
====================== ======================

View File

@ -353,8 +353,8 @@ class MiscNews(SphinxDirective):
# Support for building "topic help" for pydoc # Support for building "topic help" for pydoc
pydoc_topic_labels = [ pydoc_topic_labels = [
'assert', 'assignment', 'async', 'atom-identifiers', 'atom-literals', 'assert', 'assignment', 'assignment-expressions', 'async', 'atom-identifiers',
'attribute-access', 'attribute-references', 'augassign', 'await', 'atom-literals', 'attribute-access', 'attribute-references', 'augassign', 'await',
'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', 'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object',
'bltin-null-object', 'bltin-type-objects', 'booleans', 'bltin-null-object', 'bltin-type-objects', 'booleans',
'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound', 'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound',

View File

@ -417,33 +417,43 @@ topics = {'assert': 'The "assert" statement\n'
'caused a\n' 'caused a\n'
'syntax error.\n', 'syntax error.\n',
'assignment-expressions': 'Assignment expressions\n' 'assignment-expressions': 'Assignment expressions\n'
'**********************\n' '**********************\n'
'\n' '\n'
'An assignment expression (sometimes also called a “named expression”' ' assignment_expression ::= [identifier ":="] '
'\nor “walrus”) assigns an expression to an identifier, while also\n' 'expression\n'
'returning the value of the expression.\n' '\n'
'\n' 'An assignment expression (sometimes also called a '
'One common use case is when handling matched regular expressions:\n' '“named expression”\n'
'\n' 'or “walrus”) assigns an "expression" to an '
' if matching := pattern.search(data):\n' '"identifier", while also\n'
' do_something(matching)\n' 'returning the value of the "expression".\n'
'\n' '\n'
'Or, when processing a file stream in chunks:\n' 'One common use case is when handling matched '
'\n' 'regular expressions:\n'
' while chunk := file.read(9000):\n' '\n'
' process(chunk)\n' ' if matching := pattern.search(data):\n'
'\n' ' do_something(matching)\n'
'Assignment expressions must be surrounded by parentheses when used as\n' '\n'
'expression statements and when used as sub-expressions in slicing,\n' 'Or, when processing a file stream in chunks:\n'
'conditional, lambda, keyword-argument, and comprehension-if\n' '\n'
'expressions and in assert, with, and assignment statements. In all\n' ' while chunk := file.read(9000):\n'
'other places where they can be used, parentheses are not required,\n' ' process(chunk)\n'
'including in if and while statements.\n' '\n'
'\n' 'Assignment expressions must be surrounded by '
'Added in version 3.8.\n' 'parentheses when used as\n'
'See also:\n' 'expression statements and when used as '
'\n' 'sub-expressions in slicing,\n'
' **PEP 572** - Assignment Expressions\n', 'conditional, lambda, keyword-argument, and '
'comprehension-if\n'
'expressions and in "assert", "with", and '
'"assignment" statements. In\n'
'all other places where they can be used, '
'parentheses are not required,\n'
'including in "if" and "while" statements.\n'
'\n'
'Added in version 3.8: See **PEP 572** for more '
'details about\n'
'assignment expressions.\n',
'async': 'Coroutines\n' 'async': 'Coroutines\n'
'**********\n' '**********\n'
'\n' '\n'