-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid recommending __slots__ for classes that inherit from more than …
…namedtuple
- Loading branch information
1 parent
6f4db86
commit 496384e
Showing
3 changed files
with
31 additions
and
20 deletions.
There are no files selected for viewing
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
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
19 changes: 13 additions & 6 deletions
19
...s/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_slots/mod.rs | ||
--- | ||
SLOT002.py:5:7: SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` | ||
SLOT002.py:6:7: SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` | ||
| | ||
5 | class Bad(namedtuple("foo", ["str", "int"])): # SLOT002 | ||
6 | class Bad(namedtuple("foo", ["str", "int"])): # SLOT002 | ||
| ^^^ SLOT002 | ||
6 | pass | ||
7 | pass | ||
| | ||
|
||
SLOT002.py:9:7: SLOT002 Subclasses of call-based `typing.NamedTuple()` should define `__slots__` | ||
SLOT002.py:10:7: SLOT002 Subclasses of call-based `typing.NamedTuple()` should define `__slots__` | ||
| | ||
9 | class UnusualButStillBad(NamedTuple("foo", [("x", int, "y", int)])): # SLOT002 | ||
10 | class UnusualButStillBad(NamedTuple("foo", [("x", int, "y", int)])): # SLOT002 | ||
| ^^^^^^^^^^^^^^^^^^ SLOT002 | ||
10 | pass | ||
11 | pass | ||
| | ||
|
||
SLOT002.py:30:7: SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` | ||
| | ||
30 | class UnusualButStillBad(namedtuple("foo", ["str", "int"]), NamedTuple("foo", [("x", int, "y", int)])): | ||
| ^^^^^^^^^^^^^^^^^^ SLOT002 | ||
31 | pass | ||
| |