src-py-lib
Reusable libraries for Sourcegraph projects
Experimental - This is not a supported Sourcegraph product
This repo was created for Sourcegraph Implementation Engineering deployments, and is not intended, designed, built, or supported for use in any other scenario. Feel free to open issues or PRs, but responses are best effort.
Semantic Versioning
- Release versions are
major.minor.patch - Because this project is still major version 0:
- Minor version updates are breaking changes
- Patch version updates are not breaking changes
Install
From PyPI:
uv add src-py-lib
From this repository:
uv add git+https://github.com/sourcegraph/src-py-lib.git
Use it for
- Typed config models loaded from defaults,
.env, environment variables, and CLI flags - Root logger setup with terminal output, optional JSONL events, timing, and run metadata
- A shared
httpxJSON client with timeouts, retries,Retry-After, and contextual errors - Small helpers for TSV output, JSON caches, GraphQL pagination, and batched GraphQL queries
- Thin clients for Sourcegraph, Linear, Slack, GitHub, Google Sheets, and 1Password
Prefer vendor SDKs when they handle complex auth, token refresh, quota behavior, pagination, retries, or request models better than a thin wrapper
Quick example
Define a project config, parse it once, and configure logging at startup:
from pathlib import Path
import src_py_lib as src
class LinearExportConfig(src.LinearClientConfig):
output_dir: Path = src.config_field(
default=Path("."),
env_var="LINEAR_EXPORT_OUTPUT_DIR",
cli_flag="--output-dir",
metavar="PATH",
help="Directory for generated files.",
)
config = src.parse_args(LinearExportConfig, description="Export Linear data")
with src.logging(config):
client = src.linear_client_from_config(config)
client.validate()
src.info("Starting export", output_dir=str(config.output_dir))
- Config precedence is code defaults,
.env, shell environment, then CLI overrides parse_argsresolvesop://...references by default- Mark sensitive fields with
secret=Trueso config snapshots redact resolved values src.logging()configures the root logger by default so project code andsrc_py_libinternals share the same handlers- Use
event()for timed work,stage()for workflow context, andinfo()/warning()/error()for structured one-off events
Development
uv sync
uv run ruff format .
uv run ruff check .
uv run pyright
uv run python -m unittest discover -s tests
npx --yes markdownlint-cli2
Metadata
Release files for src-py-lib 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| src_py_lib-0.3.3.tar.gz | 102.0 kB | With provenance | Details for src_py_lib-0.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| src_py_lib-0.3.3-py3-none-any.whl | Python 3 | none | any | Details for src_py_lib-0.3.3-py3-none-any.whl |
Total release size: 156.4 kB
Release files / src_py_lib-0.3.3.tar.gz
| Download URL | src_py_lib-0.3.3.tar.gz |
|---|---|
| Size | 102.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4bd923907543a66e05d748cacb5ed8a46fb0a0a120bce816a2a01e67f0bd5f63
|
|
BLAKE2b-256 checksum How to use checksums |
c7cf7319326af9b7f25f88e0a16726dc5d295e8add2de0c19bedf2a51413ee20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / src_py_lib-0.3.3-py3-none-any.whl
| Download URL | src_py_lib-0.3.3-py3-none-any.whl |
|---|---|
| Size | 54.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90db7591e85e94f052285d32fb494e2d30f12c9cdda008cae2ee84df4e25e679
|
|
BLAKE2b-256 checksum How to use checksums |
32f034b6f1c3edf5c2be3c274969170730a9dd9604321b6dbbcf729644b1a63d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logSecurity for src-py-lib 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for src_py_lib-0.3.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.