Skip to content

Commit 49183a3

Browse files
committed
Fix parser hanging when there's a comment directly after __all__.
2 parents 0a2f3ef + 1ab2463 commit 49183a3

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

docs/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Bug Fixes
1111

1212
* D401: Fixed a false positive where one stem had multiple imperative forms,
1313
e.g., init and initialize / initiate (#382).
14+
* Fix parser hanging when there's a comment directly after ``__all__``
15+
(#391, #366).
1416

1517
4.0.0 - July 6th, 2019
1618
---------------------------

src/pydocstyle/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ def parse_dunder_all(self):
487487
self.dunder_all = None
488488
self.dunder_all_error = 'Could not evaluate contents of __all__. '
489489
return
490+
self.stream.move()
490491

491492
def parse_module(self):
492493
"""Parse a module (and its children) and return a Module object."""

src/tests/parser_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,9 @@ def nested_3(self):
551551
__all__ = 'foo', 'bar'
552552
foo = 1
553553
"""),
554+
CodeSnippet("""\
555+
__all__ = ['foo', 'bar'] # never freeze
556+
"""),
554557
))
555558
def test_dunder_all(code):
556559
"""Test that __all__ is parsed correctly."""

0 commit comments

Comments
 (0)