Split check and fmt tools

This commit is contained in:
Lonami Exo 2023-09-13 20:15:49 +02:00
parent 9e43700f55
commit 569ff3d372
2 changed files with 34 additions and 7 deletions

View File

@ -1,8 +1,11 @@
"""
Sort imports, format code, type-check and run offline tests.
Check formatting, type-check and run offline tests.
"""
import subprocess
import sys
import tempfile
BLACK_IGNORE = r"tl/(abcs|functions|types)/\w+.py"
def run(*args: str) -> int:
@ -10,12 +13,14 @@ def run(*args: str) -> int:
def main() -> None:
exit(
run("isort", ".", "--profile", "black", "--gitignore")
or run("black", ".", "--extend-exclude", r"tl/(abcs|functions|types)/\w+.py")
or run("mypy", "--strict", ".")
or run("pytest", ".", "-m", "not net")
)
with tempfile.TemporaryDirectory() as tmp_dir:
exit(
run("isort", ".", "-c", "--profile", "black", "--gitignore")
or run("black", ".", "--check", "--extend-exclude", BLACK_IGNORE)
or run("mypy", "--strict", ".")
or run("sphinx", "-nW", "client/doc", tmp_dir)
or run("pytest", ".", "-m", "not net")
)
if __name__ == "__main__":

22
tools/fmt.py Normal file
View File

@ -0,0 +1,22 @@
"""
Sort imports and format code.
"""
import subprocess
import sys
BLACK_IGNORE = r"tl/(abcs|functions|types)/\w+.py"
def run(*args: str) -> int:
return subprocess.run((sys.executable, "-m", *args)).returncode
def main() -> None:
exit(
run("isort", ".", "--profile", "black", "--gitignore")
or run("black", ".", "--extend-exclude", BLACK_IGNORE)
)
if __name__ == "__main__":
main()