|
12 | 12 | from astroid import helpers |
13 | 13 | from astroid.interpreter import objectmodel |
14 | 14 | from astroid import MANAGER |
| 15 | +from astroid import objects |
15 | 16 |
|
16 | 17 |
|
17 | 18 | LRU_CACHE = "functools.lru_cache" |
@@ -98,31 +99,8 @@ def _functools_partial_inference(node, context=None): |
98 | 99 | "wrapped function received unknown parameters" |
99 | 100 | ) |
100 | 101 |
|
101 | | - # Return a wrapped() object that can be used further for inference |
102 | | - class PartialFunction(astroid.FunctionDef): |
103 | | - |
104 | | - filled_positionals = len(call.positional_arguments[1:]) |
105 | | - filled_keywords = list(call.keyword_arguments) |
106 | | - |
107 | | - def infer_call_result(self, caller=None, context=None): |
108 | | - nonlocal call |
109 | | - filled_args = call.positional_arguments[1:] |
110 | | - filled_keywords = call.keyword_arguments |
111 | | - |
112 | | - if context: |
113 | | - current_passed_keywords = { |
114 | | - keyword for (keyword, _) in context.callcontext.keywords |
115 | | - } |
116 | | - for keyword, value in filled_keywords.items(): |
117 | | - if keyword not in current_passed_keywords: |
118 | | - context.callcontext.keywords.append((keyword, value)) |
119 | | - |
120 | | - call_context_args = context.callcontext.args or [] |
121 | | - context.callcontext.args = filled_args + call_context_args |
122 | | - |
123 | | - return super().infer_call_result(caller=caller, context=context) |
124 | | - |
125 | | - partial_function = PartialFunction( |
| 102 | + partial_function = objects.PartialFunction( |
| 103 | + call, |
126 | 104 | name=inferred_wrapped_function.name, |
127 | 105 | doc=inferred_wrapped_function.doc, |
128 | 106 | lineno=inferred_wrapped_function.lineno, |
|
0 commit comments