Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 1c88e4d

Browse files
committed
Hotfix for "yield X from Y" bug.
1 parent f9eb3c5 commit 1c88e4d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/pydocstyle/parser.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,12 @@ def _parse_from_import_source(self):
468468
self.stream.move()
469469
is_future_import = self.current.value == '__future__'
470470
self.stream.move()
471-
while (self.current.kind in (tk.DOT, tk.NAME, tk.OP) and
472-
self.current.value != 'import'):
471+
while (self.current is not None and
472+
self.current.kind in (tk.DOT, tk.NAME, tk.OP) and
473+
self.current.value != 'import'):
473474
self.stream.move()
475+
if self.current is None or self.current.value != 'import':
476+
return False
474477
self.check_current(value='import')
475478
assert self.current.value == 'import', self.current.value
476479
self.stream.move()
@@ -480,10 +483,10 @@ def _parse_from_import_names(self, is_future_import):
480483
"""Parse the 'y' part in a 'from x import y' statement."""
481484
if self.current.value == '(':
482485
self.consume(tk.OP)
483-
expected_end_kind = tk.OP
486+
expected_end_kinds = (tk.OP, )
484487
else:
485-
expected_end_kind = tk.NEWLINE
486-
while self.current.kind != expected_end_kind and not (
488+
expected_end_kinds = (tk.NEWLINE, tk.ENDMARKER)
489+
while self.current.kind not in expected_end_kinds and not (
487490
self.current.kind == tk.OP and self.current.value == ';'):
488491
if self.current.kind != tk.NAME:
489492
self.stream.move()
@@ -504,4 +507,3 @@ def _parse_from_import_names(self, is_future_import):
504507
self.consume(tk.OP)
505508
self.log.debug("parsing import, token is %r (%s)",
506509
self.current.kind, self.current.value)
507-

0 commit comments

Comments
 (0)