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

Commit e5bffda

Browse files
authored
Fix bug in PEP257 conformance test, and fix docstring violations. (#465)
Fixes #464.
1 parent 61584cb commit e5bffda

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

src/pydocstyle/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ def get_leading_words(line):
10041004
return result.group()
10051005

10061006
def is_def_arg_private(arg_name):
1007-
"""Returns a boolean indicating if the argument name is private."""
1007+
"""Return a boolean indicating if the argument name is private."""
10081008
return arg_name.startswith("_")
10091009

10101010
def get_function_args(function_string):

src/pydocstyle/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def main():
7171

7272

7373
def setup_stream_handlers(conf):
74-
"""Setup logging stream handlers according to the options."""
74+
"""Set up logging stream handlers according to the options."""
7575
class StdoutFilter(logging.Filter):
7676
def filter(self, record):
7777
return record.levelno in (logging.DEBUG, logging.INFO)

src/pydocstyle/parser.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515

1616
class ParseError(Exception):
17+
"""An error parsing contents of a Python file."""
18+
1719
def __str__(self):
1820
return "Cannot parse file."
1921

@@ -111,6 +113,10 @@ class Module(Definition):
111113

112114
@property
113115
def is_public(self):
116+
"""Return True iff the module is considered public.
117+
118+
This helps determine if it requires a docstring.
119+
"""
114120
return not self.name.startswith('_') or self.name.startswith('__')
115121

116122
def __str__(self):
@@ -183,6 +189,7 @@ def is_public(self):
183189

184190
@property
185191
def is_static(self):
192+
"""Return True iff the method is static."""
186193
for decorator in self.decorators:
187194
if decorator.name == "staticmethod":
188195
return True
@@ -221,6 +228,7 @@ class Docstring(str):
221228
the start and end of the token.
222229
223230
"""
231+
224232
def __new__(cls, v, start, end):
225233
return str.__new__(cls, v)
226234

@@ -372,9 +380,9 @@ def parse_docstring(self):
372380
return None
373381

374382
def parse_decorators(self):
375-
"""Called after first @ is found.
383+
"""Parse decorators into self._accumulated_decorators.
376384
377-
Parse decorators into self._accumulated_decorators.
385+
Called after first @ is found.
378386
Continue to do so until encountering the 'def' or 'class' start token.
379387
"""
380388
name = []

src/pydocstyle/wordlists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def load_wordlist(name: str) -> Iterator[str]:
3535
yield line
3636

3737

38-
#: A dict mapping stemmed verbs to the imperative form
3938
def make_imperative_verbs_dict(wordlist: Iterator[str]) -> Dict[str, Set[str]]:
39+
"""Create a dictionary mapping stemmed verbs to the imperative form."""
4040
imperative_verbs = {} # type: Dict[str, Set[str]]
4141
for word in wordlist:
4242
imperative_verbs.setdefault(stem(word), set()).add(word)

src/tests/test_integration.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,9 @@ def parse_errors(err):
150150
def test_pep257_conformance():
151151
"""Test that we conform to PEP 257."""
152152
base_dir = (pathlib.Path(__file__).parent / '..').resolve()
153-
src_dirs = (base_dir, base_dir / 'tests')
154-
src_files = []
155-
for src_dir in src_dirs:
156-
src_files.extend(str(path) for path in src_dir.glob('*.py'))
153+
excluded = base_dir / 'tests' / 'test_cases'
154+
src_files = (str(path) for path in base_dir.glob('**/*.py')
155+
if excluded not in path.parents)
157156

158157
ignored = {'D104', 'D105'}
159158
select = violations.conventions.pep257 - ignored

0 commit comments

Comments
 (0)