Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/PIL/_util.py: 79%
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
4from typing import Any, NoReturn
6from ._typing import StrOrBytesPath, TypeGuard
9def is_path(f: Any) -> TypeGuard[StrOrBytesPath]:
10 return isinstance(f, (bytes, str, os.PathLike))
13class DeferredError:
14 def __init__(self, ex: BaseException):
15 self.ex = ex
17 def __getattr__(self, elt: str) -> NoReturn:
18 raise self.ex
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)