Skip to content

Commit

Permalink
Clean ruff; ignore many rules in this old code
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Nov 15, 2023
1 parent f6012e9 commit ad01ba5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cheta/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ def _plural(x):
"""Return English plural of ``x``. Super-simple and only valid for the
known small set of cases within fetch where it will get applied.
"""
return x + "es" if (x.endswith("x") or x.endswith("s")) else x + "s"
return x + "es" if (x.endswith(("x", "s"))) else x + "s"


def get_data_gap_spec_parser():
Expand Down
2 changes: 1 addition & 1 deletion cheta/get_telem.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def sanitize_event_expression(expr):
ast.literal_eval(word)
tokens.append("LITERAL")
except Exception:
raise ValueError("Cannot identify word {!r}".format(word))
raise ValueError("Cannot identify word {!r}".format(word)) from None

# Now check syntax and do substitutions where needed
in_arg_list = False
Expand Down
3 changes: 1 addition & 2 deletions cheta/tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import numpy as np

from .. import fetch as fetch_cxc
from .. import fetch_eng as fetch_eng
from .. import fetch_sci as fetch_sci
from .. import fetch_eng, fetch_sci
from ..units import Units

start = "2011:001:00:00:00"
Expand Down
2 changes: 1 addition & 1 deletion make_units_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
units_sci = dict(
(msid, "DEGC")
for msid, unit in units_cxc.items()
if unit == "K" or unit == "deltaK"
if unit in ("K", "deltaK")
)
pickle.dump(units_sci, open("units_sci.pkl", "wb"))
13 changes: 11 additions & 2 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ignore = [
"PLR2004", # Magic number
]

# TODO : fix these and stop ignoring. Commented out ones are common and OK to except.
# TODO : fix these and stop ignoring. This is an old package with a lot of poor style.
extend-ignore = [
"PGH004", # Use specific rule codes when using `noqa`
"D205", # 1 blank line required between summary line and description
Expand All @@ -59,7 +59,16 @@ extend-ignore = [
"C408", # Unnecessary `dict` call (rewrite as a literal)
"C416", # Unnecessary `dict` comprehension (rewrite using `dict()`)
"PGH002", # warn is deprecated in favor of warning
# "PYI056", # Calling `.append()` on `__all__` may not be supported by all type checkers
"TID252", # Relative imports from parent modules are banned (DO NOT FIX: namespace)
"PLW0603", # Using the global statement to update `password` is discouraged
"SIM118", # Use `key in dict` instead of `key in dict.keys()`
"B007", # Loop control variable `time` not used within loop body
"E721", # Do not compare types, use `isinstance()`
"PGH001", # No builtin `eval()` allowed
"B904", # Within an `except` clause, raise exceptions with
"B007", # Loop control variable `i` not used within loop body
"PLW0602", # Using global for .. but no assignment is done
"PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation
]

extend-exclude = [
Expand Down

0 comments on commit ad01ba5

Please sign in to comment.