-
Notifications
You must be signed in to change notification settings - Fork 951
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
Evaluate using HomeAssistant rules in ruff #1477
Comments
I did not express myself well, please add these rules in our ruff.toml but comment those out that currently gives you a headache. This PR is clean and nice, let's keep it like that, and then you can un comment the rules in new PR(s). |
I understood you, but remember better if it's an issue assigned to me. (I work across a dozen projects) |
Ahh it is a new one, sorry I am on my iPAD this evening. |
Looking forward to see more PR around this theme. I too work on a number of projects and I have absolutely no problem with you opening issues as reminders. |
Looks like you have the version active ? or am I missing something? |
I don't understand your question. === Anyways, I've gone and deleted some rules where I don't see value (such as There are three remaining "big" rulesets which I think are useful, but require more substantial work. I've put them in but commented out.
|
we already use bandit directly and mccabe via pylint, so it puzzles me why those 2 are big jobs....the third one is new to me. Anyhow if you want we can divide them, or you do it slowly when you have time. |
For McCabe/pylint, I intend to actually reduce the complexity and not just use For bandit, I don't think it's actually used: Lines 8 to 13 in 248f8de
Both
|
Bandit is used: pymodbus/.github/workflows/ci.yml Line 34 in 248f8de
Reducing is a nice goal, but please please do it very carefully, and in chunks I can review....I have already tried and failed (or at least postponed). |
o_0. OK, I missed that. Hopefully #1488 makes it clearer (and kills another CI runner, yay) However,
|
I believe you do ! |
I just read about ruff, in another project. Is rule M001 default ? if not we should activate it, to get warnings when there are unused noga statements. |
Hmm, it appears I'd suggest moving the other project from |
thanks. |
If #1510 is OK, we're down to two functions with a McCabe complexity of > 10.
Note that both of them have large |
I have reworked many if/else constructs to So I suggest you follow the same pattern if possible. |
Yes, it's good advice when possible for nested if/else. However, I meant code like this (sequential if / else if / else) that would be a switch/case or match in other languages: pymodbus/pymodbus/transaction.py Lines 340 to 349 in 759b222
Actually, since there are now only a few left I think I will just ignore them, switch to ruff, and disable the pylint McCabe. |
Switch to ruff sounds like a good idea, but please do not disable McCabe, but add "pylint: disable=complex..." or whatever it is called in ruff, for those couple of methods. |
I meant disabling the pylint McCade while enabling it in ruff. a25de7f |
Ahh got it, my bad 😀 |
Originally posted by @janiversen in #1476 (comment)
https://github.com/home-assistant/core/blob/7eccef87c2cccb834f5ff394f765e697831390e3/pyproject.toml#L240
"ICN001", # import concentions; {name} should be imported as {asname}"T20", # flake8-printignore = [
"D203", # 1 blank line required before class docstring"D213", # Multi-line docstring summary should start at the second line"D406", # Section name should end with a newline"D407", # Section name underliningIgnored due to performance: Implement PEP 604 rewrites for
isinstance
andissubclass
checks astral-sh/ruff#2923"UP038", # UseX | Y
inisinstance
call instead of(X, Y)
The text was updated successfully, but these errors were encountered: