Skip to content

Ignore E722: do not use bare 'except'

Valentin Valls requested to merge valls-patch-206 into master

Hi @all, here is a proposal to ignore E722 for flake8.

I feel like this constraint is far too strict.

This warn in the case there is no filter in the except:

try:
    bar
except:
    foo

Which is always used for context manager, which is needed for strong code dealing any unexpected fail like ctrl-c, which is not the same as except Exception:. It's the same as except BaseException: but i guess it also warn for this one.

I was fixing the Flint base code relative to that, but i have reverted my changes. I have also tried to do so few months ago, and i have also reverted it.

In fact a bare except is really explicit in the fact it catches everything, so i don't see the problem.

It could be introduced back later but, for now i think it is noise.

What do you think?

$ flake8 | grep E722 | wc -l
218

FYI, on my branch with fixes

$ flake8 | wc -l
2115

I was aiming to reduce the warnings bellow to 2000 :-) I think it is the best approach.

Merge request reports