Skip to content

Commit 42631be

Browse files
committed
prefer version with any
1 parent 85857d4 commit 42631be

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

mypy/join.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ def visit_callable_type(self, t: CallableType) -> ProperType:
414414
# We don't want to return unusable Callable, attempt fallback instead.
415415
return join_types(t.fallback, self.s)
416416
else:
417+
s, t = self.s, t
418+
if s.min_args < t.min_args:
419+
s, t = t, s
417420
if is_subtype(self.s, t):
418421
result = t.copy_modified()
419422
elif is_subtype(t, self.s):

test-data/unit/check-functions.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3499,12 +3499,12 @@ def f_any(*_, **__): ...
34993499
def f_3(common, b=None, x=None): ...
35003500

35013501
fdict = {
3502-
"f_1": f_1, # E: Dict entry 0 has incompatible type "str": "Callable[[Any, Any], Any]"; expected "str": "Callable[[Any, Any, Any], Any]"
3502+
"f_1": f_1,
35033503
"f_any": f_any,
35043504
"f_3": f_3,
35053505
}
3506-
reveal_type(fdict) # N: Revealed type is "builtins.dict[builtins.str, def (common: Any, b: Any =, x: Any =) -> Any]"
3506+
reveal_type(fdict) # N: Revealed type is "builtins.dict[builtins.str, def (*_: Any, **__: Any) -> Any]"
3507+
3508+
reveal_type(join(f_1, f_any, f_3)) # N: Revealed type is "def (*_: Any, **__: Any) -> Any"
35073509

3508-
reveal_type(join(f_1, f_any, f_3)) # N: Revealed type is "def (common: Any, b: Any =, x: Any =) -> Any" \
3509-
# E: Argument 1 to "join" has incompatible type "Callable[[Any, Any], Any]"; expected "Callable[[Any, Any, Any], Any]"
35103510
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)