Skip to content

Commit c67ea98

Browse files
author
Yuki Kobayashi
committed
Add an example with non-empty tag
1 parent 83cf038 commit c67ea98

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Doc/library/ast.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,16 @@ Type annotations
17831783
value=Constant(value=1))],
17841784
type_ignores=[
17851785
TypeIgnore(lineno=1, tag='')])
1786+
>>> print(ast.dump(ast.parse('x: bool = 1 # type: ignore[assignment]', type_comments=True), indent=4))
1787+
Module(
1788+
body=[
1789+
AnnAssign(
1790+
target=Name(id='x', ctx=Store()),
1791+
annotation=Name(id='bool', ctx=Load()),
1792+
value=Constant(value=1),
1793+
simple=1)],
1794+
type_ignores=[
1795+
TypeIgnore(lineno=1, tag='[assignment]')])
17861796

17871797
.. versionadded:: 3.8
17881798

0 commit comments

Comments
 (0)