Too Broad of an exception

Rene Kita mail at rkta.de
Wed Oct 25 10:25:42 EDT 2023


rsutton <rsutton43 at comcast.net> wrote:
> Hi all,
> I am fairly new to python (ie < 2 years).  I have a question about 
> pylint.  I am running on windows 10/11, python 3.10.11.
[...]
>         if p.returncode >= 8:
>             raise Exception(f'Invalid result: {p.returncode}')
> 
> It actually runs fine.  But pylint is not having it.  I get:
> 
> win_get_put_tb_filters.py:61:12: W0719: Raising too general exception: 
> Exception (broad-exception-raised)

pylint is just a linter, ignore it if the code works and you like it the
way it is.

pylint complains because you use Exception. Use e.g. RuntimeException to
silence it.


More information about the Python-list mailing list