flake8-bugbear icon indicating copy to clipboard operation
flake8-bugbear copied to clipboard

raise RunetimeError check

Open gaul opened this issue 5 years ago • 4 comments

This is a bit cheeky, but I encountered the misspelling RunetimeError instead of the correct RuntimeError and it seems to have some popularity:

https://github.com/search?l=Python&q=%22raise+RunetimeError%22&type=Code

cc: @timuralp

gaul avatar Oct 17 '20 12:10 gaul

So are you asking here if we should lint for this? I feel unittests should be finding this one.

cooperlees avatar Nov 23 '20 18:11 cooperlees

Yes, I think bugbear might want to add a check for this and other common typos on exceptional paths. These paths are often hard to test and thus poorly tested. While I have only personally encountered RunetimeError, I could imagine common misspellings of ValueError, OSError, and Exception. We could do some more GitHub searches to prove this out.

gaul avatar Nov 24 '20 11:11 gaul

In my opinion, this could be better handled by type checking/type hints instead of flake8-bugbear. Those types of tools are expressly designed to trace information like this throughout the application.

kkirsche avatar Jan 23 '23 13:01 kkirsche

Even linters like flake8 can usually detect undefined names like RunetimeError (unless you use import *, but then you have only yourself to blame). I don't think bugbear needs a special case for this.

JelleZijlstra avatar Jan 23 '23 15:01 JelleZijlstra