slotscheck
Ensure your __slots__ are working properly.
What it is and what it does
Slotscheck is a runtime validator for Python's `__slots__` mechanism, which developers use to optimize class memory and attribute access. The tool runs your code, inspects the resulting class tree, and detects common slots mistakes that static analyzers miss: overlapping slots across inheritance hierarchies, slots defined in child classes when parents lack them, duplicate slot names, and unused slots. It works by actually importing and executing your modules, which lets it catch slots generated at import time by decorators, metaclasses, and frameworks like dataclasses, attrs, and pydantic—cases that static analysis cannot see.
You run it from the command line against files or modules, and it reports errors with class paths and problem types. It integrates into pre-commit hooks and CI pipelines to prevent slots mistakes from reaching production. The tool is CPython-specific because it relies on CPython internals to inspect the class tree; it will not work on alternative Python implementations.
Use it for:
- Validate slots inheritance in a large codebase before committing to catch mistakes early via pre-commit.
- Audit a third-party library (e.g., sanic) to find slots violations in its class hierarchy.
- Enforce slots usage across a team's code to ensure consistent performance optimization practices.
- Detect unused or duplicate slots in classes that auto-generate slots via decorators or metaclasses.
- Add to CI pipeline to prevent slots regressions as code evolves and class hierarchies change.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Validates that `__slots__` are correctly implemented across class hierarchies, detecting overlapping slots, inheritance errors, and duplicate slot definitions by running and inspecting your code.
Yes. Slotscheck fills a real gap: static analyzers cannot catch slots mistakes that arise from runtime code generation, conditional imports, or deep inheritance trees. If you use `__slots__` for performance, this tool prevents silent failures that are hard to debug. Low install friction, active maintenance, MIT license, and no known vulnerabilities make it a safe addition to your development workflow.
Install
slotscheck on PyPI
pip
pip install slotscheckuv
uv add slotscheckpoetry
poetry add slotscheckInstalling slotscheck
Before you install
Low install friction with a single lightweight runtime dependency (tomli). Active maintenance with recent releases and a stable repository.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions.
Quickstart
pip install slotscheck
python -m slotscheck [FILES]...
# or
slotscheck -m [MODULES]...
Requires CPython 3.10+; does not work on PyPy, Jython, or IronPython. Will import and potentially execute all submodules of target packages.
Verify before relying
- Whether slotscheck can be integrated into automated CI/CD pipelines beyond pre-commit hooks.
- Performance impact when scanning large codebases or packages with many modules.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — tomli |
| Maintenance | actively maintained — 40 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 160,502/month — #10,659 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: slotscheck-0.20.1-py3-none-any.whl
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
overridesProvides a @override decorator that validates…
permissive · top 1,000 on PyPI
docstring-inheritanceAutomatically inherits docstrings from parent…
permissive · top 15,000 on PyPI
pyflakesPyflakes checks Python source files for logical…
permissive · top 1,000 on PyPI
interegularInteregular checks whether pairs of Python…
permissive · top 5,000 on PyPI
classesImplements typeclasses for Python, enabling…
permissive · top 15,000 on PyPI
pylintPylint is a static code analyzer that checks…
copyleft · top 1,000 on PyPI
recordclassRecordclass provides memory-efficient, mutable…
permissive · top 15,000 on PyPI
intervaltreeA self-balancing interval tree data structure…
permissive · top 5,000 on PyPI
check-manifestValidates that a Python package's MANIFEST.in…
permissive · top 5,000 on PyPI
yesqayesqa automatically removes unnecessary `#…
permissive · top 15,000 on PyPI