7
7
"""Astroid hooks for understanding functools library module."""
8
8
from functools import partial
9
9
from itertools import chain
10
+ from typing import Iterator , Optional
10
11
11
- from astroid import BoundMethod , arguments , extract_node , helpers , objects
12
+ from astroid import BoundMethod , arguments , extract_node , helpers , nodes , objects
13
+ from astroid .context import InferenceContext
12
14
from astroid .exceptions import InferenceError , UseInferenceDefault
13
15
from astroid .inference_tip import inference_tip
14
16
from astroid .interpreter import objectmodel
@@ -62,7 +64,9 @@ def _transform_lru_cache(node, context=None) -> None:
62
64
node .special_attributes = LruWrappedModel ()(node )
63
65
64
66
65
- def _functools_partial_inference (node , context = None ):
67
+ def _functools_partial_inference (
68
+ node : nodes .Call , context : Optional [InferenceContext ] = None
69
+ ) -> Iterator [objects .PartialFunction ]:
66
70
call = arguments .CallSite .from_call (node , context = context )
67
71
number_of_positional = len (call .positional_arguments )
68
72
if number_of_positional < 1 :
@@ -101,7 +105,6 @@ def _functools_partial_inference(node, context=None):
101
105
partial_function = objects .PartialFunction (
102
106
call ,
103
107
name = inferred_wrapped_function .name ,
104
- doc = inferred_wrapped_function .doc ,
105
108
lineno = inferred_wrapped_function .lineno ,
106
109
col_offset = inferred_wrapped_function .col_offset ,
107
110
parent = node .parent ,
@@ -113,6 +116,7 @@ def _functools_partial_inference(node, context=None):
113
116
returns = inferred_wrapped_function .returns ,
114
117
type_comment_returns = inferred_wrapped_function .type_comment_returns ,
115
118
type_comment_args = inferred_wrapped_function .type_comment_args ,
119
+ doc_node = inferred_wrapped_function .doc_node ,
116
120
)
117
121
return iter ((partial_function ,))
118
122
0 commit comments