Skip to content

Commit

Permalink
Fix an infinite loop when handling # fmt: on/off.
Browse files Browse the repository at this point in the history
  • Loading branch information
yilei committed Jul 6, 2022
1 parent 7af77d1 commit b420d19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/black/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def generate_ignored_nodes(
if contains_fmt_on_at_column(child, leaf.column, preview=preview):
return
yield child
return
else:
yield container
container = container.next_sibling
Expand Down
11 changes: 11 additions & 0 deletions tests/data/simple_cases/fmtonoff5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Regression test for https://github.com/psf/black/issues/3129.
setup(
entry_points={
# fmt: off
"console_scripts": [
"foo-bar"
"=foo.bar.:main",
# fmt: on
]
},
)

0 comments on commit b420d19

Please sign in to comment.