We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples below are suggested as dataclass. I think they shouldnt
class RegexAssert: def __init__(self, pattern, flags=0): self._regex = re.compile(pattern, flags) def __eq__(self, actual): return bool(self._regex.match(actual)) def __repr__(self): return self._regex.pattern
class OfType: """ >>> 3 == OfType(int, str, bool) True >>> 'txt' == OfType(int) False """ def __init__(self, *types): self.type = types def __eq__(self, other): return isinstance(other, self.type)
The text was updated successfully, but these errors were encountered:
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__
Sorry, something went wrong.
Linked PR will not make the OfType example not trigger the warning.
OfType
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
91f371f
MartinThoma
No branches or pull requests
Desired change
Explanation
Examples below are suggested as dataclass. I think they shouldnt
Example
The text was updated successfully, but these errors were encountered: