Enable ruff RUF003 rule (#11376)

* Enable ruff RUF003 rule

* Update pyproject.toml

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Maxim Smolskiy 2024-04-22 22:56:14 +03:00 committed by GitHub
parent 4700297b3e
commit d016fda51c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 8 deletions

View File

@ -26,7 +26,7 @@ def _fib(n: int) -> tuple[int, int]:
if n == 0: # (F(0), F(1))
return (0, 1)
# F(2n) = F(n)[2F(n+1) F(n)]
# F(2n) = F(n)[2F(n+1) - F(n)]
# F(2n+1) = F(n+1)^2+F(n)^2
a, b = _fib(n // 2)
c = a * (b * 2 - a)

View File

@ -33,7 +33,7 @@ def main(
pheromone_evaporation: float,
alpha: float,
beta: float,
q: float, # Pheromone system parameters Qwhich is a constant
q: float, # Pheromone system parameters Q, which is a constant
) -> tuple[list[int], float]:
"""
Ant colony algorithm main function
@ -117,7 +117,7 @@ def pheromone_update(
cities: dict[int, list[int]],
pheromone_evaporation: float,
ants_route: list[list[int]],
q: float, # Pheromone system parameters Qwhich is a constant
q: float, # Pheromone system parameters Q, which is a constant
best_path: list[int],
best_distance: float,
) -> tuple[list[list[float]], list[int], float]:

View File

@ -146,7 +146,7 @@ class PolynomialRegression:
"Design matrix is not full rank, can't compute coefficients"
)
# np.linalg.pinv() computes the MoorePenrose pseudoinverse using SVD
# np.linalg.pinv() computes the Moore-Penrose pseudoinverse using SVD
self.params = np.linalg.pinv(X) @ y_train
def predict(self, data: np.ndarray) -> np.ndarray:

View File

@ -10,9 +10,6 @@ lint.ignore = [ # `ruff rule S101` for a description of that rule
"PLW2901", # PLW2901: Redefined loop variable -- FIX ME
"PT011", # `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
"PT018", # Assertion should be broken down into multiple parts
"RUF001", # String contains ambiguous {}. Did you mean {}?
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
"RUF003", # Comment contains ambiguous {}. Did you mean {}?
"S101", # Use of `assert` detected -- DO NOT FIX
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
"SLF001", # Private member accessed: `_Iterator` -- FIX ME

View File

@ -36,7 +36,7 @@ def luhn_validation(credit_card_number: str) -> bool:
digit = int(cc_number[i])
digit *= 2
# If doubling of a number results in a two digit number
# i.e greater than 9(e.g., 6 × 2 = 12),
# i.e greater than 9(e.g., 6 x 2 = 12),
# then add the digits of the product (e.g., 12: 1 + 2 = 3, 15: 1 + 5 = 6),
# to get a single digit number.
if digit > 9: