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

Commit 18959c0

Browse files
committed
Merge remote-tracking branch 'refs/remotes/PyCQA/master' into astroid
2 parents 37e5e88 + e1fd706 commit 18959c0

File tree

6 files changed

+43
-8
lines changed

6 files changed

+43
-8
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Links
5050
:target: https://readthedocs.org/projects/pydocstyle/?badge=latest
5151
:alt: Documentation Status
5252

53-
* `Read the full documentation here <http://pydocstyle.readthedocs.org>`_.
53+
* `Read the full documentation here <https://pydocstyle.readthedocs.io>`_.
5454

5555
* `Fork pydocstyle on GitHub <http://github.com/PyCQA/pydocstyle>`_.
5656

docs/release_notes.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ New Features
1313
the summary of a multi-line docstring starts at the first line,
1414
respectively at the second line (#174).
1515

16-
* Added D404 - First word of the docstring should not be `This`. It is turned
16+
* Added D404 - First word of the docstring should not be "This". It is turned
1717
off by default (#183).
1818

1919
Bug Fixes
2020

2121
* The error code D300 is now also being reported if a docstring has
2222
uppercase literals (``R`` or ``U``) as prefix (#176).
2323

24+
* Fixed a bug where an ``__all__`` error was reported when ``__all__`` was
25+
imported from another module with a different name (#182, #187).
26+
2427
1.0.0 - January 30th, 2016
2528
--------------------------
2629

src/pydocstyle.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import ast
1414
import copy
1515
import logging
16+
import textwrap
1617
import tokenize as tk
1718
from itertools import takewhile, dropwhile, chain
1819
from re import compile as re
@@ -487,13 +488,14 @@ def parse_definition(self, class_):
487488
return definition
488489

489490
def check_current(self, kind=None, value=None):
490-
msg = """Error at line {self.line}:
491+
msg = textwrap.dedent("""
492+
Unexpected token at line {self.line}:
491493
492494
In file: {self.filename}
493495
494496
Got kind {self.current.kind!r}
495497
Got value {self.current.value}
496-
""".format(self=self)
498+
""".format(self=self))
497499
kind_valid = self.current.kind == kind if kind else True
498500
value_valid = self.current.value == value if value else True
499501
assert kind_valid and value_valid, msg
@@ -505,6 +507,14 @@ def parse_from_import_statement(self):
505507
506508
"""
507509
log.debug('parsing from/import statement.')
510+
is_future_import = self._parse_from_import_source()
511+
self._parse_from_import_names(is_future_import)
512+
513+
def _parse_from_import_source(self):
514+
"""Parse the 'from x import' part in a 'from x import y' statement.
515+
516+
Return true iff `x` is __future__.
517+
"""
508518
assert self.current.value == 'from', self.current.value
509519
self.stream.move()
510520
is_future_import = self.current.value == '__future__'
@@ -515,6 +525,10 @@ def parse_from_import_statement(self):
515525
self.check_current(value='import')
516526
assert self.current.value == 'import', self.current.value
517527
self.stream.move()
528+
return is_future_import
529+
530+
def _parse_from_import_names(self, is_future_import):
531+
"""Parse the 'y' part in a 'from x import y' statement."""
518532
if self.current.value == '(':
519533
self.consume(tk.OP)
520534
expected_end_kind = tk.OP

src/tests/test_cases/all_import.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
"""A valid module docstring."""
22

3-
from .all_import_aux import __all__ as not_dunder_all
3+
from .all_import_aux import __all__
44
from .expected import Expectation
55

66
expectation = Expectation()
77
expect = expectation.expect
88

9-
__all__ = ('public_func', )
10-
119

1210
@expect("D103: Missing docstring in public function")
1311
def public_func():
1412
pass
1513

1614

17-
def private_func():
15+
@expect("D103: Missing docstring in public function")
16+
def this():
1817
pass

src/tests/test_cases/all_import_as.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""A valid module docstring."""
2+
3+
from .all_import_aux import __all__ as not_dunder_all
4+
from .expected import Expectation
5+
6+
expectation = Expectation()
7+
expect = expectation.expect
8+
9+
__all__ = ('public_func', )
10+
11+
12+
@expect("D103: Missing docstring in public function")
13+
def public_func():
14+
pass
15+
16+
17+
def private_func():
18+
pass

src/tests/test_definitions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def test_token_stream():
261261
'comment_after_def_bug',
262262
'multi_line_summary_start',
263263
'all_import',
264+
'all_import_as',
264265
])
265266
def test_pep257(test_case):
266267
"""Run domain-specific tests from test.py file."""

0 commit comments

Comments
 (0)