Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More relaxed require-subclass option #59

Open
ariebovenberg opened this issue Feb 10, 2022 · 1 comment
Open

More relaxed require-subclass option #59

ariebovenberg opened this issue Feb 10, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request needs refinement This issue needs refinement before work can start

Comments

@ariebovenberg
Copy link
Owner

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).

@ariebovenberg ariebovenberg added enhancement New feature or request needs refinement This issue needs refinement before work can start labels Feb 10, 2022
@dantownsend
Copy link

I think it should be if someone explicitly declares slots in a parent class.

class Animal:
    __slots__ = ('colour',)

class Dog(Animal):
    pass  # This is likely to be a mistake.

You could do something like check whether the class and parent class exist in the same module.

@ariebovenberg ariebovenberg self-assigned this Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs refinement This issue needs refinement before work can start
Projects
None yet
Development

No branches or pull requests

2 participants