Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.10/site-packages/astroid/typing.py: 86%

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

28 statements  

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 

4 

5from __future__ import annotations 

6 

7from collections.abc import Callable, Generator 

8from typing import ( 

9 TYPE_CHECKING, 

10 Any, 

11 Generic, 

12 Protocol, 

13 TypedDict, 

14 TypeVar, 

15 Union, 

16) 

17 

18if TYPE_CHECKING: 

19 from collections.abc import Iterator 

20 

21 from astroid import bases, exceptions, nodes, transforms, util 

22 from astroid.context import InferenceContext 

23 from astroid.interpreter._import import spec 

24 

25 

26class InferenceErrorInfo(TypedDict): 

27 """Store additional Inference error information 

28 raised with StopIteration exception. 

29 """ 

30 

31 node: nodes.NodeNG 

32 context: InferenceContext | None 

33 

34 

35class AstroidManagerBrain(TypedDict): 

36 """Dictionary to store relevant information for a AstroidManager class.""" 

37 

38 astroid_cache: dict[str, nodes.Module] 

39 _mod_file_cache: dict[ 

40 tuple[str, str | None], spec.ModuleSpec | exceptions.AstroidImportError 

41 ] 

42 _failed_import_hooks: list[Callable[[str], nodes.Module]] 

43 always_load_extensions: bool 

44 optimize_ast: bool 

45 max_inferable_values: int 

46 extension_package_whitelist: set[str] 

47 _transform: transforms.TransformVisitor 

48 

49 

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) 

60 

61ConstFactoryResult = Union[ 

62 "nodes.List", 

63 "nodes.Set", 

64 "nodes.Tuple", 

65 "nodes.Dict", 

66 "nodes.Const", 

67 "nodes.EmptyNode", 

68] 

69 

70InferBinaryOp = Callable[ 

71 [ 

72 _SuccessfulInferenceResultT, 

73 Union["nodes.AugAssign", "nodes.BinOp"], 

74 str, 

75 InferenceResult, 

76 "InferenceContext", 

77 SuccessfulInferenceResult, 

78 ], 

79 Generator[InferenceResult], 

80] 

81 

82 

83class InferFn(Protocol, Generic[_SuccessfulInferenceResultT_contra]): 

84 def __call__( 

85 self, 

86 node: _SuccessfulInferenceResultT_contra, 

87 context: InferenceContext | None = None, 

88 **kwargs: Any, 

89 ) -> Iterator[InferenceResult]: ... # pragma: no cover 

90 

91 

92class TransformFn(Protocol, Generic[_SuccessfulInferenceResultT]): 

93 def __call__( 

94 self, 

95 node: _SuccessfulInferenceResultT, 

96 infer_function: InferFn[_SuccessfulInferenceResultT] = ..., 

97 ) -> _SuccessfulInferenceResultT | None: ... # pragma: no cover