diff --git a/playwright/_impl/_async_base.py b/playwright/_impl/_async_base.py index b06994a65..db7e5d005 100644 --- a/playwright/_impl/_async_base.py +++ b/playwright/_impl/_async_base.py @@ -96,9 +96,9 @@ async def __aenter__(self: Self) -> Self: async def __aexit__( self, - exc_type: Type[BaseException], - exc_val: BaseException, - traceback: TracebackType, + exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], + traceback: Optional[TracebackType], ) -> None: await self.close() diff --git a/playwright/_impl/_sync_base.py b/playwright/_impl/_sync_base.py index e6fac9750..3fef433b5 100644 --- a/playwright/_impl/_sync_base.py +++ b/playwright/_impl/_sync_base.py @@ -142,9 +142,9 @@ def __enter__(self: Self) -> Self: def __exit__( self, - exc_type: Type[BaseException], - exc_val: BaseException, - _traceback: TracebackType, + exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], + _traceback: Optional[TracebackType], ) -> None: self.close()