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
This commit is contained in:
Yifan Xiong 2021-02-01 14:12:02 +08:00 коммит произвёл GitHub
Родитель 8ae0138004
Коммит a897738699
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 19 добавлений и 15 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -1,6 +1,8 @@
[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

Просмотреть файл

@ -1,7 +1,4 @@
[mypy]
ignore_missing_imports = True
scripts_are_modules = True
[superbench]
warn_return_any = True
disallow_untyped_defs = True

Просмотреть файл

@ -1,4 +1,6 @@
[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 @@ class Formatter(Command):
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 @@ class Linter(Command):
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 @@ class Tester(Command):
def run(self):
"""Run pytest."""
errno = os.system('python3 -m pytest -v')
sys.exit(errno)
sys.exit(0 if errno == 0 else 1)
setup(