False positive DirectMagicAttributeAccessViolation with __subclasses__
See original GitHub issueBug report
What’s wrong
class MyClass(object):
"""My class."""
subs = MyClass.__subclasses__()
This piece of code raises
WPS609 Found direct magic attribute usage: __subclasses__
How is that should be
__subclasess__
method should be excluded from the check because it’s a class method and can be used outside of class.
Maybe there are other methods that should be excluded?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
A Guide to Python's Magic Methods « rafekettler.com
A guide to all the Magic Methods in Python. ... Representing your Classes; Controlling Attribute Access; Making Custom Sequences; Reflection ...
Read more >3. Data model — Python 3.11.1 documentation
These are attributes that provide access to the implementation and are not intended for general use. Their definition may change in the future....
Read more >Python Tutorial - Object-Oriented Programming (OOP)
To access an attribute, use "dot" operator in the form of class_name.attr_name or instance_name.attr_name . To construct an instance of a class, invoke...
Read more >Underscoring (or dunder-scoring) the importance of native ...
And all Python objects have a type with associated attributes and ... data types using something known as dunder methods or magic methods....
Read more >2. Class vs. Instance Attributes | OOP | python-course.eu
Object-oriented programming in Python: instance attributes vs. class ... Besides this, we see that we can access a class attribute via an ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@AlwxSin submit a PR then 🛷
@mattany thanks a lot! And congrats on your first open-source fork 🎉
I am going to help you!
And let’s start from here: we can create a whitelist of method names that can be called. And do not raise violation if this method name is inside the whitelist.
Feel free to ask any questions!