mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-27 11:07:43 +07:00
- support @dataclass(slots=True) - add inspection for conflict with explicit __slots__ - add quickfix for new inspection - add/adjust tests GitOrigin-RevId: 5ac6efeb6c1e209b641365e2f22bdca74ae6484a
29 lines
699 B
HTML
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> |