Closed sondrelg closed 2 years ago
You're absolutely right. SIM909 needs a fix. I hope in 1-2 hours I can release a new version with the fix.
Thank you for reporting it!
class BaseMeta:
metadata = metadata
$ python -m astpretty --no-show-offsets /dev/stdin <<< `cat example.py`
Module(
body=[
ClassDef(
name='BaseMeta',
bases=[],
keywords=[],
body=[
Assign(
targets=[Name(id='metadata', ctx=Store())],
value=Name(id='metadata', ctx=Load()),
type_comment=None,
),
],
decorator_list=[],
),
],
type_ignores=[],
)
Let me know when the new release is out and I can test on my repo if you'd like 🙂
flake8-simplify==0.19.2
was just released with the fix :-)
All the (now) false positives are gone, and it seems to run well. Thanks @MartinThoma!
Nice! Thank you for reporting the issue and checking if the fix works!
Desired change
Explanation
I have this code:
The
BaseMeta
class is used for database models as theMeta
baseclass.This is currently flagged by SIM909, but after reading through the rationale of the rule, I think this could be considered a false positive. Assignment of
metadata
tometadata
on a class is not the same as outside a class right - it actually serves a purpose 🙂What do you think?