77"""Astroid hooks for understanding functools library module."""
88from functools import partial
99from itertools import chain
10+ from typing import Iterator , Optional
1011
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
1214from astroid .exceptions import InferenceError , UseInferenceDefault
1315from astroid .inference_tip import inference_tip
1416from astroid .interpreter import objectmodel
@@ -62,7 +64,9 @@ def _transform_lru_cache(node, context=None) -> None:
6264 node .special_attributes = LruWrappedModel ()(node )
6365
6466
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 ]:
6670 call = arguments .CallSite .from_call (node , context = context )
6771 number_of_positional = len (call .positional_arguments )
6872 if number_of_positional < 1 :
@@ -101,7 +105,6 @@ def _functools_partial_inference(node, context=None):
101105 partial_function = objects .PartialFunction (
102106 call ,
103107 name = inferred_wrapped_function .name ,
104- doc = inferred_wrapped_function .doc ,
105108 lineno = inferred_wrapped_function .lineno ,
106109 col_offset = inferred_wrapped_function .col_offset ,
107110 parent = node .parent ,
@@ -113,6 +116,7 @@ def _functools_partial_inference(node, context=None):
113116 returns = inferred_wrapped_function .returns ,
114117 type_comment_returns = inferred_wrapped_function .type_comment_returns ,
115118 type_comment_args = inferred_wrapped_function .type_comment_args ,
119+ doc_node = inferred_wrapped_function .doc_node ,
116120 )
117121 return iter ((partial_function ,))
118122
0 commit comments