-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirstdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The minimal, reproducible example is to click on a link to view the ast
documentation.
Desired output
The example, if it were to include None
values, would read
ast.Module(
body=[
ast.AsyncFunctionDef(
name='f',
args=ast.arguments(
posonlyargs=[],
args=[],
vararg=None,
kwonlyargs=[],
kw_defaults=[],
kwarg=None,
defaults=[]),
body=[
ast.Expr(
value=ast.Await(
value=ast.Call(
func=ast.Name(id='other_func', ctx=ast.Load()),
args=[],
keywords=[])))],
decorator_list=[],
returns=None,
type_comment=None,
type_params=[])],
type_ignores=[])
Solution
Change
Lines 147 to 149 in 7291eab
if value is None and getattr(cls, name, ...) is None: | |
keywords = True | |
continue |
To
if value is None and getattr(cls, name, ...) is None:
if show_empty:
args.append('%s=%s' % (name, value))
keywords = True
continue
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Windows, Other
Linked PRs
- gh-134733: fix: ast.dump( show_empty=True ) now displays all
None
values #134743 - gh-134733: Fix documentation for the show_empty option of ast.dump() #134925
- [3.14] gh-134733: Fix documentation for the show_empty option of ast.dump() (GH-134925) #134940
- [3.13] gh-134733: Fix documentation for the show_empty option of ast.dump() (GH-134925) #134941
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirstdlibPython modules in the Lib dirPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error