Add more ruff rules (#8767)

* Add more ruff rules

* Add more ruff rules

* pre-commit: Update ruff v0.0.269 -> v0.0.270

* Apply suggestions from code review

* Fix doctest

* Fix doctest (ignore whitespace)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2023-05-26 09:34:17 +02:00
committed by GitHub
parent dd3b499bfa
commit 4b79d771cd
67 changed files with 349 additions and 223 deletions

View File

@@ -23,7 +23,8 @@ def resistor_parallel(resistors: list[float]) -> float:
index = 0
for resistor in resistors:
if resistor <= 0:
raise ValueError(f"Resistor at index {index} has a negative or zero value!")
msg = f"Resistor at index {index} has a negative or zero value!"
raise ValueError(msg)
first_sum += 1 / float(resistor)
index += 1
return 1 / first_sum
@@ -47,7 +48,8 @@ def resistor_series(resistors: list[float]) -> float:
for resistor in resistors:
sum_r += resistor
if resistor < 0:
raise ValueError(f"Resistor at index {index} has a negative value!")
msg = f"Resistor at index {index} has a negative value!"
raise ValueError(msg)
index += 1
return sum_r