{"id":10231,"library":"slotscheck","title":"Slotscheck","description":"Slotscheck is a Python library that helps ensure your `__slots__` are working properly. It acts as a linter, identifying classes where `__slots__` might not be effective or are misused, thereby aiding in memory optimization and performance. The current version is 0.19.1, and it has a regular release cadence, often aligning with new Python versions.","status":"active","version":"0.19.1","language":"en","source_language":"en","source_url":"https://github.com/ariebovenberg/slotscheck","tags":["slots","linting","performance","memory","optimization","dataclasses","typing"],"install":[{"cmd":"pip install slotscheck","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The main function to check slots is named 'slotscheck', just like the library itself.","symbol":"slotscheck","correct":"from slotscheck import slotscheck"}],"quickstart":{"code":"from slotscheck import slotscheck\n\nclass MySlottedClass:\n    __slots__ = ('x', 'y')\n\n    def __init__(self, x, y):\n        self.x = x\n        self.y = y\n\nclass MyUnslottedClass:\n    def __init__(self, x, y):\n        self.x = x\n        self.y = y\n\nresults_slotted = slotscheck(MySlottedClass)\nprint(f\"MySlottedClass check results: {results_slotted}\")\n\nresults_unslotted = slotscheck(MyUnslottedClass)\nprint(f\"MyUnslottedClass check results: {results_unslotted}\")\n\n# To check an entire module (e.g., the current file):\n# import sys\n# current_module = sys.modules[__name__]\n# module_results = slotscheck(current_module)\n# print(f\"Current module check results: {module_results}\")","lang":"python","description":"This quickstart demonstrates how to import and use the `slotscheck` function to verify `__slots__` implementation for individual classes. It shows examples of both a correctly slotted and an unslotted class, and how to get results from the checker. It can also be used to check entire modules."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer, or pin `slotscheck==0.18.0` in your project's dependencies.","message":"Python 3.8 support was dropped in `slotscheck` version `0.19.1`. If you are using Python 3.8, you must upgrade your Python interpreter or pin your `slotscheck` version.","severity":"breaking","affected_versions":">=0.19.1"},{"fix":"Upgrade your Python environment to 3.8 or newer, or pin `slotscheck < 0.17.0` in your project's dependencies.","message":"Python 3.7 support was dropped in `slotscheck` version `0.17.0`. Users on Python 3.7 will not be able to install or use newer versions.","severity":"breaking","affected_versions":">=0.17.0"},{"fix":"Upgrade to `slotscheck >= 0.17.1` to resolve the false positive for `Generic` classes.","message":"When using Python 3.12+, `Generic` classes could be incorrectly flagged as not having slots in `slotscheck` versions prior to `0.17.1`, leading to false positives.","severity":"gotcha","affected_versions":"0.17.0 (on Python 3.12+)"},{"fix":"Upgrade to `slotscheck >= 0.16.5` to correctly handle `TypedDict` instances.","message":"`TypedDict` imported from `typing_extensions` could be incorrectly flagged as not having slots in `slotscheck` versions prior to `0.16.5`, particularly in Python versions where `TypedDict` is already in the standard library.","severity":"gotcha","affected_versions":"<0.16.5"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Import the specific function directly: `from slotscheck import slotscheck`. Then call it: `slotscheck(MyClass)`. Alternatively, if you `import slotscheck`, you must call `slotscheck.slotscheck(MyClass)`.","cause":"You imported the entire `slotscheck` module (e.g., `import slotscheck`) and then tried to call the module itself as a function (e.g., `slotscheck(MyClass)`).","error":"TypeError: 'module' object is not callable"},{"fix":"Use the correct function name: `from slotscheck import slotscheck` followed by `slotscheck(MyClass)`.","cause":"You're attempting to call a function named `check_slots`, which does not exist in the `slotscheck` library. The primary function for checking is also named `slotscheck`.","error":"AttributeError: module 'slotscheck' has no attribute 'check_slots'"},{"fix":"Rename your local file if it's named `slotscheck.py` to avoid name collisions. Ensure you're importing from the installed library, not a local file.","cause":"This error often occurs if you have a local Python file named `slotscheck.py` in your project directory, which conflicts with the installed `slotscheck` package.","error":"ImportError: cannot import name 'slotscheck' from 'slotscheck' (possibly due to a circular import)"}]}