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

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

Open
ariebovenberg opened this issue Jan 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ariebovenberg
Copy link
Owner

ariebovenberg commented Jan 2, 2023

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

@ariebovenberg ariebovenberg added the enhancement New feature or request label Jan 2, 2023
@ariebovenberg
Copy link
Owner Author

This behavior is a result of #130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant