-
Notifications
You must be signed in to change notification settings - Fork 379
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
[cfg] Upgrade to pylint 3.2.4 #4279
Conversation
fccd454
to
9525937
Compare
# Regular expression matching correct method names | ||
method-rgx=[a-z_][a-z0-9_]{2,30}$ | ||
# Maximum number of characters on a single line. | ||
max-line-length=100 |
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.
Previously, the maximum number of characters in a line was 80. Is it an automatically generated new value of max-line-length? Shouldn't have we sticked to previous number?
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.
Good point, thanks! pycodestyle
is also checking this. By the way, pylint
looks quite extensive in format checking. Would it be worth getting rid of pycodestyle
? Would we lose anything with it? We could compare these two tools sometime in the future.
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.
Yes, I think it is redundant. We should check these parameters by one tool.
# Naming hint for method names | ||
method-name-hint=[a-z_][a-z0-9_]{2,30}$ | ||
# Maximum number of lines in a module. | ||
max-module-lines=1000 |
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.
The max-module-lines limit was 2000. Should we change it?
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.
Maybe, we could, but I turned off max line checking in the disable
section anyway. report_server.py
has more than 4300 lines :)
duplicate-code, # TODO: Could be eliminated | ||
cyclic-import, # TODO: Could be fixed | ||
subprocess-popen-preexec-fn, # TODO: Could be fixed | ||
broad-exception-caught, # TODO: could be valid | ||
no-member, # TODO: Why is this emitted for multiprocess module? | ||
consider-using-with, # TODO: Mainly for Popen, could be valid | ||
protected-access, # TODO: Used in test code, but not elegant | ||
global-statement, | ||
consider-using-get, # Unnecessary style checker | ||
attribute-defined-outside-init # Too many reports from test codes |
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.
The cyclic-import and the no-member checkers used to be enabled explicitly.
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 don't understand, why they didn't report earlier, then. Currently they give reports. I added to TODO for cyclic import, that could be solved sometime. It's interesting, though, that python interpreter doesn't bother about it.
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 don't understand either. OK, we're going to figure it out and solve the cyclic import problem.
#output-format= | ||
|
||
# Tells whether to display a full report or only the messages. | ||
reports=no |
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.
We used to set output-format=text and reports=yes. I am not sure it is necessary to change them. Maybe the default value of the output-format is text.
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.
It's interesting, because some reports are generated even without this option. But you're right. I'll check if there are some local settings in Makefiles for pylint invocations. Now I can see some --ignore and some other configurations in Makefiles, but you're right, every check should use the same configuration. I'll unify pylint calls in makefiles.
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.
Thank you for checking it!
@@ -164,7 +164,8 @@ def check_supported_analyzers(analyzers): | |||
failed_analyzers.add((analyzer_name, | |||
"Failed to detect analyzer binary!")) | |||
continue | |||
elif not os.path.isabs(analyzer_bin): | |||
|
|||
if not os.path.isabs(analyzer_bin): | |||
# If the analyzer is not in an absolute path, try to find it... |
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.
Why can't we use elif here?
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.
We can. The checker says that if a continue/break/return/raise/etc. command skips the rest of the block, then it's not necessary to put that block under an "else". I would say, this is a question of style. If we don't agree with this convention, then I can turn off this checker.
@@ -87,7 +87,7 @@ def __check_bug_path_order(self, run_results, order): | |||
def test_get_run_results_no_filter(self): | |||
""" Get all the run results without any filtering. """ | |||
runid = self._runid | |||
logging.debug('Get all run results from the db for runid: ' + | |||
logging.debug('Get all run results from the db for runid: %s', |
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.
And here.
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 prefer to use f-string instead of %s format.
@@ -189,7 +189,7 @@ def test_skip(self): | |||
""" There should be no results from the skipped file. """ | |||
|
|||
runid = self._runid | |||
logging.debug('Get all run results from the db for runid: ' + | |||
logging.debug('Get all run results from the db for runid: %s', |
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 prefer to use f-string instead of %s format.
@@ -237,7 +237,7 @@ def test_suppress_comment_in_db(self): | |||
Exported source suppress comment stored as a review status in the db. | |||
""" | |||
runid = self._runid | |||
logging.debug("Get all run results from the db for runid: " + | |||
logging.debug("Get all run results from the db for runid: %s", |
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.
Same here.
for run_result in run_results: | ||
logging.debug(run_result) | ||
self.assertIsNotNone(run_results) | ||
self.assertNotEqual(len(run_results), 0) | ||
|
||
for bug_hash in hash_to_suppress_msgs: | ||
logging.debug("tesing for bug hash " + bug_hash) | ||
expected_data = hash_to_suppress_msgs[bug_hash] | ||
for bug_hash, expected_data in hash_to_suppress_msgs.items(): | ||
logging.debug("tesing for bug hash %s", bug_hash) |
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.
And here.
Thanks for the review, it's a great work at this PR :) So, would you think, that we should rather allow the "elif" style? Is there any style checker that anyone doesn't agree with? The other common note was about f-strings, but I would say that for the logging library it's reasonable not to use them. I would wait a little before I go through this change again, so it can be done only once. If no other suggestions arrive, I'll undo "elif" style. |
The general consensus (at least from what I understood from the community posts) is that you should adhere to "no if not foo:
log("error")
return
good_things() If the two (or all) branches of the if foo == enum.A:
return "A"
elif foo == enum.B:
return "B"
# ... |
No description provided.