-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable pylint and other linting rules in ruff #417
Conversation
But don't enable ruff format preview mode, since we don't want their parentheses formatting yet (hug_parens_with_braces_and_square_brackets)
These rules can be used again now that preview mode is enabled
s += "X units: {:s}\n".format(self.xmode or "None") | ||
s += "Y units: {:s}\n".format(self.ymode or "None") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike this change---it relies on a subtlety unique to python that not even many intermediate python programmers know, just for the sake of a little brevity. Could we disable this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your alternate idea: convert both to f"{str(self.xymode)}"
for maximum conciseness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is almost certainly FURB110
@@ -95,7 +95,7 @@ def read(filename, verbose=False, cal_kwargs=None): | |||
energy_channel_pairs = [] | |||
energy_res_pairs = [] # currently unused | |||
energy_eff_pairs = [] # currently unused | |||
with Path(filename).open() as f: | |||
with Path(filename).open(encoding="utf-8") as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is PLW1514
.
@@ -31,7 +31,7 @@ def sim_data(x_min, x_max, y_func, num_x=200, binning="linear", **params): | |||
edges = np.linspace(x_min, x_max, num_x, dtype=float) | |||
elif binning == "sqrt": | |||
edges = np.linspace(np.sqrt(x_min), np.sqrt(x_max), num_x) | |||
edges = edges**2 | |||
edges **= 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this exists? TIL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I like it
I will redo this PR without implementing |
This PR enables the following rulesets in
ruff
:SIM
: flake8-simplify rules to simplify codePL
: pylint rules to "check[] for errors, enforce[] a coding standard, look[] for code smells, and [] make suggestions about how the code could be refactored"FURB
: refurb, "for refurbishing and modernizing Python codebases"I thought these made useful improvements and would be helpful for maintaining our code going forward.