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

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

27 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 typing import ( 

8 TYPE_CHECKING, 

9 Any, 

10 Callable, 

11 Generator, 

12 Generic, 

13 Protocol, 

14 TypedDict, 

15 TypeVar, 

16 Union, 

17) 

18 

19if TYPE_CHECKING: 

20 from collections.abc import Iterator 

21 

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

23 from astroid.context import InferenceContext 

24 from astroid.interpreter._import import spec 

25 

26 

27class InferenceErrorInfo(TypedDict): 

28 """Store additional Inference error information 

29 raised with StopIteration exception. 

30 """ 

31 

32 node: nodes.NodeNG 

33 context: InferenceContext | None 

34 

35 

36class AstroidManagerBrain(TypedDict): 

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

38 

39 astroid_cache: dict[str, nodes.Module] 

40 _mod_file_cache: dict[ 

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

42 ] 

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

44 always_load_extensions: bool 

45 optimize_ast: bool 

46 max_inferable_values: int 

47 extension_package_whitelist: set[str] 

48 _transform: transforms.TransformVisitor 

49 

50 

51InferenceResult = Union["nodes.NodeNG", "util.UninferableBase", "bases.Proxy"] 

52SuccessfulInferenceResult = Union["nodes.NodeNG", "bases.Proxy"] 

53_SuccessfulInferenceResultT = TypeVar( 

54 "_SuccessfulInferenceResultT", bound=SuccessfulInferenceResult 

55) 

56_SuccessfulInferenceResultT_contra = TypeVar( 

57 "_SuccessfulInferenceResultT_contra", 

58 bound=SuccessfulInferenceResult, 

59 contravariant=True, 

60) 

61 

62ConstFactoryResult = Union[ 

63 "nodes.List", 

64 "nodes.Set", 

65 "nodes.Tuple", 

66 "nodes.Dict", 

67 "nodes.Const", 

68 "nodes.EmptyNode", 

69] 

70 

71InferBinaryOp = Callable[ 

72 [ 

73 _SuccessfulInferenceResultT, 

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

75 str, 

76 InferenceResult, 

77 "InferenceContext", 

78 SuccessfulInferenceResult, 

79 ], 

80 Generator[InferenceResult, None, None], 

81] 

82 

83 

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

85 def __call__( 

86 self, 

87 node: _SuccessfulInferenceResultT_contra, 

88 context: InferenceContext | None = None, 

89 **kwargs: Any, 

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

91 

92 

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

94 def __call__( 

95 self, 

96 node: _SuccessfulInferenceResultT, 

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

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