File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -452,7 +452,7 @@ def _parse_exc(
452452 issubclass (origin_exc , BaseExceptionGroup )
453453 and exc_type in (BaseException , Any )
454454 ):
455- if not isinstance ( exc , Exception ):
455+ if not issubclass ( origin_exc , ExceptionGroup ):
456456 self .is_baseexception = True
457457 return cast (type [BaseExcT_1 ], origin_exc )
458458 else :
@@ -465,9 +465,9 @@ def _parse_exc(
465465 )
466466 # unclear if the Type/ValueError distinction is even helpful here
467467 msg = f"expected exception must be { expected } , not "
468- if isinstance (exc , type ):
468+ if isinstance (exc , type ): # type: ignore[unreachable]
469469 raise ValueError (msg + f"{ exc .__name__ !r} " )
470- if isinstance (exc , BaseException ):
470+ if isinstance (exc , BaseException ): # type: ignore[unreachable]
471471 raise TypeError (msg + f"an exception instance ({ type (exc ).__name__ } )" )
472472 raise TypeError (msg + repr (type (exc ).__name__ ))
473473
Original file line number Diff line number Diff line change @@ -1325,6 +1325,16 @@ def test_annotated_group() -> None:
13251325 with RaisesExc (BaseExceptionGroup [BaseException ]):
13261326 raise BaseExceptionGroup ("" , [KeyboardInterrupt ()])
13271327
1328+ # assure AbstractRaises.is_baseexception is set properly
1329+ assert (
1330+ RaisesGroup (ExceptionGroup [Exception ]).expected_type ()
1331+ == "ExceptionGroup(ExceptionGroup)"
1332+ )
1333+ assert (
1334+ RaisesGroup (BaseExceptionGroup [BaseException ]).expected_type ()
1335+ == "BaseExceptionGroup(BaseExceptionGroup)"
1336+ )
1337+
13281338
13291339def test_tuples () -> None :
13301340 # raises has historically supported one of several exceptions being raised
Original file line number Diff line number Diff line change @@ -417,7 +417,7 @@ def test_context() -> None:
417417 with monkeypatch .context () as m :
418418 m .setattr (functools , "partial" , 3 )
419419 assert not inspect .isclass (functools .partial )
420- assert inspect .isclass (functools .partial ) # type:ignore[unreachable]
420+ assert inspect .isclass (functools .partial )
421421
422422
423423def test_context_classmethod () -> None :
You can’t perform that action at this time.
0 commit comments