Report on uncatchable exception handlers (?)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 123
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 5
Description
Was surprised bugbear didn't report this, but not encountered in live code so I don't know if it's seen much / ever in the wild:
try:
...
except BaseException:
...
except:
...
will report B001/E722, but in a project that uses bare excepts widely and disables those checks the except never being possible to run seems like a separate error.
try:
...
except BaseException:
...
except Exception:
...
Gives no warning, nor does a plausibly more common
try:
...
except Exception:
...
except ValueError:
...
or similar variants. Checking whether a caught exception is a built-in, and if so issubclass of a previously caught exception, seems straightforward. I quickly checked mypy and vulture as well and neither of them sees it. But this might definitely not be common enough that it's worth bothering with.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the existing B001/E722 handling and how flake8-bugbear represents exception handlers. Compare the BaseException, Exception, ValueError, and bare-except examples in the issue, then determine whether an additional warning and tests are warranted for unreachable handlers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100