forked from electricitymaps/electricitymaps-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.py
29 lines (23 loc) · 777 Bytes
/
scripts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Poetry scripts, runable using 'poetry run'.
"""
import subprocess
import sys
def _run(cmd: str):
cmd_with_args = f"{cmd} {' '.join(sys.argv[1:])}"
print(f"⚙︎ {cmd_with_args}")
r = subprocess.run(cmd_with_args, shell=True).returncode
if r != 0:
print(f"FAILED: {cmd}")
sys.exit(r)
def lint():
_run(
"flake8 electricitymap tests parsers --count --select=E901,E999,F821,F822,F823 --show-source --statistics"
)
for path in ["tests", "electricitymap", "*.py"]:
_run(
f"pylint -E {path} -d unsubscriptable-object,unsupported-assignment-operation,unpacking-non-sequence"
)
def test():
_run("python -u -m unittest discover tests")
_run("python -u -m unittest discover parsers/test")