MartinThoma / flake8-simplify

❄ A flake8 plugin that helps you to simplify code
MIT License
185 stars 19 forks source link

[Adjust Rule] SIM401 unnecessarily quotes default value #89

Closed akx closed 2 years ago

akx commented 2 years ago

Desired change

Explanation

The pattern

if a:
    token = a[1]
elif 'token' in dct:
    token = dct['token']
else:
    token = None

is reported as

SIM401 Use 'token = dct.get(token, "None")' instead of an if-block

though it obviously should be

SIM401 Use 'token = dct.get(token, None)' instead of an if-block

or when the default is None,

SIM401 Use 'token = dct.get(token)' instead of an if-block

Example

See above.

MartinThoma commented 2 years ago

hi @akx , Thank you for reporting this issue. I'm currently fixing several issues with SIM401 in PR #85 . This

MartinThoma commented 2 years ago

Closed by https://github.com/MartinThoma/flake8-simplify/pull/85

MartinThoma commented 2 years ago

Thank you very much for your help. The issue was fixed in flake8-simplify==0.14.6