Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/PIL/_util.py: 69%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

16 statements  

1from __future__ import annotations 

2 

3import os 

4 

5TYPE_CHECKING = False 

6if TYPE_CHECKING: 

7 from typing import Any, NoReturn, TypeGuard 

8 

9 from ._typing import StrOrBytesPath 

10 

11 

12def is_path(f: Any) -> TypeGuard[StrOrBytesPath]: 

13 return isinstance(f, (bytes, str, os.PathLike)) 

14 

15 

16class DeferredError: 

17 def __init__(self, ex: BaseException): 

18 self.ex = ex 

19 

20 def __getattr__(self, elt: str) -> NoReturn: 

21 raise self.ex 

22 

23 @staticmethod 

24 def new(ex: BaseException) -> Any: 

25 """ 

26 Creates an object that raises the wrapped exception ``ex`` when used, 

27 and casts it to :py:obj:`~typing.Any` type. 

28 """ 

29 return DeferredError(ex)