Slotscheck - Find mistakes in your slots definitions

Overview

🎰 Slotscheck

https://img.shields.io/pypi/v/slotscheck.svg?color=blue

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!

See my blog post for the longer story behind slotscheck.

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.

Could this be a flake8 plugin?

Maybe. But it'd be a lot of work.

The problem is that flake8 plugins need to work without running the code. Many libraries define conditional imports, star imports, re-exports or metaclasses which basically require running the code to find out the class tree.

There's an issue to track any progress on 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, I've found in most cases this is unintentional.
  • 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
Comments
  • Address misleading import behavior when given files

    Address misleading import behavior when given files

    I found it somewhat misleading when I ran slotscheck mymod/ and it instead tested the installed version of mymod. This is especially since the command line options seem to imply that the argument is a file unless the -m option is provided.

    I also tried this in an environment that doesn't have my module installed and it couldn't import it, which I also found surprising given that the module is there in the directory I ran slotscheck from.

    documentation enhancement 
    opened by asmeurer 10
  • strict-imports toggle doesn't seem to work when run by pre-commit

    strict-imports toggle doesn't seem to work when run by pre-commit

    Hi,

    I tried configuring no-strict-imports i pyproject.toml, but running the tool via pre-commit ignored this completely. I concluded it probably doesn't read the pyproject.toml file inside pre-commit, so I insterad tried doing this in my pre-commit config:

      - repo: https://github.com/ariebovenberg/slotscheck
        rev: v0.14.1
        hooks:
          - id: slotscheck
            exclude: "test_*"
            args: [--no-strict-imports]
    

    But the tool keeps complaining about imports. I think it simply doesn't pick the config.

    bug 
    opened by Goldziher 8
  • Add pre-commit config

    Add pre-commit config

    Hi there,

    Thanks for this useful library. I am integrating it in the starlite pipeline (https://github.com/starlite-api/starlite).

    Would be awesome if I could run this as part of pre-commit. For this you will need to add a pre-commit config to the library - its not hard and will increase exposure i think.

    best

    opened by Goldziher 6
  • typing.Protocol classes should probably be ignored

    typing.Protocol classes should probably be ignored

    Currently, slotscheck is marking classes that inherit from typing.Protocol as regular classes, and reports missing slots. However protocol classes are usually not used for actual inheritance, and defining __slots__ on them would mean a type-checker would be checking for presence of __slots__ when determining whether a type can be downcasted to given protocol class.

    Here's an example of this:

    from typing import Protocol, Callable, TypeVar, ParamSpec
    from functools import wraps
    
    P = ParamSpec("P")
    R = TypeVar("R")
    
    class DecoratorFunction(Protocol):
        def __call__(self, __x: Callable[P, R]) -> Callable[P, R]:
            ...
            
    def log_with_markers(x: int, y: int) -> DecoratorFunction:
        def inner(func: Callable[P, R]) -> Callable[P, R]:
    
            @wraps(func)
            def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
                print(f"Function called, markers: {x=}, {y=}")
                return func(*args, **kwargs)
    
            return wrapper
        return inner
    

    The DecoratorFunction class shouldn't be slotted, and slotscheck probably shouldn't enforce the presence of __slots__ there.

    opened by ItsDrike 4
  • exception raised

    exception raised

    Hi there,

    I'm running this library as a pre-commit hook. I introduced some changes, and do have an issue in my code I need to fix - but this causes slotscheck to go heywire:

    Traceback (most recent call last):
      File "/opt/homebrew/Cellar/[email protected]/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/pkgutil.py", line 495, in find_loader
        spec = importlib.util.find_spec(fullname)
      File "/opt/homebrew/Cellar/[email protected]/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/util.py", line 94, in find_spec
        parent = __import__(parent_name, fromlist=['__path__'])
      File "/Users/naamanhirschfeld/workspace/starlite/starlite/__init__.py", line 3, in <module>
        from .app import Starlite
      File "/Users/naamanhirschfeld/workspace/starlite/starlite/app.py", line 19, in <module>
        from starlite.asgi import StarliteASGIRouter
      File "/Users/naamanhirschfeld/workspace/starlite/starlite/asgi.py", line 10, in <module>
        from starlite.routes import ASGIRoute, HTTPRoute
      File "/Users/naamanhirschfeld/workspace/starlite/starlite/routes.py", line 20, in <module>
        from starlite.controller import Controller
      File "/Users/naamanhirschfeld/workspace/starlite/starlite/controller.py", line 6, in <module>
        from starlite.handlers import BaseRouteHandler
      File "/Users/naamanhirschfeld/workspace/starlite/starlite/handlers/__init__.py", line 3, in <module>
        from .http import HTTPRouteHandler, delete, get, patch, post, put, route
      File "/Users/naamanhirschfeld/workspace/starlite/starlite/handlers/http.py", line 54, in <module>
        class HTTPRouteHandler(BaseRouteHandler):
      File "/Users/naamanhirschfeld/workspace/starlite/starlite/handlers/http.py", line 256, in HTTPRouteHandler
        def resolve_exception_handlers(self) -> Dict[Union[int, Type[Exception], ExceptionHandler]]:
      File "/opt/homebrew/Cellar/[email protected]/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 312, in inner
        return func(*args, **kwds)
      File "/opt/homebrew/Cellar/[email protected]/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 1143, in __getitem__
        _check_generic(self, params, self._nparams)
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/typing_extensions.py", line 103, in _check_generic
        raise TypeError(f"Too {'many' if alen > elen else 'few'} parameters for {cls};"
    TypeError: Too few parameters for typing.Dict; actual 1, expected 2
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/opt/homebrew/Cellar/[email protected]/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/opt/homebrew/Cellar/[email protected]/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/slotscheck/__main__.py", line 4, in <module>
        root()
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
        return self.main(*args, **kwargs)
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
        rv = self.invoke(ctx)
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
        return __callback(*args, **kwargs)
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/slotscheck/cli.py", line 163, in root
        classes, modules = _collect(files, module, conf)
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/slotscheck/cli.py", line 382, in _collect
        modules_all = consolidate(
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/slotscheck/discovery.py", line 46, in consolidate
        for t in trees:
      File "/Users/naamanhirschfeld/.cache/pre-commit/repotvckiflq/py_env-python3.10/lib/python3.10/site-packages/slotscheck/discovery.py", line 158, in module_tree
        loader = pkgutil.get_loader(module)
      File "/opt/homebrew/Cellar/[email protected]/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/pkgutil.py", line 481, in get_loader
        return find_loader(fullname)
      File "/opt/homebrew/Cellar/[email protected]/3.10.4/Frameworks/Python.framework/Versions/3.10/lib/python3.10/pkgutil.py", line 501, in find_loader
        raise ImportError(msg.format(fullname, type(ex), ex)) from ex
    ImportError: Error while finding loader for 'starlite.controller' (<class 'TypeError'>: Too few parameters for typing.Dict; actual 1, expected 2)
    
    bug 
    opened by Goldziher 4
  • Add ini support

    Add ini support

    Description

    Closes #52

    Before merge

    • [ ] tox runs successfully
    • [ ] Docs updated

    Before release (if applicable)

    • [ ] Version updated in pyproject.toml
    • [ ] Version updated in pre-commit hook example
    • [ ] Version updated in changelog
    • [ ] Branch merged
    • [ ] Tag created and pushed
    • [ ] Published
    opened by q0w 4
  • False positive with typing.TypedDict?

    False positive with typing.TypedDict?

    Consider the following:

    from typing import TypedDict
    
    foo = TypedDict("foo", {"bar": str})
    
    
    class Foo(TypedDict):
        bar: str
    

    slotscheck running in stric mode (require-subclass = true) will flag both foo and Foo as missing slots, although TypedDict are not used as "real class" and don't support slots:

    PS D:\test> slotscheck main.py -v
    ERROR: 'main:Foo' has no slots, but it could have.
           This is flagged because the strict `require-subclass` setting is active.
    ERROR: 'main:foo' has no slots, but it could have.
           This is flagged because the strict `require-subclass` setting is active.
    Oh no, found some problems!
    
    

    Or should TypedDict support slots out of the box?

    bug 
    opened by yakMM 3
  • Bump pydantic from 1.9.2 to 1.10.2

    Bump pydantic from 1.9.2 to 1.10.2

    Bumps pydantic from 1.9.2 to 1.10.2.

    Release notes

    Sourced from pydantic's releases.

    v1.10.2 (2022-09-05)

    Full Changelog: https://github.com/pydantic/pydantic/compare/v1.10.1...v1.10.2

    v1.10.1 (2022-08-31)

    • Add __hash__ method to pydancic.color.Color class, #4454 by @​czaki

    Full Changelog: https://github.com/pydantic/pydantic/compare/v1.10.0...v1.10.1

    v1.10.0 (2022-08-30)

    See #4419 for feedback and discussion, docs are live at pydantic-docs.helpmanual.io.

    • Refactor the whole pydantic dataclass decorator to really act like its standard lib equivalent. It hence keeps __eq__, __hash__, ... and makes comparison with its non-validated version possible. It also fixes usage of frozen dataclasses in fields and usage of default_factory in nested dataclasses. The support of Config.extra has been added. Finally, config customization directly via a dict is now possible, #2557 by @​PrettyWood BREAKING CHANGES:
      • The compiled boolean (whether pydantic is compiled with cython) has been moved from main.py to version.py
      • Now that Config.extra is supported, dataclass ignores by default extra arguments (like BaseModel)
    • Fix PEP487 __set_name__ protocol in BaseModel for PrivateAttrs, #4407 by @​tlambert03
    • Allow for custom parsing of environment variables via parse_env_var in Config, #4406 by @​acmiyaguchi
    • Rename master to main, #4405 by @​hramezani
    • Fix StrictStr does not raise ValidationError when max_length is present in Field, #4388 by @​hramezani
    • Make SecretStr and SecretBytes hashable, #4387 by @​chbndrhnns
    • Fix StrictBytes does not raise ValidationError when max_length is present in Field, #4380 by @​JeanArhancet
    • Add support for bare type, #4375 by @​hramezani
    • Support Python 3.11, including binaries for 3.11 in PyPI, #4374 by @​samuelcolvin
    • Add support for re.Pattern, #4366 by @​hramezani
    • Fix __post_init_post_parse__ is incorrectly passed keyword arguments when no __post_init__ is defined, #4361 by @​hramezani
    • Fix implicitly importing ForwardRef and Callable from pydantic.typing instead of typing and also expose MappingIntStrAny, #4358 by @​aminalaee
    • remove Any types from the dataclass decorator so it can be used with the disallow_any_expr mypy option, #4356 by @​DetachHead
    • moved repo to pydantic/pydantic, #4348 by @​yezz123
    • fix "extra fields not permitted" error when dataclass with Extra.forbid is validated multiple times, #4343 by @​detachhead
    • Add Python 3.9 and 3.10 examples to docs, #4339 by @​Bobronium
    • Discriminated union models now use oneOf instead of anyOf when generating OpenAPI schema definitions, #4335 by @​MaxwellPayne
    • Allow type checkers to infer inner type of Json type. Json[list[str]] will be now inferred as list[str], Json[Any] should be used instead of plain Json. Runtime behaviour is not changed, #4332 by @​Bobronium
    • Allow empty string aliases by using a alias is not None check, rather than bool(alias), #4253 by @​sergeytsaplin
    • Update ForwardRefs in Field.outer_type_, #4249 by @​JacobHayes
    • The use of __dataclass_transform__ has been replaced by typing_extensions.dataclass_transform, which is the preferred way to mark pydantic models as a dataclass under PEP 681, #4241 by @​multimeric
    • Use parent model's Config when validating nested NamedTuple fields, #4219 by @​synek

    ... (truncated)

    Changelog

    Sourced from pydantic's changelog.

    v1.10.2 (2022-09-05)

    v1.10.1 (2022-08-31)

    • Add __hash__ method to pydancic.color.Color class, #4454 by @​czaki

    v1.10.0 (2022-08-30)

    • Refactor the whole pydantic dataclass decorator to really act like its standard lib equivalent. It hence keeps __eq__, __hash__, ... and makes comparison with its non-validated version possible. It also fixes usage of frozen dataclasses in fields and usage of default_factory in nested dataclasses. The support of Config.extra has been added. Finally, config customization directly via a dict is now possible, #2557 by @​PrettyWood BREAKING CHANGES:
      • The compiled boolean (whether pydantic is compiled with cython) has been moved from main.py to version.py
      • Now that Config.extra is supported, dataclass ignores by default extra arguments (like BaseModel)
    • Fix PEP487 __set_name__ protocol in BaseModel for PrivateAttrs, #4407 by @​tlambert03
    • Allow for custom parsing of environment variables via parse_env_var in Config, #4406 by @​acmiyaguchi
    • Rename master to main, #4405 by @​hramezani
    • Fix StrictStr does not raise ValidationError when max_length is present in Field, #4388 by @​hramezani
    • Make SecretStr and SecretBytes hashable, #4387 by @​chbndrhnns
    • Fix StrictBytes does not raise ValidationError when max_length is present in Field, #4380 by @​JeanArhancet
    • Add support for bare type, #4375 by @​hramezani
    • Support Python 3.11, including binaries for 3.11 in PyPI, #4374 by @​samuelcolvin
    • Add support for re.Pattern, #4366 by @​hramezani
    • Fix __post_init_post_parse__ is incorrectly passed keyword arguments when no __post_init__ is defined, #4361 by @​hramezani
    • Fix implicitly importing ForwardRef and Callable from pydantic.typing instead of typing and also expose MappingIntStrAny, #4358 by @​aminalaee
    • remove Any types from the dataclass decorator so it can be used with the disallow_any_expr mypy option, #4356 by @​DetachHead
    • moved repo to pydantic/pydantic, #4348 by @​yezz123
    • fix "extra fields not permitted" error when dataclass with Extra.forbid is validated multiple times, #4343 by @​detachhead
    • Add Python 3.9 and 3.10 examples to docs, #4339 by @​Bobronium
    • Discriminated union models now use oneOf instead of anyOf when generating OpenAPI schema definitions, #4335 by @​MaxwellPayne
    • Allow type checkers to infer inner type of Json type. Json[list[str]] will be now inferred as list[str], Json[Any] should be used instead of plain Json. Runtime behaviour is not changed, #4332 by @​Bobronium
    • Allow empty string aliases by using a alias is not None check, rather than bool(alias), #4253 by @​sergeytsaplin
    • Update ForwardRefs in Field.outer_type_, #4249 by @​JacobHayes
    • The use of __dataclass_transform__ has been replaced by typing_extensions.dataclass_transform, which is the preferred way to mark pydantic models as a dataclass under PEP 681, #4241 by @​multimeric
    • Use parent model's Config when validating nested NamedTuple fields, #4219 by @​synek
    • Update BaseModel.construct to work with aliased Fields, #4192 by @​kylebamos

    ... (truncated)

    Commits
    • bc74342 prepare for v1.10.2
    • f1e9883 fix: dataclass wrapper was not always called (#4484)
    • 91bb8d4 Basic fix of GenericModel cache to detect order of args in Union models [#447...
    • eccd85e prevent long strings as int inputs (#4480)
    • a4367c1 Revert percent encoding in URLs. (#4470)
    • 02cf7f5 fix mypy with default_factory=list etc. (#4471)
    • 5a2ddec Use tomllib on Python 3.11 (#4476)
    • 317bef3 build(deps): bump black from 22.6.0 to 22.8.0 (#4465)
    • 2add8a9 build(deps): bump hypothesis from 6.54.3 to 6.54.4 (#4464)
    • f1fb4f2 build(deps): bump mkdocs-material from 8.4.0 to 8.4.2 (#4463)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 3
  • Fix Protocol imports on >=3.10

    Fix Protocol imports on >=3.10

    Description

    Since typing_extensions is only required on >3.10, attempts to run the latest release on <=3.10 fail if typing_extensions hasn't been installed into the target environment.

    Protocol was added to the std typing module in 3.8 so this should only ever need to fallback to typing_extensions for Protocol on 3.7 and some 3.8 alpha releases.

    I don't know why your CI is installing typing_extensions before running tests on 3.10 and 3.11.

    Before merge

    • [ ] tox runs successfully
    • [ ] Docs updated

    Before release (if applicable)

    • [x] Version updated in pyproject.toml
    • [x] Version updated in pre-commit hook example
    • [x] Version updated in changelog
    • [x] Branch merged
    • [x] Tag created and pushed
    • [x] Published
    opened by FasterSpeeding 2
  • dataclass fields with default values misscategorized as class variables

    dataclass fields with default values misscategorized as class variables

    In this example:

    @dataclass
    class SemanticVersion:
        __slots__ = ("version", "prerelease", "build_metadata")
    
        version: tuple[int, int, int]
        prerelease: Optional[tuple[str, ...]] = None
        build_metadata: Optional[tuple[str, ...]] = None
    

    slotscheck reports a failed import, due to prerelease (and build_metadata) being in __slots__ conflicting with class variables.

    However clearly, these aren't actually class variables, they're in fact just fields of a dataclass with some default values. Slotscheck should probably be able to distinguish between actual class variables and usage in dataclasses, to prevent this false positive.

    Note that sometimes, variables defined like this can actually be considered class variables by the dataclass decorator, but only if they're type-hinted as one, or if they aren't type hinted at all, see this example:

    from typing import ClassVar
    
    @dataclass
    class Foobar:
        FOO: ClassVar[int] = 5  # actual class variable, not present in generated `__init__`
        BAR = 10  # another class variable, not present in generated `__init__`
        
        x: int = 2  # instance variable, with default value in `__init__`
    
    opened by ItsDrike 2
  • ImportError handling

    ImportError handling

    Hi there,

    So I encountered a problem that currently forced me to disable this tool in pre-commit. You can see the pertinent branch here: https://github.com/starlite-api/starlite/pull/315

    The issue is that this plugin fails on import errors. In the above linked branch we are creating rust based extension and we are using a *.pyi file for its typings. Import fails because the extension is not built during pre-commit.

    I'd like to suggest one of the following to handle this: stop failing on import errors. Maybe make this configurable with a command line arg, e.g. emit error, warning or continue on import error, but in any case the preferable opinion from my PoV is to to skip import errors and continue without failure.

    opened by Goldziher 2
  • Warn if inheriting from non-slotted protocol in slots-required mode

    Warn if inheriting from non-slotted protocol in slots-required mode

    (A bit of an obscure edge case, but worth documenting for future reference.)

    The require-subclass mode warns of any classes which could be slotted, but are not.

    class A(int):  # slots-required error triggered because A cloud be slotted, but isn't
        ...
    
    class B(A):  # no slots-required error because B cannot be slotted (because one of its superclasses isn't)
        ...
    

    However, protocols complicate things a bit:

    class MyProto(Protocol):  # no slots-required error because protocols are not concrete classes
        ...
    
    class C(MyProto):  # no slots-required error because one of its superclasses has no slots.
        ...
    

    In the last case, we might want to emit a warning that C could be slotted if its protocol is. In the current situation, C is more-or-less silently allowed to not have slots. Note that this problem is not present in ABC because they are meant to be inherited from and do trigger slots-required themselves.

    enhancement 
    opened by ariebovenberg 1
  • Detailed debug output

    Detailed debug output

    For debugging issues it'd be useful to be able to include some debug output. This could include:

    • Given paths/arguments
    • Settings used, and from which files they come
    • installed packages, Python version etc.
    enhancement 
    opened by ariebovenberg 0
  • Ignore classes by using comments

    Ignore classes by using comments

    slotscheck should support something like:

    
    # slotscheck: ignore[require-superclass,overlaps]
    class A(Base):
        __slots__ = ('a', 'b')
    
    # slotscheck: ignore
    class B(Base):
        __slots__ = ()
    
    enhancement needs refinement 
    opened by ariebovenberg 0
  • Helpful message when 'module not found' is a directory in working directory

    Helpful message when 'module not found' is a directory in working directory

    It's already documented why:

    slotscheck mymodule/
    

    doesn't work if the current directory is not explicitly in sys.path.

    However, this is a corner of Python unknown to many. To prevent unnecessary frustration, a helpful message can be printed linking to the docs

    enhancement 
    opened by ariebovenberg 1
  • More relaxed `require-subclass` option

    More relaxed `require-subclass` option

    Currently slotscheck has the require-subclass option, which enforces the use of __slots__ wherever slotted classes are subclassed. However, this greatly depends on whether builtin/extension classes are considered "slotted". For example, object has no __dict__. Flagging all direct object subclasses would essentially require slots for all classes in a module (that don't subclass from a non-slot class outside the module).

    enhancement needs refinement 
    opened by ariebovenberg 1
Owner
Arie Bovenberg
Dutch-American 🚲 civil engineer turned coder. Experienced python wrangler 🐍, functional-programming enthousiast ⚡, and aspiring computational wizard ✨.
Arie Bovenberg
A Python tool to check ASS subtitles for common mistakes and errors.

A Python tool to check ASS subtitles for common mistakes and errors.

null 1 Dec 18, 2021
With the initiation of the COVID vaccination drive across India for all individuals above the age of 18, I wrote a python script which alerts the user regarding open slots in the vicinity!

cowin_notifier With the initiation of the COVID vaccination drive across India for all individuals above the age of 18, I wrote a python script which

null 13 Aug 1, 2021
A Python Web Application for Checking vaccine slots by pincodes and auto slot booking.

The Dashboard is developed using Bokeh and python 3.5+. This dashboard is useful for you if you are looking for something which will help you to book the vaccine slot once slots become available. Other Vaccine Finders will notify you once slots become available but you will still need to login to the portal and book the slot manually. This dashboard will look for slot availability continuously and will send the OTP itself once slots become available.

Suraj Deshmukh 10 Jan 23, 2022
Python module for creating the circuit simulation definitions for Elmer FEM

elmer_circuitbuilder Python module for creating the circuit simulation definitions for Elmer FEM. The circuit definitions enable easy setup of coils (

null 5 Oct 3, 2022
Automatically find solutions when your Python code encounters an issue.

What The Python?! Helping you find answers to the errors Python spits out. Installation You can find the source code on GitHub at: https://github.com/

What The Python?! 139 Dec 14, 2022
Web app to find your chance of winning at Texas Hold 'Em

poker_mc Web app to find your chance of winning at Texas Hold 'Em A working version of this project is deployed at poker-mc.ue.r.appspot.com. It's run

Aadith Vittala 7 Sep 15, 2021
Find your desired product in Digikala using this app.

Digikala Search Find your desired product in Digikala using this app. با این برنامه محصول مورد نظر خود را در دیجیکالا پیدا کنید. About me Full name: M

Matin Ardestani 17 Sep 15, 2022
General tricks that may help you find bad, or noisy, labels in your dataset

doubtlab A lab for bad labels. Warning still in progress. This repository contains general tricks that may help you find bad, or noisy, labels in your

vincent d warmerdam 449 Dec 26, 2022
ChainJacking is a tool to find which of your Go lang direct GitHub dependencies is susceptible to ChainJacking attack.

ChainJacking is a tool to find which of your Go lang direct GitHub dependencies is susceptible to ChainJacking attack.

Checkmarx 36 Nov 2, 2022
Larvamatch - Find your larva or punk match.

LarvaMatch Find your larva or punk match. UI TBD API (not started) The API will allow you to specify a punk by token id to find a larva match, and vic

null 1 Jan 2, 2022
Participants of Bertelsmann Technology Scholarship created an awesome list of resources and they want to share it with the world, if you find illegal resources please report to us and we will remove.

Participants of Bertelsmann Technology Scholarship created an awesome list of resources and they want to share it with the world, if you find illegal

Wissem Marzouki 29 Nov 28, 2022
Find the remote website version based on a git repository

versionshaker Versionshaker is a tool to find a remote website version based on a git repository This tool will help you to find the website version o

Orange Cyberdefense 110 Oct 23, 2022
The tool helps to find hidden parameters that can be vulnerable or can reveal interesting functionality that other hunters miss.

The tool helps to find hidden parameters that can be vulnerable or can reveal interesting functionality that other hunters miss. Greater accuracy is achieved thanks to the line-by-line comparison of pages, comparison of response code and reflections.

null 197 Nov 14, 2022
A practice program to find the LCM i.e Lowest Common Multiplication of two numbers using python without library.

Finding-LCM-using-python-from-scratch Here, I write a practice program to find the LCM i.e Lowest Common Multiplication of two numbers using python wi

Sachin Vinayak Dabhade 4 Sep 24, 2021
PyPI package for scaffolding out code for decision tree models that can learn to find relationships between the attributes of an object.

Decision Tree Writer This package allows you to train a binary classification decision tree on a list of labeled dictionaries or class instances, and

null 2 Apr 23, 2022
Simplest way to find Appointments in Bürgeramt Berlin, Not over engineered.

Simplest way to find Appointments in Bürgeramt Berlin, Not over engineered. Der einfachste Weg, Termine im Bürgeramt Berlin zu finden, ohne viel Schnickschnack.

Jannis 8 Nov 25, 2022
The goal of this program was to find the most common color in my living room.

The goal of this program was to find the most common color in my living room. I found a dataset online with colors names and their corr

null 1 Nov 9, 2021
Given tool find related trending keywords of input keyword

blog_generator Given tool find related trending keywords of input keyword (blog_related_to_keyword). Then cretes a mini blog. Currently its customised

Shivanshu Srivastava 2 Nov 30, 2021
Here You will Find CodeChef Challenge Solutions

Here You will Find CodeChef Challenge Solutions

kanishk kashyap 1 Sep 3, 2022