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

27 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:53 +0000

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 astroid import bases, exceptions, nodes, transforms, util 

21 from astroid.context import InferenceContext 

22 from astroid.interpreter._import import spec 

23 

24 

25class InferenceErrorInfo(TypedDict): 

26 """Store additional Inference error information 

27 raised with StopIteration exception. 

28 """ 

29 

30 node: nodes.NodeNG 

31 context: InferenceContext | None 

32 

33 

34class AstroidManagerBrain(TypedDict): 

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

36 

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 extension_package_whitelist: set[str] 

45 _transform: transforms.TransformVisitor 

46 

47 

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

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

50_SuccessfulInferenceResultT = TypeVar( 

51 "_SuccessfulInferenceResultT", bound=SuccessfulInferenceResult 

52) 

53_SuccessfulInferenceResultT_contra = TypeVar( 

54 "_SuccessfulInferenceResultT_contra", 

55 bound=SuccessfulInferenceResult, 

56 contravariant=True, 

57) 

58 

59ConstFactoryResult = Union[ 

60 "nodes.List", 

61 "nodes.Set", 

62 "nodes.Tuple", 

63 "nodes.Dict", 

64 "nodes.Const", 

65 "nodes.EmptyNode", 

66] 

67 

68InferBinaryOp = Callable[ 

69 [ 

70 _SuccessfulInferenceResultT, 

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

72 str, 

73 InferenceResult, 

74 "InferenceContext", 

75 SuccessfulInferenceResult, 

76 ], 

77 Generator[InferenceResult, None, None], 

78] 

79 

80 

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

82 def __call__( 

83 self, 

84 node: _SuccessfulInferenceResultT_contra, 

85 context: InferenceContext | None = None, 

86 **kwargs: Any, 

87 ) -> Generator[InferenceResult, None, None]: 

88 ... # pragma: no cover 

89 

90 

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

92 def __call__( 

93 self, 

94 node: _SuccessfulInferenceResultT, 

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

96 ) -> _SuccessfulInferenceResultT | None: 

97 ... # pragma: no cover