Skip to content

Commit e02d552

Browse files
committed
Enforce code style checks
Resolve a few minor code style issues, for short variable, bare except, and long lines. Run `make check` in Python 3.5 Travis job to prevent unintentional regressions. Python 2 is not checked as Python 3 syntax is used, and PyPy has problems with rstcheck, and pylint doesnt support Python 3.6+.
1 parent 14bae49 commit e02d552

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎.travis.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ install:
1717
# Prevent Python 2.7 from using the non-3to2 converted code.
1818
- mv language_check .language_check
1919

20+
- pip install pycodestyle pylint rstcheck
21+
2022
script:
2123
- ./test.py
2224

@@ -29,3 +31,6 @@ script:
2931
- echo 'This is a sentence.' > foo.txt
3032
- language-check foo.txt
3133
- language-check --version
34+
35+
- mv .language_check language_check
36+
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.5" ]]; then make check; fi

‎Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
check:
22
pycodestyle \
3+
--exclude ./language_check/LanguageTool-* \
34
--ignore=E402 \
45
./language-check \
56
./language_check/ \
@@ -21,6 +22,7 @@ check:
2122
--disable=similarities \
2223
--disable=too-few-public-methods \
2324
--disable=too-many-branches \
25+
--disable=too-many-instance-attributes \
2426
--disable=too-many-locals \
2527
--disable=too-many-statements \
2628
--disable=wrong-import-order \

‎language_check/main.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def main():
106106

107107
remote_server = None
108108
if args.remote_host is not None and args.remote_port is not None:
109-
remote_server = {'host': args.remote_host, 'port': args.remote_port}
109+
remote_server = {'host': args.remote_host,
110+
'port': args.remote_port}
110111
lang_tool = LanguageTool(
111112
motherTongue=args.mother_tongue,
112113
remote_server=remote_server,

‎setup.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ def split_multiline(value):
192192

193193
def split_elements(value):
194194
"""Split a string with comma or space-separated elements into a list."""
195-
l = [v.strip() for v in value.split(',')]
196-
if len(l) == 1:
197-
l = value.split()
198-
return l
195+
items = [v.strip() for v in value.split(',')]
196+
if len(items) == 1:
197+
items = value.split()
198+
return items
199199

200200

201201
def eval_environ(value):
@@ -541,7 +541,7 @@ def copy_data(src, dst):
541541
try:
542542
run_3to2(copied_py_files)
543543
write_py2k_header(copied_py_files)
544-
except:
544+
except Exception:
545545
shutil.rmtree(py2k_dir)
546546
raise
547547

0 commit comments

Comments
 (0)