skillfed

slotscheck

Ensure your __slots__ are working properly.

slotscheck v0.20.1 160.5K downloads/30d#10,659 on PyPI127
Permissive license MIT Active released

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 slotscheck

uv

uv add slotscheck

poetry

poetry add slotscheck

Installing 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

Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Quality AssuranceTyping :: Typed

Tags

slots validation pythoncheck slots inheritancedetect overlapping slotsslots linterclass slots verification
performance-optimizationclass-validationcpython-specific

More Quality Assurance packages