Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
myint committed Jul 17, 2019
1 parent d1aeb24 commit 20136e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Makefile
@@ -1,6 +1,10 @@
check:
pycodestyle docformatter.py setup.py
pydocstyle docformatter.py setup.py
pydocstyle \
--convention=pep257 \
--add-ignore=D413 \
docformatter.py \
setup.py
pylint \
--reports=no \
--disable=bad-continuation \
Expand All @@ -9,10 +13,12 @@ check:
--disable=invalid-name \
--disable=no-else-return \
--disable=no-member \
--disable=too-few-public-methods \
--disable=too-many-arguments \
--disable=too-many-boolean-expressions \
--disable=too-many-locals \
--disable=too-many-return-statements \
--disable=useless-object-inheritance \
--rcfile=/dev/null \
docformatter.py setup.py
check-manifest
Expand Down
19 changes: 12 additions & 7 deletions docformatter.py
Expand Up @@ -58,8 +58,9 @@
CRLF = '\r\n'


class FormatResult(object): # pylint: disable=too-few-public-methods, useless-object-inheritance
class FormatResult(object):
"""Possible exit codes."""

ok = 0
error = 1
interrupted = 2
Expand Down Expand Up @@ -387,6 +388,7 @@ def _find_shortest_indentation(lines):

return indentation or ''


def find_newline(source):
"""Return type of newline used in source.
Expand Down Expand Up @@ -421,8 +423,8 @@ def normalize_line_endings(lines, newline):
All lines will be modified to use the most common line ending.
"""
return "".join([normalize_line(line, newline) for line in lines])
return ''.join([normalize_line(line, newline) for line in lines])


def strip_docstring(docstring):
"""Return contents of docstring."""
Expand Down Expand Up @@ -596,9 +598,11 @@ def _main(argv, standard_out, standard_error, standard_in):
parser = argparse.ArgumentParser(description=__doc__, prog='docformatter')
changes = parser.add_mutually_exclusive_group()
changes.add_argument('-i', '--in-place', action='store_true',
help='make changes to files instead of printing diffs')
help='make changes to files instead of printing '
'diffs')
changes.add_argument('-c', '--check', action='store_true',
help='only check and report incorrectly formatted files')
help='only check and report incorrectly formatted '
'files')
parser.add_argument('-r', '--recursive', action='store_true',
help='drill down directories recursively')
parser.add_argument('--wrap-summaries', default=79, type=int,
Expand Down Expand Up @@ -687,7 +691,7 @@ def _get_encoding():
def find_py_files(sources, recursive):
"""Find Python source files.
Parameters:
Parameters
- sources: iterable with paths as strings.
- recursive: drill down directories if True.
Expand Down Expand Up @@ -716,7 +720,8 @@ def _format_files(args, standard_out, standard_error):
outcomes = collections.Counter()
for filename in find_py_files(set(args.files), args.recursive):
try:
result = format_file(filename, args=args, standard_out=standard_out)
result = format_file(filename, args=args,
standard_out=standard_out)
outcomes[result] += 1
if result == FormatResult.check_failed:
print(unicode(filename), file=standard_error)
Expand Down

0 comments on commit 20136e9

Please sign in to comment.