Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.rich._fileno Namespace Reference

Functions

int|None get_fileno (IO[str] file_like)
 

Function Documentation

◆ get_fileno()

int | None get_fileno ( IO[str]  file_like)
Get fileno() from a file, accounting for poorly implemented file-like objects.

Args:
    file_like (IO): A file-like object.

Returns:
    int | None: The result of fileno if available, or None if operation failed.

Definition at line 6 of file _fileno.py.

6def get_fileno(file_like: IO[str]) -> int | None:
7 """Get fileno() from a file, accounting for poorly implemented file-like objects.
8
9 Args:
10 file_like (IO): A file-like object.
11
12 Returns:
13 int | None: The result of fileno if available, or None if operation failed.
14 """
15 fileno: Callable[[], int] | None = getattr(file_like, "fileno", None)
16 if fileno is not None:
17 try:
18 return fileno()
19 except Exception:
20 # `fileno` is documented as potentially raising a OSError
21 # Alas, from the issues, there are so many poorly implemented file-like objects,
22 # that `fileno()` can raise just about anything.
23 return None
24 return None
for i

References i.