Skip to main content

🎰 Slotscheck

https://img.shields.io/pypi/v/slotscheck.svg https://img.shields.io/pypi/l/slotscheck.svg https://img.shields.io/pypi/pyversions/slotscheck.svg https://img.shields.io/readthedocs/slotscheck.svg https://img.shields.io/badge/code%20style-black-000000.svg

Adding __slots__ to a class in Python is a great way to reduce memory usage. But to work properly, all base classes need to implement it. It turns out it’s easy to forget one class in complex inheritance trees. What’s worse: there is nothing warning you that you messed up.

✨ Until now! ✨

Quickstart

Usage is quick from the command line:

slotscheck [MODULE]

For example:

$ slotscheck pandas
ERROR: 'pandas.core.internals.array_manager.SingleArrayManager' has slots but inherits from non-slot class
ERROR: 'pandas.core.internals.blocks.Block' has slots but inherits from non-slot class
ERROR: 'pandas.core.internals.blocks.NumericBlock' has slots but inherits from non-slot class
ERROR: 'pandas.core.internals.blocks.DatetimeLikeBlock' has slots but inherits from non-slot class
ERROR: 'pandas.core.internals.blocks.ObjectBlock' has slots but inherits from non-slot class
ERROR: 'pandas.core.internals.blocks.CategoricalBlock' has slots but inherits from non-slot class
ERROR: 'pandas.core.internals.array_manager.BaseArrayManager' has slots but inherits from non-slot class
ERROR: 'pandas.core.internals.managers.BaseBlockManager' has slots but inherits from non-slot class
ERROR: 'pandas.core.internals.managers.SingleBlockManager' has slots but inherits from non-slot class

Now get to fixing – and add slotscheck to your CI pipeline to prevent mistakes from creeping in again!

Use the --help option to find out more.

Notes

  • slotscheck will try to import all submodules of the given package. If there are scripts without if __name__ == "__main__": blocks, they may be executed.

  • Even in the case that slots are not inherited properly, there may still an advantage to using them (i.e. attribute access speed and some memory savings)

  • Only classes at module-level are checked (i.e. no nested classes)

  • In rare cases imports may fail, the module is then skipped. Use the verbose mode to show detailed information.

  • Limited to the CPython implementation for now.

  • Non pure-Python classes are currently assumed to have slots. This is not necessarily the case, but it is nontrivial to determine.

Installation

It’s available on PyPI.

pip install slotscheck

Metadata

Release files for slotscheck 0.1.1

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

Source distribution (sdist)

Source distribution for slotscheck 0.1.1
File Size Uploaded Provenance Actions
slotscheck-0.1.1.tar.gz 4.9 kB Without provenance Details for slotscheck-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 11.0 kB

Release files / slotscheck-0.1.1.tar.gz

Download URL slotscheck-0.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
31b881d3fc95e945864fbbe393e43a43b2c148bc1732d28f89bbdcf68602cd2f
BLAKE2b-256 checksum
How to use checksums
20a6df8dc1e7400dd981ab14bd197b85a6f8797f38b6004289b9582ed8dd79e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.9.9 Darwin/21.2.0

Release files / slotscheck-0.1.1-py3-none-any.whl

Download URL slotscheck-0.1.1-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5eb916075d05d8ae5ce0d6d2e916bf2d39b06b24830058cea45bbc94c8cbd260
BLAKE2b-256 checksum
How to use checksums
00781a94ea09b737a73efb7e76c05a975978c796d0c5ebcb7f2ea2fb12acc319
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.9.9 Darwin/21.2.0

Security for slotscheck 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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