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:
Родитель
8ae0138004
Коммит
a897738699
|
@ -9,7 +9,7 @@ trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
[*.py]
|
[*.py]
|
||||||
max_line_length = 79
|
max_line_length = 120
|
||||||
|
|
||||||
[*.yaml]
|
[*.yaml]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
4
.flake8
4
.flake8
|
@ -1,6 +1,8 @@
|
||||||
[flake8]
|
[flake8]
|
||||||
|
max-complexity = 10
|
||||||
|
max-line-length = 120
|
||||||
|
# flake8-docstrings extension
|
||||||
inline-quotes = single
|
inline-quotes = single
|
||||||
multiline-quotes = double
|
multiline-quotes = double
|
||||||
docstring-quotes = double
|
docstring-quotes = double
|
||||||
docstring-convention = google
|
docstring-convention = google
|
||||||
max-complexity = 10
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
[mypy]
|
[mypy]
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
scripts_are_modules = True
|
scripts_are_modules = True
|
||||||
|
|
||||||
[superbench]
|
|
||||||
warn_return_any = True
|
warn_return_any = True
|
||||||
disallow_untyped_defs = True
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
[style]
|
[style]
|
||||||
based_on_style = pep8
|
based_on_style = pep8
|
||||||
|
column_limit = 120
|
||||||
spaces_before_comment = 4
|
spaces_before_comment = 4
|
||||||
blank_line_before_module_docstring = True
|
blank_line_before_module_docstring = True
|
||||||
|
dedent_closing_brackets = True
|
||||||
|
|
23
setup.py
23
setup.py
|
@ -41,9 +41,8 @@ class Formatter(Command):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Fromat the code using yapf."""
|
"""Fromat the code using yapf."""
|
||||||
errno = os.system(
|
errno = os.system('python3 -m yapf --in-place --recursive --exclude .git .')
|
||||||
'python3 -m yapf --in-place --recursive --exclude .git .')
|
sys.exit(0 if errno == 0 else 1)
|
||||||
sys.exit(errno)
|
|
||||||
|
|
||||||
|
|
||||||
class Linter(Command):
|
class Linter(Command):
|
||||||
|
@ -67,12 +66,16 @@ class Linter(Command):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Lint the code with yapf, mypy, and flake8."""
|
"""Lint the code with yapf, mypy, and flake8."""
|
||||||
errno = os.system(' && '.join([
|
errno = os.system(
|
||||||
'python3 -m yapf --diff --recursive --exclude .git .',
|
' && '.join(
|
||||||
'python3 -m mypy .',
|
[
|
||||||
'python3 -m flake8',
|
'python3 -m yapf --diff --recursive --exclude .git .',
|
||||||
]))
|
'python3 -m mypy .',
|
||||||
sys.exit(errno)
|
'python3 -m flake8',
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
sys.exit(0 if errno == 0 else 1)
|
||||||
|
|
||||||
|
|
||||||
class Tester(Command):
|
class Tester(Command):
|
||||||
|
@ -97,7 +100,7 @@ class Tester(Command):
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Run pytest."""
|
"""Run pytest."""
|
||||||
errno = os.system('python3 -m pytest -v')
|
errno = os.system('python3 -m pytest -v')
|
||||||
sys.exit(errno)
|
sys.exit(0 if errno == 0 else 1)
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче