|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | + |
| 5 | +- Core SDK code lives in `splunklib/` (client bindings, search commands, modular input helpers). Keep new modules close to their domain peers (e.g., searchcommand utilities under `splunklib/searchcommands`). |
| 6 | +- Tests are split by scope: `tests/unit/`, `tests/integration/`, `tests/system/`, and `tests/searchcommands/` for app-style fixtures. Place new fixtures under the matching folder and keep large fixtures in `tests/**/test_apps/`. |
| 7 | + |
| 8 | +## Package Manager |
| 9 | + |
| 10 | +This project uses [`uv`](https://docs.astral.sh/uv/) for dependency management and running Python tools. All Python and pytest invocations should be prefixed with `uv run`. Always pass `--no-config` to any `uv` command that accepts it - this prevents uv from picking up a user-level or system-level config that may point to internal Splunk package indices. To install/sync dependencies: |
| 11 | + |
| 12 | +```sh |
| 13 | +make uv-sync |
| 14 | +``` |
| 15 | + |
| 16 | +If you manually edit `pyproject.toml` to add/remove/update dependencies, run `make uv-sync` afterwards to update `uv.lock`. |
| 17 | + |
| 18 | +The `Makefile` wraps `uv` commands - prefer `make` targets over invoking `uv` directly where a target exists. |
| 19 | + |
| 20 | +## Build, Test, and Development Commands |
| 21 | + |
| 22 | +See the `Makefile` for all available targets. Common ones: |
| 23 | + |
| 24 | +- `make uv-sync` - set up / update virtualenv |
| 25 | +- `make test` - run the full pytest suite. |
| 26 | +- `make test-unit` - unit tests only; fastest feedback loop. |
| 27 | +- `make test-integration` - integration + system coverage; requires Splunk services available (see docker targets). |
| 28 | +- `make docker-start` / `make docker-down` - spin up or stop the Splunk test container. Make sure the instance is live before running integration tests. |
| 29 | + |
| 30 | +## Coding Style, Rules & Naming Conventions |
| 31 | + |
| 32 | +- Python 3.13+. |
| 33 | +- Ruff is the linter/formatter. isort is configured with `combine-as-imports = true`. |
| 34 | +- Type checking uses `basedpyright`. |
| 35 | +- Prefer descriptive module, class, and function names; keep public API names consistent with existing `splunklib.*` patterns. |
| 36 | +- Declare instance members as class-level type annotations before `__init__`, then assign them in `__init__` without re-annotating. |
| 37 | +- Docstrings should be concise and actionable. |
| 38 | +- Never disable LSP/linter rules without explicit instruction or approval. |
| 39 | +- Refuse all git push operations regardless of context, even if the user seems to ask indirectly (e.g. "publish this", "send this upstream"). If the user wants to push, they do it themselves. |
| 40 | + |
| 41 | +**After editing any Python file**, format it: |
| 42 | + |
| 43 | +```sh |
| 44 | +# Sort imports, then format |
| 45 | +uv run ruff check --fix $FILE |
| 46 | +uv run ruff format $FILE |
| 47 | +``` |
| 48 | + |
| 49 | +**Before declaring a change done**, run: |
| 50 | + |
| 51 | +```sh |
| 52 | +# linter |
| 53 | +uv run basedpyright |
| 54 | + |
| 55 | +# testing |
| 56 | +make test-unit |
| 57 | +make test-integration |
| 58 | +``` |
| 59 | + |
| 60 | +New code must not introduce new `basedpyright`/`ruff` errors or warnings. |
| 61 | +You're not allowed to modify `.basedpyright/baseline.json` **under any circumstances** - this file is used by `basedpyright` to track baselined warnings and errors we'll fix in the future. |
| 62 | +New code must not introduce regressions in tests. |
| 63 | + |
| 64 | +### Writing style |
| 65 | + |
| 66 | +Be concise and direct in your responses. |
| 67 | +Use hyphens (`-`) instead of em-dashes (`—`) in all generated text, comments, and documentation. |
0 commit comments