Add Useless-Overload-Body rule#3853
Conversation
There was a problem hiding this comment.
LGTM, thanks
@NathanTempest do you mind merging this one
|
Just resolved the conflicts, LGTM and importing it now. |
|
Thank you for working on this @pratved64. The merge conflicts that I resolved are not being applied properly and are causing some internal import errors. Can you rebase this diff, make sure that the any documentation related to the error kinds are in alphabetical order, resolve the merge conflicts and push the changes so I can try to import again ? Thanks in advance and welcome to the Pyrefly team. We are looking forward to working with you on your future contributions. |
1f3d875 to
4e97202
Compare
|
I've rebased with the main branch, resolved merge conflicts and ensured that the errors are in alphabetical order in both the definitions and documentation. Let me know if anything else is needed! |
NathanTempest
left a comment
There was a problem hiding this comment.
LGTM thanks for addressing my follow-ups
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Summary
Added a useless-overload-body rule to execute when an overloaded function contains executable body logic. Since, overload bodies are never executed at runtime, executable logic becomes dead code and only placeholder bodies are useful (pass, ..., docstring-only, raise NotImplementedError, return NotImplemented).
Default severity is warn since the dead code will not cause any runtime errors. The valid exemptions to this rule are:
Fixes #3767
Test Plan
I added a regression test covering executable logic, placeholders and edge cases. Additionally, 2 existing tests were updated to expect this new rule (test_implementation_with_overload, test_overload_with_docstring2). To test changes locally, I ran:
Please note: Initial exploration of the codebase was assisted by a local AI agent