[pylint] Implement invalid-bytes-returned (E0308)#10959
[pylint] Implement invalid-bytes-returned (E0308)#10959charliermarsh merged 7 commits intoastral-sh:mainfrom
pylint] Implement invalid-bytes-returned (E0308)#10959Conversation
0317d41 to
f7cb7d4
Compare
CodSpeed Performance ReportMerging #10959 will not alter performanceComparing Summary
|
|
| visitor.returns | ||
| }; | ||
|
|
||
| for stmt in returns { |
There was a problem hiding this comment.
Should this rule and the other invalid-*-returned rules also flag the case where the method has no return statement
class Test:
def __bytes__(self):
print("nope")
There was a problem hiding this comment.
I added this case as well. If this becomes the consensus, I can also add it to the already included bool (E0304) and str (E0307) cases.
There was a problem hiding this comment.
@MichaReiser As it turned out, the no-return case is not that simple: if there is just a pass/ellipsis/raise statement, then this rule should not raise. However, if there is e.g. a print statement and a raise statement, then it should raise - see the tests for examples.
There was a problem hiding this comment.
I changed this to use is_stub for detecting the other cases.
a84894a to
197b5fc
Compare
pylint] Implement invalid-bytes-returned (E0308)
6eb9545 to
ced76b9
Compare
Add pylint rule invalid-bytes-returned (PLE0308)
See #970 for rules
Test Plan:
cargo test