Instruction file imported from enorm-labs/event-junkie (
.github/instructions/python.instructions.md). Copyright stays with the author.
Python
The scripts under scripts/, deploy/alerts/ and deploy/dashboards/, and nothing else. Not a Python project: no pyproject.toml, no venv, no test
runner. scripts/README.md § The short version carries the decisions; this is what they mean when you edit a .py file.
- Standard library only, with
argparse.ste_lint.pyand everything underdeploy/are copied to a node and run under thepython3there, where nothing is installed.outline_text.pyis the one exception, and its wrapper builds the venv it needs. A CLI library (click, typer) is the same decision as a shell framework, andscripts/README.mdrecords both as decided against. ruff checkandruff format, from the rootruff.toml: line length 120,target-version = "py312"(thepython3on an Ubuntu 24.04 node), rulesE,F,W,B,I. The pin isRUFF_VERSIONinvalidate-python.yml; the commit hook uses theruffon$PATH(brew install ruff), the way ShellCheck does. Without one,uvx ruff@<RUFF_VERSION>runs the pinned release. Not selected on purpose:UP031, because%-formatting is deliberate in code that runs under whateverpython3a node has, andPLW1510, because everysubprocess.runhere reads its ownreturncode.- Tests are plain scripts, not pytest.
deploy/alerts/test_diff_alerts.pyanddeploy/dashboards/test_lint_dashboard.pycount checks and exit non-zero;validate-python.ymlruns both. Two files do not justify a runner. A third test follows the same shape, and goes into that workflow. - Importing a sibling from a test:
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)), then the import with# noqa: E402. The files are run, not imported, so there is no package to make and no__init__.py. --helpbefore anything else. Every script underscripts/answers-hor--helpwith exit 0 before it touches a tool, a file or the network, andscripts/index-parity.shasserts it.argparsegives that for free as long as nothing runs at import time.