12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- from invoke import task
- @task
- def run(c, port=8080, host="127.0.0.1"):
- """Run a debug server locally"""
- c.run(
- f"poetry run python -m flask run -p {port} -h {host}",
- env={
- "FLASK_APP": "baba-yaga.py",
- "APP_PATH": f"http://{host}:{port}",
- },
- )
- @task
- def install(c):
- """Install the listed dependencies into a virtualenv"""
- c.run("poetry install")
- @task
- def fmt(c):
- """Automatically format the source code, committing it if it is safe to do so."""
- status = c.run("git status --porcelain", hide="stdout")
- is_clean = status.stdout.strip() == ""
- c.run("poetry run black $(find by *.py -name '*.py')")
- if is_clean:
- date = datetime.now().isoformat()
- c.run(f"git commit -a -m 'Automatic formatting commit: {date}'")
- else:
- print("Uncommitted change exist; skipping commit")
- @task
- def checkfmt(c):
- """Automatically format the source code, committing it if it is safe to do so."""
- return c.run(
- "poetry run black --check $(find lc scripts stubs tests *.py -name '*.py')"
- )
- @task
- def tc(c):
- """Typecheck with mypy"""
- c.run(
- "MYPYPATH=$(pwd)/stubs poetry run mypy --check-untyped-defs by/*.py"
- )
|