File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 13
13
AnyType ,
14
14
CallableType ,
15
15
Instance ,
16
+ Overloaded ,
16
17
Type ,
17
18
TypeOfAny ,
18
19
UnboundType ,
@@ -124,6 +125,9 @@ def partial_new_callback(ctx: mypy.plugin.FunctionContext) -> Type:
124
125
if len (ctx .arg_types [0 ]) != 1 :
125
126
return ctx .default_return_type
126
127
128
+ if isinstance (ctx .arg_types [0 ][0 ], Overloaded ):
129
+ # TODO: handle overloads, just fall back to whatever the non-plugin code does
130
+ return ctx .default_return_type
127
131
fn_type = ctx .api .extract_callable_type (ctx .arg_types [0 ][0 ], ctx = ctx .default_return_type )
128
132
if fn_type is None :
129
133
return ctx .default_return_type
Original file line number Diff line number Diff line change @@ -261,6 +261,23 @@ def main2(f: CallbackProto) -> None:
261
261
p("a") # E: Argument 1 to "__call__" of "CallbackProto" has incompatible type "str"; expected "int"
262
262
[builtins fixtures/dict.pyi]
263
263
264
+ [case testFunctoolsPartialOverload]
265
+ from typing import overload
266
+ import functools
267
+
268
+ @overload
269
+ def foo(a: int, b: str) -> int: ...
270
+ @overload
271
+ def foo(a: str, b: int) -> str: ...
272
+ def foo(*a, **k): ...
273
+
274
+ p1 = functools.partial(foo)
275
+ reveal_type(p1(1, "a")) # N: Revealed type is "builtins.int"
276
+ reveal_type(p1("a", 1)) # N: Revealed type is "builtins.int"
277
+ p1(1, 2) # TODO: false negative
278
+ p1("a", "b") # TODO: false negative
279
+ [builtins fixtures/dict.pyi]
280
+
264
281
[case testFunctoolsPartialTypeGuard]
265
282
import functools
266
283
from typing_extensions import TypeGuard
You can’t perform that action at this time.
0 commit comments