astral-sh/ruff
Auf GitHub ansehenAuto-fix for SIM103 could be improved or add a new SIM rule?
Open
#6.184 geöffnet am 31. Juli 2023
acceptedhelp wantedrule
Repository-Metriken
- Stars
- (47.527 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 3T 8h) (573 gemergte PRs in 30 T)
Beschreibung
I came across this code on a project:
if not condition_a and condition_b:
return True
elif condition_a and condition_b:
return True
else:
return False
condition_a is redundant and this entire snippet should be simplified to:
return bool(condition_b)
However, this is what ruff produced using ruff --select="SIM103" example.py --fix --isolated:
if not condition_a and condition_b:
return True
return bool(condition_a and condition_b)
I think this is correct reading the rule docs but I thought there could be some improvement here either within this rule or a new rule.
Ruff version is 0.0.280 and config:
[tool.ruff]
line-length = 120
select = [
"D3", # pydocstyle
"D40", # pydocstyle
"DTZ", # flake8-datetimez
"FLY", # flynt
"I", # isort
"INT", # flake8-gettext
"PIE", # flake8-pie
"PLC", # pylint
"PLE", # pylint
"RSE", # flake8-raise
"SIM2", # flake8-simplify
"SIM3", # flake8-simplify
"TCH", # flake8-type-checking
"W", # pycodestyle
"YTT", # flake8-2020
]
target-version = "py37"