New submission from Cooper Lees <[email protected]>:
Today if you enter a `contextlib.suppress()` context and specify no exceptions
there is no error or warning (I didn't check pywarnings to be fair). Isn't this
a useless context then? If not, please explain why and close.
If it is, I'd love to discuss possibly raising a new NoSupressionError or at
least a warning to let people know they executing an unneeded context.
Example code that 3.11 does not error on:
```python
cooper@home1:~$ python3.11
Python 3.11.0a5+ (main, Feb 21 2022, 08:52:10) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import contextlib
>>> with contextlib.suppress():
... print("Foo")
...
Foo
```
This was reported to `flake8-bugbear` and if this is not accepted I may accept
adding this to the linter. But feel this could be fixable in cpython itself.
----------
components: Library (Lib)
messages: 413663
nosy: cooperlees
priority: normal
severity: normal
status: open
title: Add an Error / Exception / Warning when contextlib.suppress() is entered
with no specified exception(s) to suppress
versions: Python 3.11
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46819>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com