An option to ignore unused variables starting with '_'

已回答

Would it be possible to add an option to the "unused local" inspection to ignore names starting with a "_"?

I really like unused variable warnings, I find that they detect a lot of bugs. I'm coming from Eclipse, and it supports ignoring unused locals starting with an underscore, As a result, my company's code base has a lot of unused variables starting with "_" and this causes a lot of PyCharm warnings.

I think this is a very good convention: for example in tuple unpacking, it allows me to find bugs by detecting unused names, and lets me explicitly declare names that I'm not using by prepending an underscore. The alternative of replacing the entire name with "_" is inferior, because then if I want to know the meaning of that value, I have to look up the function documentation. On the other hand, if the name remains and is just prefixed by an underscore, it's easy to understand its meaning.

Thanks,

Noam

 

1

Hello Noam,
Please, feel free to file a feature request about it to PyCharm bug-tracker: https://youtrack.jetbrains.com/issues/PY.

0
Avatar
Permanently deleted user

Thanks! Here's the feature request: https://youtrack.jetbrains.com/issue/PY-27435

0

请先登录再写评论。