GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Further fix overload diagnostic for vararg and varkwarg (#19619) · python/mypy@186515f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • mypy
    • typeops.py
  • test-data/unit
    • check-overloading.test
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎mypy/typeops.py‎

Copy file name to clipboardExpand all lines: mypy/typeops.py
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,16 @@ def callable_corresponding_argument(
521521

522522
# def right(a: int = ...) -> None: ...
523523
# def left(__a: int = ..., *, a: int = ...) -> None: ...
524-
from mypy.subtypes import is_subtype
524+
from mypy.meet import meet_types
525525

526526
if (
527527
not (by_name.required or by_pos.required)
528528
and by_pos.name is None
529529
and by_name.pos is None
530530
):
531-
# We actually want the intersection of by_name.typ and by_pos.typ
532-
if is_subtype(by_name.typ, by_pos.typ):
533-
return FormalArgument(by_name.name, by_pos.pos, by_name.typ, False)
534-
if is_subtype(by_pos.typ, by_name.typ):
535-
return FormalArgument(by_name.name, by_pos.pos, by_pos.typ, False)
531+
return FormalArgument(
532+
by_name.name, by_pos.pos, meet_types(by_name.typ, by_pos.typ), False
533+
)
536534
return by_name if by_name is not None else by_pos
537535

538536

Collapse file

‎test-data/unit/check-overloading.test‎

Copy file name to clipboardExpand all lines: test-data/unit/check-overloading.test
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,23 @@ def foo(*args: int | str, **kw: int) -> None:
246246
pass
247247
[builtins fixtures/tuple.pyi]
248248

249+
[case testTypeCheckOverloadImplOverlapVarArgsAndKwargsUnion]
250+
from __future__ import annotations
251+
from typing import overload
252+
253+
class Foo: ...
254+
255+
@overload
256+
def foo(x: int) -> None: ...
257+
@overload
258+
def foo(*, x: Foo) -> None: ...
259+
@overload
260+
def foo(a: str, /) -> None: ...
261+
262+
def foo(*args: int | str, **kw: int | Foo) -> None:
263+
pass
264+
[builtins fixtures/tuple.pyi]
265+
249266
[case testTypeCheckOverloadWithImplTooSpecificRetType]
250267
from typing import overload, Any
251268

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.