[pylint] Avoid false-positive slot non-assignment for __dict__ (PLE0237) (#10348)

Closes https://github.com/astral-sh/ruff/issues/10306.
This commit is contained in:
Charlie Marsh 2024-03-11 15:48:56 -07:00 committed by GitHub
parent 02fc521369
commit f8f56186b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -54,3 +54,15 @@ class StudentE(StudentD):
def setup(self):
pass
class StudentF(object):
__slots__ = ("name", "__dict__")
def __init__(self, name, middle_name):
self.name = name
self.middle_name = middle_name # [assigning-non-slot]
self.setup()
def setup(self):
pass

View file

@ -142,7 +142,7 @@ fn is_attributes_not_in_slots(body: &[Stmt]) -> Vec<AttributeAssignment> {
}
}
if slots.is_empty() {
if slots.is_empty() || slots.contains("__dict__") {
return vec![];
}