Closed Kub-AT closed 2 years ago
Even simpler examples that SIM119 is raised for:
class Foo:
def __init__(self, a):
self.b = a + 4
Or
class Bar:
def __init__(self, a):
self.a = a + 4
async def foo(self):
pass
Basically, if that foo() is turned into a non-async method, SIM119 is not raised.
So it seems there are at least 3 cases where SIM119 should not be suggested:
__init__
actually processes passed-in value before setting it on the classLinked PR will not make the OfType
example not trigger the warning.
Here is a test which shows the issue:
def test_sim119_false_positive():
results = _results('''class OfType:
"""
>>> 3 == OfType(int, str, bool)
True
>>> 'txt' == OfType(int)
False
"""
def __init__(self, *types):
self.types = types
def __eq__(self, other):
return isinstance(other, self.types)''')
for el in results:
assert "SIM119" not in el
Desired change
Explanation
Examples below are suggested as dataclass. I think they shouldnt
Example