Closed edbennett closed 5 months ago
Note that adding "SIM"
to the ruff
linting options will point this out to avoid reintroducing it.
This have been solved by ruff.
It's still present in src/lsdensities/InverseProblemWrapper.py
. Add "SIM"
to line 35 of pyproject.toml
and then run pre-commit run --all
and it will highlight it.
Done.
Fab; can you fix the other issues that SIM
now highlights?
It appears that no issues are detected.
Weird, I see two issues on my machine.
$ pre-commit run --all
ruff.....................................................................Failed
- hook id: ruff
- exit code: 1
src/lsdensities/InverseProblemWrapper.py:675:17: SIM102 Use a single `if` statement instead of nested `if` statements
src/lsdensities/utils/rhoUtils.py:237:13: SIM113 Use `enumerate()` for index variable `indx` in `for` loop
Found 2 errors.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
ruff-format..............................................................Passed
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
check toml...............................................................Passed
mixed line ending........................................................Passed
Ok, now I get them too, and I solved it.
This is a pedantic issue, but there is usually not a reason to write something like
The reason:
some_condition_that_is_boolean
is alreadyTrue
orFalse
, so you can return it directly:Bam, your function is 3 lines shorter so there are 3 fewer lines of code to need to understand.