Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/astroid/typing.py: 83%
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
1# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
2# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
3# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
5from __future__ import annotations
7from collections.abc import Callable, Generator
8from typing import (
9 TYPE_CHECKING,
10 Generic,
11 Protocol,
12 TypedDict,
13 TypeVar,
14 Union,
15)
17if TYPE_CHECKING:
18 from collections.abc import Iterator
20 from astroid import bases, exceptions, nodes, transforms, util
21 from astroid.context import InferenceContext
22 from astroid.interpreter._import import spec
25class InferenceErrorInfo(TypedDict):
26 """Store additional Inference error information
27 raised with StopIteration exception.
28 """
30 node: nodes.NodeNG
31 context: InferenceContext | None
34class AstroidManagerBrain(TypedDict):
35 """Dictionary to store relevant information for a AstroidManager class."""
37 astroid_cache: dict[str, nodes.Module]
38 _mod_file_cache: dict[
39 tuple[str, str | None], spec.ModuleSpec | exceptions.AstroidImportError
40 ]
41 _failed_import_hooks: list[Callable[[str], nodes.Module]]
42 always_load_extensions: bool
43 optimize_ast: bool
44 max_inferable_values: int
45 extension_package_whitelist: set[str]
46 _transform: transforms.TransformVisitor
49# pylint: disable=consider-alternative-union-syntax
50InferenceResult = Union["nodes.NodeNG", "util.UninferableBase", "bases.Proxy"]
51SuccessfulInferenceResult = Union["nodes.NodeNG", "bases.Proxy"]
52_SuccessfulInferenceResultT = TypeVar(
53 "_SuccessfulInferenceResultT", bound=SuccessfulInferenceResult
54)
55_SuccessfulInferenceResultT_contra = TypeVar(
56 "_SuccessfulInferenceResultT_contra",
57 bound=SuccessfulInferenceResult,
58 contravariant=True,
59)
61ConstFactoryResult = Union[
62 "nodes.List",
63 "nodes.Set",
64 "nodes.Tuple",
65 "nodes.Dict",
66 "nodes.Const",
67 "nodes.EmptyNode",
68]
70InferBinaryOp = Callable[
71 [
72 _SuccessfulInferenceResultT,
73 Union["nodes.AugAssign", "nodes.BinOp"],
74 str,
75 InferenceResult,
76 "InferenceContext",
77 SuccessfulInferenceResult,
78 ],
79 Generator[InferenceResult],
80]
83class InferFn(Protocol, Generic[_SuccessfulInferenceResultT_contra]):
84 def __call__(
85 self,
86 node: _SuccessfulInferenceResultT_contra,
87 context: InferenceContext | None = None,
88 ) -> Iterator[InferenceResult]: ... # pragma: no cover
91class TransformFn(Protocol, Generic[_SuccessfulInferenceResultT]):
92 def __call__(
93 self,
94 node: _SuccessfulInferenceResultT,
95 infer_function: InferFn[_SuccessfulInferenceResultT] = ...,
96 ) -> _SuccessfulInferenceResultT | None: ... # pragma: no cover