Unverified Commit a8977386 authored by Yifan Xiong's avatar Yifan Xiong Committed by GitHub
Browse files

Setup: Revision - Update lint rules (#7)

Update some lint rules, including:
* change max line length from 79 to 120, following [pytorch]
* add dedent_closing_brackets in yapf
* remove typed def requirements in mypy

Fix return code bug in setup.py, when lint/test command return 1,
`os.system` will return 256 and `sys.exit(256)` will get return code 0.

[pytorch]: https://github.com/pytorch/pytorch/blob/d1dcd5f/.flake8#L3
parent 8ae01380
......@@ -9,7 +9,7 @@ trim_trailing_whitespace = true
insert_final_newline = true
[*.py]
max_line_length = 79
max_line_length = 120
[*.yaml]
indent_size = 2
......
[flake8]
max-complexity = 10
max-line-length = 120
# flake8-docstrings extension
inline-quotes = single
multiline-quotes = double
docstring-quotes = double
docstring-convention = google
max-complexity = 10
[mypy]
ignore_missing_imports = True
scripts_are_modules = True
[superbench]
warn_return_any = True
disallow_untyped_defs = True
[style]
based_on_style = pep8
column_limit = 120
spaces_before_comment = 4
blank_line_before_module_docstring = True
dedent_closing_brackets = True
......@@ -41,9 +41,8 @@ def finalize_options(self):
def run(self):
"""Fromat the code using yapf."""
errno = os.system(
'python3 -m yapf --in-place --recursive --exclude .git .')
sys.exit(errno)
errno = os.system('python3 -m yapf --in-place --recursive --exclude .git .')
sys.exit(0 if errno == 0 else 1)
class Linter(Command):
......@@ -67,12 +66,16 @@ def finalize_options(self):
def run(self):
"""Lint the code with yapf, mypy, and flake8."""
errno = os.system(' && '.join([
'python3 -m yapf --diff --recursive --exclude .git .',
'python3 -m mypy .',
'python3 -m flake8',
]))
sys.exit(errno)
errno = os.system(
' && '.join(
[
'python3 -m yapf --diff --recursive --exclude .git .',
'python3 -m mypy .',
'python3 -m flake8',
]
)
)
sys.exit(0 if errno == 0 else 1)
class Tester(Command):
......@@ -97,7 +100,7 @@ def finalize_options(self):
def run(self):
"""Run pytest."""
errno = os.system('python3 -m pytest -v')
sys.exit(errno)
sys.exit(0 if errno == 0 else 1)
setup(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment