Coverage for linuxpy/types.py: 82%
33 statements
« prev ^ index » next coverage.py v7.6.8, created at 2025-05-27 13:54 +0200
« prev ^ index » next coverage.py v7.6.8, created at 2025-05-27 13:54 +0200
1#
2# This file is part of the linuxpy project
3#
4# Copyright (c) 2023 Tiago Coutinho
5# Distributed under the GPLv3 license. See LICENSE for more info.
7import collections.abc
8import os
9import pathlib
10import typing
12if hasattr(typing, "Self"): # 3.11+
13 Self = typing.Self
14else:
15 import typing_extensions
17 Self = typing_extensions.Self
19if hasattr(collections.abc, "Buffer"): # 3.12+
20 Buffer = collections.abc.Buffer
21else:
22 import typing_extensions
24 Buffer = typing_extensions.Buffer
26if hasattr(typing, "TypeAlias"): # 3.11+
27 TypeAlias = typing.TypeAlias
28else:
29 import typing_extensions
31 TypeAlias = typing_extensions.TypeAlias
33Union = typing.Union
34Optional = typing.Optional
35PathLike = Union[str, pathlib.Path, os.PathLike]
38class HasFileno(typing.Protocol):
39 def fileno(self) -> int: ...
42FD = int
43FDLike = Union[FD, HasFileno]
46Iterable = collections.abc.Iterable
47Iterator = collections.abc.Iterator
48AsyncIterable = collections.abc.AsyncIterable
49AsyncIterator = collections.abc.AsyncIterator
50Generator = typing.Generator
51Callable = collections.abc.Callable
52Sequence = collections.abc.Sequence
53Collection = collections.abc.Collection
54NamedTuple = typing.NamedTuple
56T = typing.TypeVar("T")