-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add slotscheck #14
Merged
Merged
Add slotscheck #14
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ItsDrike
added
t: bug
Something isn't working
p: 2 - normal
Normal priority
t: feature
New request or feature
a: CI
Related to continuous integration and deployment
a: internal
Related to internal API of the project
labels
Dec 29, 2022
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
a: CI
Related to continuous integration and deployment
a: internal
Related to internal API of the project
p: 2 - normal
Normal priority
t: bug
Something isn't working
t: feature
New request or feature
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the only thing enforcing
__slots__
in the code-base is theRequiredParamsABCMixin
class, which is only checking for presence of the variable and prevents initialization if this presence check fails (similarly to how ABCs work).However there's a lot more things that we should be enforcing when it comes to
__slots__
, such as avoiding duplicates, ensuring all subclasses have__slots__
defined, etc. For these additional checks, we can use theslotscheck
library.Along with that, slotscheck can also require all classes to be slotted by default, and produce a linter error otherwise. Of course, we can always add specific ignores if some class shouldn't be slotted (though
slotscheck
is actually pretty good at recognizing those cases itself, so it might not even be that necessary).However since
slotscheck
works by actually running the code it's checking, and performing it's checks on runtime, some of it's edge case ignores that it provides require proper typing imports (like to ignore the need for__slots__
inTypedDict
orProtocol
classes), which is why this PR also converts our current way of usingtyping-extensions
and turns it into a full runtime dependency.This is not a huge issue, as it seems that one of our dependencies already requires
typing-extensions
on runtime, so us requiring it too doesn't actually change anything about whether the library users will end up installing it.