jendrikseipp / vulture

Find dead Python code
MIT License
3.38k stars 148 forks source link

Feature request: not throw "unused variable" for __exit__ #292

Closed jamesbraza closed 1 year ago

jamesbraza commented 1 year ago

Are you willing to consider built-in whitelisting "unused variable" reports for context management's __exit__?

Context management is a fundamental aspect of Python, with __exit__'s signature documented in Python's data model. Furthermore, __exit__'s signature is autocompleted by IDE's like PyCharm. I don't think one should have to explicitly go back and replace commonly unused argument names like exc_type with _.

Considering this is overrideable built-in object functionality, I think having unused arguments should be allowed by default.

What do you think?


Disclaimer: this issue is a blatent duplicate of https://github.com/jendrikseipp/vulture/issues/39, but I didn't want to grave dig an issue from over 5 years ago.

jendrikseipp commented 1 year ago

I still believe that the best way to solve this is to explicitly mark the arguments as unused. There's nothing special about the argument names, and they might even change between Python releases. I updated issue #39 with more recommendations for marking the arguments as unused.