Files
openide/python/python-psi-impl/resources/inspectionDescriptions/PyDunderSlotsInspection.html
Marcus Mewsandintellij-monorepo-bot 3914253777 PY-76811 Conformance test failure: dataclasses_slots.py
- support @dataclass(slots=True)
- add inspection for conflict with explicit __slots__
- add quickfix for new inspection
- add/adjust tests

GitOrigin-RevId: 5ac6efeb6c1e209b641365e2f22bdca74ae6484a
2025-09-18 08:08:12 +00:00

29 lines
699 B
HTML

<html>
<body>
<p>Reports invalid usages of a class with <code>__slots__</code> definitions.</p>
<p><b>Example when accessing undefined attributes:</b></p>
<pre><code>
class Foo:
__slots__ = ['foo', 'bar']
def __init__(self):
self.x = 3 # error: 'x' is not defined in __slots__
</code></pre>
<p><b>Example of conflicting attributes:</b></p>
<pre><code>
class A:
__slots__ = ("x",)
x = 42 # error: conflict with "x" listed in __slots__
</code></pre>
<p><b>Example <code>slots=True</code>:</b></p>
<pre><code>
from dataclasses import dataclass
@dataclass(slots=True) # error: __slots__ is also defined in Foo
class Foo:
__slots__ = ['a']
</code></pre>
</body>
</html>