Coverage for linuxpy/types.py: 83%
33 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-10-18 07:40 +0200
« prev ^ index » next coverage.py v7.6.1, created at 2024-10-18 07:40 +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+ 12 ↛ 13line 12 didn't jump to line 13 because the condition on line 12 was never true
13 Self = typing.Self
14else:
15 import typing_extensions
17 Self = typing_extensions.Self
19if hasattr(collections.abc, "Buffer"): # 3.12+ 19 ↛ 20line 19 didn't jump to line 20 because the condition on line 19 was never true
20 Buffer = collections.abc.Buffer
21else:
22 import typing_extensions
24 Buffer = typing_extensions.Buffer
26if hasattr(typing, "TypeAlias"): # 3.11+ 26 ↛ 27line 26 didn't jump to line 27 because the condition on line 26 was never true
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: ... 39 ↛ exitline 39 didn't jump to line 39 because
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")