Skip to content

Commit 077e820

Browse files
authored
Adds explicit test for overloads with pos-only self(#11608)
See #11606 for discussion
1 parent b4256a1 commit 077e820

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test-data/unit/check-python38.test

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,3 +546,27 @@ def foo() -> None:
546546
x = 0
547547
[x := x + y for y in [1, 2, 3]]
548548
[builtins fixtures/dict.pyi]
549+
550+
[case testOverloadWithPositionalOnlySelf]
551+
from typing import overload, Optional
552+
553+
class Foo:
554+
@overload
555+
def f(self, a: str, /) -> None: ...
556+
557+
@overload
558+
def f(self, *, b: bool = False) -> None: ...
559+
560+
def f(self, a: Optional[str] = None, /, *, b: bool = False) -> None: # E: Overloaded function implementation does not accept all possible arguments of signature 2
561+
...
562+
563+
class Bar:
564+
@overload
565+
def f(self, a: str, /) -> None: ...
566+
567+
@overload # Notice `/` in sig below:
568+
def f(self, /, *, b: bool = False) -> None: ...
569+
570+
def f(self, a: Optional[str] = None, /, *, b: bool = False) -> None:
571+
...
572+
[builtins fixtures/bool.pyi]

0 commit comments

Comments
 (0)