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
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
1from __future__ import annotations
3import os
5TYPE_CHECKING = False
6if TYPE_CHECKING:
7 from typing import Any, NoReturn, TypeGuard
9 from ._typing import StrOrBytesPath
12def is_path(f: Any) -> TypeGuard[StrOrBytesPath]:
13 return isinstance(f, (bytes, str, os.PathLike))
16class DeferredError:
17 def __init__(self, ex: BaseException):
18 self.ex = ex
20 def __getattr__(self, elt: str) -> NoReturn:
21 raise self.ex
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)