Closed
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
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