Open
Description
Current problem
Please see the below code:
# pylint: disable=missing-module-docstring,missing-function-docstring
from typing import NoReturn
def way_one() -> NoReturn:
raise ValueError # C code instantiation of ValueError
def way_two() -> NoReturn:
raise ValueError() # Interpreter instantiation of ValueError (slower)
Check this Stack Overflow answer: https://stackoverflow.com/a/16709222
way_one
is faster than way_two
, when not specifying arguments to the Exception
class.
Desired solution
I think it would be cool if pylint
would suggest this minor optimization, when no arguments are specified.
Something like consider-raising-with-class
:
> pylint a.py
a.py:9: W1234: Consider raising with exception class if no message (consider-raising-with-class)
Additional context
No response