Skip to main content

stolid

A flake8 plugin that enforces opinionated Python coding conventions for clean, maintainable code.

Stolid encourages:

  • Composition over inheritance

  • Dependency injection over mocking

  • Protocol-based typing over abstract base classes

  • Immutable dataclasses

  • Small, focused functions and classes

Installation

pip install stolid

Usage

Run stolid as a module to check your code:

python -m stolid your_package/

python -m stolid is the unified entry point. It runs the flake8 plugin (which emits every per-file SLDxxx code) and then the cross-file scanners that produce the SLD80x public-contract diagnostics, exiting with the worst of the two stages’ exit codes. Paths default to . if none are given.

Running flake8 directly still works and is fine for editor integration, but it only loads the in-file plugin — the SLD80x cross-file checks require the workspace-wide view that python -m stolid provides:

flake8 your_code.py  # in-file SLDxxx only, no SLD80x

Error Codes

Every diagnostic is an SLDxxx code, grouped by leading digit so a whole family can be reasoned about — or silenced — together:

  • SLD1xx — testing and dynamic execution: no unittest.mock.patch, no exec / eval / __import__.

  • SLD2xx — abstract base classes and imports: prefer Protocol over ABC, keep every import at the top of the module (Temporal’s with workflow.unsafe.imports_passed_through(): block counts as part of that header), and keep any single module’s imported surface narrow.

  • SLD3xx — object-oriented design: boring constructors, no private methods, and real enums instead of stringly-typed values.

  • SLD4xx — inheritance: no subclassing of concrete classes.

  • SLD5xx — dataclass configuration: frozen, slots, and kw_only on every dataclass.

  • SLD6xx — code complexity: bounded function weight, argument and method counts, context-manager-friendly cleanup, and enumerate / iteration over manual range(len(...)) and while-index walks.

  • SLD7xx — naming: no vague words, no shadowing of stdlib names, no confusable near-duplicate names.

  • SLD8xx — cross-file contracts, documentation, and import-graph architecture: the checks that need a workspace-wide view and run via python -m stolid.

  • SLD9xx — privacy: the underscore-prefix convention across attributes, modules, and imports.

The full catalog — every code with its rationale and bad/good examples — lives in the documentation under doc/error-codes/ (one page per family).

Configuration

Stolid follows standard flake8 configuration. Add to your setup.cfg or .flake8:

[flake8]
extend-ignore = SLD301,SLD302

Or use per-file ignores:

[flake8]
per-file-ignores =
    tests/*:SLD301,SLD302

Development

pip install nox

# Run all checks
nox

# Run specific sessions
nox -s tests    # Run tests with coverage
nox -s lint     # Run black and flake8
nox -s mypy     # Run type checking

License

MIT License. See LICENSE for details.

Metadata

Release files for stolid 2026.10.26.59175

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stolid 2026.10.26.59175
File Size Uploaded Provenance Actions
stolid-2026.10.26.59175.tar.gz 97.5 kB With provenance Details for stolid-2026.10.26.59175.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stolid 2026.10.26.59175
File Interpreter ABI Platform Actions
stolid-2026.10.26.59175-py3-none-any.whl Python 3 none any Details for stolid-2026.10.26.59175-py3-none-any.whl

Total release size: 228.8 kB

Release files / stolid-2026.10.26.59175.tar.gz

Download URL stolid-2026.10.26.59175.tar.gz
Size 97.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f16bb3a0517a257227f07fba74694064dcf5c570af06d23dc1a22991671260dd
BLAKE2b-256 checksum
How to use checksums
e9e9b81fbcffb2a8988c852fe5b2d21cd53e366caa4f8cecfc1f32ad590f864c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Oct 26, 2026.

Transparency log

Release files / stolid-2026.10.26.59175-py3-none-any.whl

Download URL stolid-2026.10.26.59175-py3-none-any.whl
Size 131.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3633b55b9f33079a1890079ff48c370a59fb350fff22f65a74be140b9ae988a
BLAKE2b-256 checksum
How to use checksums
803ee7a1edb6554844a745ff821d386d3d2f9232d5c218a6dec18a92b1a95994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Oct 26, 2026.

Transparency log

Security for stolid 2026.10.26.59175

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.

Select from 2 files

Attestation for stolid-2026.10.26.59175.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 Oct 26, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page