@@ -659,9 +659,9 @@ class E2(E1): pass
659659try:
660660 pass
661661except (E1, E2): pass
662- except (E1, object): pass # E: Exception type must be derived from BaseException
663- except (object, E2): pass # E: Exception type must be derived from BaseException
664- except (E1, (E2,)): pass # E: Exception type must be derived from BaseException
662+ except (E1, object): pass # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
663+ except (object, E2): pass # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
664+ except (E1, (E2,)): pass # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
665665
666666except (E1, E2): pass
667667except ((E1, E2)): pass
@@ -690,7 +690,7 @@ except (E1, E2) as e1:
690690except (E2, E1) as e2:
691691 a = e2 # type: E1
692692 b = e2 # type: E2 # E: Incompatible types in assignment (expression has type "E1", variable has type "E2")
693- except (E1, E2, int) as e3: # E: Exception type must be derived from BaseException
693+ except (E1, E2, int) as e3: # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
694694 pass
695695[builtins fixtures/exception.pyi]
696696
@@ -750,13 +750,13 @@ def nested_union(exc: Union[Type[E1], Union[Type[E2], Type[E3]]]) -> None:
750750def error_in_union(exc: Union[Type[E1], int]) -> None:
751751 try:
752752 pass
753- except exc as e: # E: Exception type must be derived from BaseException
753+ except exc as e: # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
754754 pass
755755
756756def error_in_variadic(exc: Tuple[int, ...]) -> None:
757757 try:
758758 pass
759- except exc as e: # E: Exception type must be derived from BaseException
759+ except exc as e: # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
760760 pass
761761
762762[builtins fixtures/tuple.pyi]
@@ -784,15 +784,15 @@ except E1 as e1:
784784 reveal_type(e1) # N: Revealed type is "Any"
785785except E2 as e2:
786786 reveal_type(e2) # N: Revealed type is "__main__.E2"
787- except NotBaseDerived as e3: # E: Exception type must be derived from BaseException
787+ except NotBaseDerived as e3: # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
788788 pass
789- except (NotBaseDerived, E1) as e4: # E: Exception type must be derived from BaseException
789+ except (NotBaseDerived, E1) as e4: # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
790790 pass
791- except (NotBaseDerived, E2) as e5: # E: Exception type must be derived from BaseException
791+ except (NotBaseDerived, E2) as e5: # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
792792 pass
793- except (NotBaseDerived, E1, E2) as e6: # E: Exception type must be derived from BaseException
793+ except (NotBaseDerived, E1, E2) as e6: # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
794794 pass
795- except (E1, E2, NotBaseDerived) as e6: # E: Exception type must be derived from BaseException
795+ except (E1, E2, NotBaseDerived) as e6: # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
796796 pass
797797[builtins fixtures/exception.pyi]
798798
@@ -953,8 +953,8 @@ except a as b:
953953import typing
954954def exc() -> BaseException: pass
955955try: pass
956- except exc as e: pass # E: Exception type must be derived from BaseException
957- except BaseException() as b: pass # E: Exception type must be derived from BaseException
956+ except exc as e: pass # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
957+ except BaseException() as b: pass # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
958958[builtins fixtures/exception.pyi]
959959
960960[case testTupleValueAsExceptionType]
@@ -980,7 +980,7 @@ except exs2 as e2:
980980
981981exs3 = (E1, (E1_1, (E1_2,)))
982982try: pass
983- except exs3 as e3: pass # E: Exception type must be derived from BaseException
983+ except exs3 as e3: pass # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
984984[builtins fixtures/exception.pyi]
985985
986986[case testInvalidTupleValueAsExceptionType]
@@ -991,7 +991,7 @@ class E2(E1): pass
991991
992992exs1 = (E1, E2, int)
993993try: pass
994- except exs1 as e: pass # E: Exception type must be derived from BaseException
994+ except exs1 as e: pass # E: Exception type must be derived from BaseException (or be a tuple of exception classes)
995995[builtins fixtures/exception.pyi]
996996
997997[case testOverloadedExceptionType]
@@ -1034,7 +1034,7 @@ def h(e: Type[int]):
10341034[builtins fixtures/exception.pyi]
10351035[out]
10361036main:9: note: Revealed type is "builtins.BaseException"
1037- main:12: error: Exception type must be derived from BaseException
1037+ main:12: error: Exception type must be derived from BaseException (or be a tuple of exception classes)
10381038
10391039
10401040-- Del statement
0 commit comments