@@ -210,16 +210,17 @@ def visit_name(self, node: nodes.Name) -> None:
210210 "notimplemented-raised" , node = self ._node , confidence = HIGH
211211 )
212212 return
213-
214213 try :
215- exceptions = list (_annotated_unpack_infer (node ))
214+ exceptions = [
215+ c
216+ for _ , c in _annotated_unpack_infer (node )
217+ if isinstance (c , nodes .ClassDef )
218+ ]
216219 except astroid .InferenceError :
217220 return
218221
219- for _ , exception in exceptions :
220- if isinstance (
221- exception , nodes .ClassDef
222- ) and self ._checker ._is_overgeneral_exception (exception ):
222+ for exception in exceptions :
223+ if self ._checker ._is_overgeneral_exception (exception ):
223224 self ._checker .add_message (
224225 "broad-exception-raised" ,
225226 args = exception .name ,
@@ -306,13 +307,13 @@ class ExceptionsChecker(checkers.BaseChecker):
306307
307308 def open (self ) -> None :
308309 self ._builtin_exceptions = _builtin_exceptions ()
310+ # TODO 3.1: Remove this check and put it elsewhere
309311 for exc_name in self .linter .config .overgeneral_exceptions :
310312 if "." not in exc_name :
311313 warnings .warn_explicit (
312- "Specifying exception names in the overgeneral-exceptions option"
313- " without module name is deprecated and support for it"
314- " will be removed in pylint 3.0."
315- f" Use fully qualified name (maybe 'builtins.{ exc_name } ' ?) instead." ,
314+ f"'{ exc_name } ' is not a proper value for the 'overgeneral-exceptions' option. "
315+ f"Use fully qualified name (maybe 'builtins.{ exc_name } ' ?) instead. "
316+ "This will cease to be checked at runtime in 3.1.0." ,
316317 category = UserWarning ,
317318 filename = "pylint: Command line or configuration file" ,
318319 lineno = 1 ,
@@ -646,13 +647,7 @@ def visit_tryexcept(self, node: nodes.TryExcept) -> None:
646647 exceptions_classes += [exc for _ , exc in exceptions ]
647648
648649 def _is_overgeneral_exception (self , exception : nodes .ClassDef ) -> bool :
649- return (
650- exception .qname () in self .linter .config .overgeneral_exceptions
651- # TODO: 3.0: not a qualified name, deprecated
652- or "." not in exception .name
653- and exception .name in self .linter .config .overgeneral_exceptions
654- and exception .root ().name == utils .EXCEPTIONS_MODULE
655- )
650+ return exception .qname () in self .linter .config .overgeneral_exceptions
656651
657652
658653def register (linter : PyLinter ) -> None :
0 commit comments