-
Notifications
You must be signed in to change notification settings - Fork 90
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
Fix overlapping, missing slots #426
Conversation
3242e03
to
1982742
Compare
Codecov Report
@@ Coverage Diff @@
## master #426 +/- ##
=======================================
Coverage 90.84% 90.84%
=======================================
Files 103 103
Lines 6868 6870 +2
=======================================
+ Hits 6239 6241 +2
Misses 629 629
Continue to review full report at Codecov.
|
@ariebovenberg This is great, thanks. Slots are tricky to work with, and error prone, as your tool illustrates. I think it's worthwhile adding One feature you could potentially add in the future is emitting a warning for this situation: class Animal:
__slots__ = ('colour',)
class Dog(Animal):
pass # Because it doesn't define slots, Python still assigns a dictionary, should be `__slots__ = ()` This might already be supported, and I'm not aware. |
I added it to the lint script, but chose not to run it on Regarding your idea about warnings: I'm very interested to hear any thoughts about slots 'enforcement' policies! Slotscheck does have a superstrict |
@ariebovenberg Thanks for this. I agree, there's no need to check the I left a comment on the issue you opened. |
@ariebovenberg The only other suggestion I have for
But instead it's:
Which is fine, but I think it would be more intuitive if both worked. |
@dantownsend indeed that can be confusing. This behavior is determined by Python itself, so I'm hesitant to override it. This is the approach also followed by pyanalyze, so slotscheck is in good company. There's a detailed description in the docs about this potentially confusing behavior. Now that I think about it...it'd probably be a good idea to add a link to this whenever a module cannot be found that corresponds to a directory in the working directory 🤔 — to prevent any unnecessary frustration (ariebovenberg/slotscheck#60) |
@ariebovenberg Interesting - it makes a lot more sense now I've read your docs about it. I can see your reasoning for doing it that way. |
There are some misconfigured
__slots__
:Thankfully the fix appears easy.
I discovered the slots issues with slotscheck, a tool I maintain. Of course, If you like, I can add it to CI as I've done for instagram/LibCST, sqlalchemy/sqlalchemy, and aio-libs/aiohttp.