File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ Release date: TBA
8585* Improve ``as_string()`` representation for ``TypeVar``, ``ParamSpec`` and ``TypeVarTuple`` nodes, as well as
8686 type parameter in ``ClassDef``, ``FuncDef`` and ``TypeAlias`` nodes (PEP 695).
8787
88+ * Fix a false positive for ``not-an-iterable`` in an ``ExceptionGroup`` context.
89+
90+ Closes pylint-dev/pylint#8985
91+ Closes pylint-dev/pylint#10558
92+
8893
8994What's New in astroid 3.3.11?
9095=============================
Original file line number Diff line number Diff line change @@ -770,6 +770,12 @@ def attr_text(self):
770770 return node_classes .Const ("" )
771771
772772
773+ class GroupExceptionInstanceModel (ExceptionInstanceModel ):
774+ @property
775+ def attr_exceptions (self ) -> nodes .Tuple :
776+ return node_classes .Tuple (parent = self ._instance )
777+
778+
773779class OSErrorInstanceModel (ExceptionInstanceModel ):
774780 @property
775781 def attr_filename (self ):
@@ -804,6 +810,7 @@ def attr_object(self):
804810
805811BUILTIN_EXCEPTIONS = {
806812 "builtins.SyntaxError" : SyntaxErrorInstanceModel ,
813+ "builtins.ExceptionGroup" : GroupExceptionInstanceModel ,
807814 "builtins.ImportError" : ImportErrorInstanceModel ,
808815 "builtins.UnicodeDecodeError" : UnicodeDecodeErrorInstanceModel ,
809816 # These are all similar to OSError in terms of attributes
Original file line number Diff line number Diff line change 1212 List ,
1313 Name ,
1414 Try ,
15+ Tuple ,
1516 Uninferable ,
1617 bases ,
1718 extract_node ,
2122from astroid .nodes import Expr , Raise , TryStar
2223
2324
25+ @pytest .mark .skipif (not PY311_PLUS , reason = "Requires Python 3.11 or higher" )
26+ def test_group_exceptions_exceptions () -> None :
27+ node = extract_node (
28+ textwrap .dedent (
29+ """
30+ try:
31+ raise ExceptionGroup('', [TypeError(), TypeError()])
32+ except ExceptionGroup as eg:
33+ eg.exceptions #@"""
34+ )
35+ )
36+
37+ inferred = node .inferred ()[0 ]
38+ assert isinstance (inferred , Tuple )
39+
2440@pytest .mark .skipif (not PY311_PLUS , reason = "Requires Python 3.11 or higher" )
2541def test_group_exceptions () -> None :
2642 node = extract_node (
You can’t perform that action at this time.
0 commit comments