slotscheck


Nameslotscheck JSON
Version 0.19.0 PyPI version JSON
download
home_pagehttps://github.com/ariebovenberg/slotscheck
SummaryEnsure your __slots__ are working properly.
upload_time2024-03-25 20:07:48
maintainerNone
docs_urlNone
authorArie Bovenberg
requires_python>=3.8.1
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            🎰 Slotscheck
=============

.. image:: https://img.shields.io/pypi/v/slotscheck.svg?color=blue
   :target: https://pypi.python.org/pypi/slotscheck

.. image:: https://img.shields.io/pypi/l/slotscheck.svg
   :target: https://pypi.python.org/pypi/slotscheck

.. image:: https://img.shields.io/pypi/pyversions/slotscheck.svg
   :target: https://pypi.python.org/pypi/slotscheck

.. image:: https://img.shields.io/readthedocs/slotscheck.svg
   :target: http://slotscheck.readthedocs.io/

.. image:: https://github.com/ariebovenberg/slotscheck/actions/workflows/build.yml/badge.svg
   :target: https://github.com/ariebovenberg/slotscheck/actions/workflows/build.yml

.. image:: https://img.shields.io/codecov/c/github/ariebovenberg/slotscheck.svg
   :target: https://codecov.io/gh/ariebovenberg/slotscheck

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
   :target: https://github.com/psf/black

Adding ``__slots__`` to a class in Python is a great way to improve performance.
But to work properly, all base classes need to implement it — without overlap!
It's easy to get wrong, and what's worse: there is nothing warning you that you messed up.

✨ *Until now!* ✨

``slotscheck`` helps you validate your slots are working properly.
You can even use it to enforce the use of slots across (parts of) your codebase.

See my `blog post <https://dev.arie.bovenberg.net/blog/finding-broken-slots-in-popular-python-libraries/>`_
for the origin story behind ``slotscheck``.

Quickstart
----------

Usage is quick from the command line:

.. code-block:: bash

   python -m slotscheck [FILES]...
   # or
   slotscheck -m [MODULES]...

For example:

.. code-block:: bash

   $ slotscheck -m sanic
   ERROR: 'sanic.app:Sanic' defines overlapping slots.
   ERROR: 'sanic.response:HTTPResponse' has slots but superclass does not.
   Oh no, found some problems!
   Scanned 72 module(s), 111 class(es).

Now get to fixing —
and add ``slotscheck`` to your CI pipeline or
`pre-commit <https://slotscheck.rtfd.io/en/latest/advanced.html#pre-commit-hook>`_
to prevent mistakes from creeping in again!
See `here <https://github.com/Instagram/LibCST/pull/615>`__ and
`here <https://github.com/dry-python/returns/pull/1233>`__ for examples.

Features
--------

- Detect broken slots inheritance
- Detect overlapping slots
- Detect duplicate slots
- `Pre-commit <https://slotscheck.rtfd.io/en/latest/advanced.html#pre-commit-hook>`_ hook
- (Optionally) enforce the use of slots

See `the documentation <https://slotscheck.rtfd.io>`_ for more details
and configuration options.

Why not a flake8 plugin?
------------------------

Flake8 plugins need to work without running the code.
Many libraries use conditional imports, star imports, re-exports,
and define slots with decorators or metaclasses.
This all but requires running the code to determine the slots and class tree.

There's `an issue <https://github.com/ariebovenberg/slotscheck/issues/6>`_
to discuss the matter.

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 be an advantage to using them
  (i.e. attribute access speed and *some* memory savings).
  However, in most cases this is unintentional.
  ``slotscheck`` allows you to ignore specific cases.

Installation
------------

It's available on PyPI.

.. code-block:: bash

  pip install slotscheck


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ariebovenberg/slotscheck",
    "name": "slotscheck",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8.1",
    "maintainer_email": null,
    "keywords": null,
    "author": "Arie Bovenberg",
    "author_email": "a.c.bovenberg@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/76/04/d5da2317874339ed2909a5e9fc2dd6d52661049c5901f18f4684cd17ff1c/slotscheck-0.19.0.tar.gz",
    "platform": null,
    "description": "\ud83c\udfb0 Slotscheck\n=============\n\n.. image:: https://img.shields.io/pypi/v/slotscheck.svg?color=blue\n   :target: https://pypi.python.org/pypi/slotscheck\n\n.. image:: https://img.shields.io/pypi/l/slotscheck.svg\n   :target: https://pypi.python.org/pypi/slotscheck\n\n.. image:: https://img.shields.io/pypi/pyversions/slotscheck.svg\n   :target: https://pypi.python.org/pypi/slotscheck\n\n.. image:: https://img.shields.io/readthedocs/slotscheck.svg\n   :target: http://slotscheck.readthedocs.io/\n\n.. image:: https://github.com/ariebovenberg/slotscheck/actions/workflows/build.yml/badge.svg\n   :target: https://github.com/ariebovenberg/slotscheck/actions/workflows/build.yml\n\n.. image:: https://img.shields.io/codecov/c/github/ariebovenberg/slotscheck.svg\n   :target: https://codecov.io/gh/ariebovenberg/slotscheck\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n   :target: https://github.com/psf/black\n\nAdding ``__slots__`` to a class in Python is a great way to improve performance.\nBut to work properly, all base classes need to implement it \u2014 without overlap!\nIt's easy to get wrong, and what's worse: there is nothing warning you that you messed up.\n\n\u2728 *Until now!* \u2728\n\n``slotscheck`` helps you validate your slots are working properly.\nYou can even use it to enforce the use of slots across (parts of) your codebase.\n\nSee my `blog post <https://dev.arie.bovenberg.net/blog/finding-broken-slots-in-popular-python-libraries/>`_\nfor the origin story behind ``slotscheck``.\n\nQuickstart\n----------\n\nUsage is quick from the command line:\n\n.. code-block:: bash\n\n   python -m slotscheck [FILES]...\n   # or\n   slotscheck -m [MODULES]...\n\nFor example:\n\n.. code-block:: bash\n\n   $ slotscheck -m sanic\n   ERROR: 'sanic.app:Sanic' defines overlapping slots.\n   ERROR: 'sanic.response:HTTPResponse' has slots but superclass does not.\n   Oh no, found some problems!\n   Scanned 72 module(s), 111 class(es).\n\nNow get to fixing \u2014\nand add ``slotscheck`` to your CI pipeline or\n`pre-commit <https://slotscheck.rtfd.io/en/latest/advanced.html#pre-commit-hook>`_\nto prevent mistakes from creeping in again!\nSee `here <https://github.com/Instagram/LibCST/pull/615>`__ and\n`here <https://github.com/dry-python/returns/pull/1233>`__ for examples.\n\nFeatures\n--------\n\n- Detect broken slots inheritance\n- Detect overlapping slots\n- Detect duplicate slots\n- `Pre-commit <https://slotscheck.rtfd.io/en/latest/advanced.html#pre-commit-hook>`_ hook\n- (Optionally) enforce the use of slots\n\nSee `the documentation <https://slotscheck.rtfd.io>`_ for more details\nand configuration options.\n\nWhy not a flake8 plugin?\n------------------------\n\nFlake8 plugins need to work without running the code.\nMany libraries use conditional imports, star imports, re-exports,\nand define slots with decorators or metaclasses.\nThis all but requires running the code to determine the slots and class tree.\n\nThere's `an issue <https://github.com/ariebovenberg/slotscheck/issues/6>`_\nto discuss the matter.\n\nNotes\n-----\n\n- ``slotscheck`` will try to import all submodules of the given package.\n  If there are scripts without ``if __name__ == \"__main__\":`` blocks,\n  they may be executed.\n- Even in the case that slots are not inherited properly,\n  there may still be an advantage to using them\n  (i.e. attribute access speed and *some* memory savings).\n  However, in most cases this is unintentional.\n  ``slotscheck`` allows you to ignore specific cases.\n\nInstallation\n------------\n\nIt's available on PyPI.\n\n.. code-block:: bash\n\n  pip install slotscheck\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Ensure your __slots__ are working properly.",
    "version": "0.19.0",
    "project_urls": {
        "Homepage": "https://github.com/ariebovenberg/slotscheck",
        "Repository": "https://github.com/ariebovenberg/slotscheck"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a90f27154ffdec82a8233eb12996f556d4ed4e62e91155c85d85cb27e3b2e2ba",
                "md5": "03a13db7a346787aa7ff0abfddd6cf5b",
                "sha256": "53fbc9befacb331a2ab25b385004d99ea72b5cee4f3deb6da676c8f08d0fcdd9"
            },
            "downloads": -1,
            "filename": "slotscheck-0.19.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "03a13db7a346787aa7ff0abfddd6cf5b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1",
            "size": 16749,
            "upload_time": "2024-03-25T20:07:46",
            "upload_time_iso_8601": "2024-03-25T20:07:46.670114Z",
            "url": "https://files.pythonhosted.org/packages/a9/0f/27154ffdec82a8233eb12996f556d4ed4e62e91155c85d85cb27e3b2e2ba/slotscheck-0.19.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7604d5da2317874339ed2909a5e9fc2dd6d52661049c5901f18f4684cd17ff1c",
                "md5": "8ac9bef919a7d0141a1d77a911a4ac36",
                "sha256": "707b4339d280664139ffd2c78fef99b3028e215f13cc77244147dd6126fe2e0d"
            },
            "downloads": -1,
            "filename": "slotscheck-0.19.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8ac9bef919a7d0141a1d77a911a4ac36",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1",
            "size": 15572,
            "upload_time": "2024-03-25T20:07:48",
            "upload_time_iso_8601": "2024-03-25T20:07:48.791015Z",
            "url": "https://files.pythonhosted.org/packages/76/04/d5da2317874339ed2909a5e9fc2dd6d52661049c5901f18f4684cd17ff1c/slotscheck-0.19.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-25 20:07:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ariebovenberg",
    "github_project": "slotscheck",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "slotscheck"
}
        
Elapsed time: 0.20216s