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

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

14 statements  

1from __future__ import annotations 

2 

3import os 

4from typing import Any, NoReturn 

5 

6from ._typing import StrOrBytesPath, TypeGuard 

7 

8 

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

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

11 

12 

13class DeferredError: 

14 def __init__(self, ex: BaseException): 

15 self.ex = ex 

16 

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

18 raise self.ex 

19 

20 @staticmethod 

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

22 """ 

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

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

25 """ 

26 return DeferredError(ex)