summaryrefslogtreecommitdiff
path: root/astroid/brain/brain_functools.py
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-03-07 00:25:51 +0100
committerGitHub <noreply@github.com>2022-03-07 00:25:51 +0100
commit17387a53960e8532887e885b3ca920e427757bcb (patch)
treeeea8a2bf6c9c64ea19196eef2ed8e34b423e25e5 /astroid/brain/brain_functools.py
parent40e1a64ad67d4613b0bef461b0227653c8f085a1 (diff)
downloadastroid-git-17387a53960e8532887e885b3ca920e427757bcb.tar.gz
Pass ``doc_node`` to postinit of all ``PartialFunction`` constructors (#1437)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Diffstat (limited to 'astroid/brain/brain_functools.py')
-rw-r--r--astroid/brain/brain_functools.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/astroid/brain/brain_functools.py b/astroid/brain/brain_functools.py
index 2126853b..e8637494 100644
--- a/astroid/brain/brain_functools.py
+++ b/astroid/brain/brain_functools.py
@@ -7,8 +7,10 @@
"""Astroid hooks for understanding functools library module."""
from functools import partial
from itertools import chain
+from typing import Iterator, Optional
-from astroid import BoundMethod, arguments, extract_node, helpers, objects
+from astroid import BoundMethod, arguments, extract_node, helpers, nodes, objects
+from astroid.context import InferenceContext
from astroid.exceptions import InferenceError, UseInferenceDefault
from astroid.inference_tip import inference_tip
from astroid.interpreter import objectmodel
@@ -62,7 +64,9 @@ def _transform_lru_cache(node, context=None) -> None:
node.special_attributes = LruWrappedModel()(node)
-def _functools_partial_inference(node, context=None):
+def _functools_partial_inference(
+ node: nodes.Call, context: Optional[InferenceContext] = None
+) -> Iterator[objects.PartialFunction]:
call = arguments.CallSite.from_call(node, context=context)
number_of_positional = len(call.positional_arguments)
if number_of_positional < 1:
@@ -101,7 +105,6 @@ def _functools_partial_inference(node, context=None):
partial_function = objects.PartialFunction(
call,
name=inferred_wrapped_function.name,
- doc=inferred_wrapped_function.doc,
lineno=inferred_wrapped_function.lineno,
col_offset=inferred_wrapped_function.col_offset,
parent=node.parent,
@@ -113,6 +116,7 @@ def _functools_partial_inference(node, context=None):
returns=inferred_wrapped_function.returns,
type_comment_returns=inferred_wrapped_function.type_comment_returns,
type_comment_args=inferred_wrapped_function.type_comment_args,
+ doc_node=inferred_wrapped_function.doc_node,
)
return iter((partial_function,))