Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment after __all__ causes pydocstyle to freeze #366

Closed
ig248 opened this issue Jun 5, 2019 · 2 comments · Fixed by #391
Closed

Comment after __all__ causes pydocstyle to freeze #366

ig248 opened this issue Jun 5, 2019 · 2 comments · Fixed by #391

Comments

@ig248
Copy link

@ig248 ig248 commented Jun 5, 2019

Including a comment at the end of a __all__ = ... line causes pydocstyle to freeze.

Steps to reproduce

pip install --upgrade pydocstyle
mkdir tmp/
cd tmp/
echo "__all__ = [] #" > test.py
pydocstyle . -esdv

Output

$ pydocstyle . -esdv
starting in debug mode.
No config file specified, discovering.
No config file specified, discovering.
No config file specified, discovering.
No config file specified, discovering.
No config file specified, discovering.
No config file specified, discovering.
Checking file ./test.py.
parsing module.
parsing docstring, token is tk.NAME (__all__)
parsing definition list, current token is tk.NAME (__all__)
got_newline: True

Environment

  • Ubuntu 18.04
  • python 3.6.4
  • pydocstyle 3.0.0
@Hanaasagi

This comment has been minimized.

Copy link
Contributor

@Hanaasagi Hanaasagi commented Jun 19, 2019

Confirmed and briefly checked 3.0.0 tag code. It fall into a infinite loop.

while not self.current.kind in self.stream.LOGICAL_NEWLINES:
if self.current.kind != tk.COMMENT:
self.dunder_all = None
self.dunder_all_error = 'Could not evaluate contents of __all__. '
return

self.current is a Comment Token.

And the master branch has the same issue, I think it should consume token here

diff --git a/src/pydocstyle/parser.py b/src/pydocstyle/parser.py
index e8f5c7c..473beba 100644
--- a/src/pydocstyle/parser.py
+++ b/src/pydocstyle/parser.py
@@ -487,6 +487,7 @@ class Parser:
                 self.dunder_all = None
                 self.dunder_all_error = 'Could not evaluate contents of __all__. '
                 return
+            self.stream.move()

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

This comment has been minimized.

Copy link
Contributor

@Hanaasagi Hanaasagi commented Aug 1, 2019

I will work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.