Skip to content

Commit 6dcb760

Browse files
committed
add a test case based on argparse.ArgumentParser
1 parent 8d09eca commit 6dcb760

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

mypy/test/teststubtest.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,31 @@ def func2() -> None: ...
24012401
error="func2",
24022402
)
24032403

2404+
@collect_cases
2405+
def test_type_default_protocol(self) -> Iterator[Case]:
2406+
yield Case(
2407+
stub="""
2408+
from typing import Protocol
2409+
2410+
class _FormatterClass(Protocol):
2411+
def __call__(self, *, prog: str) -> HelpFormatter: ...
2412+
2413+
class ArgumentParser:
2414+
def __init__(self, formatter_class: _FormatterClass = ...) -> None: ...
2415+
2416+
class HelpFormatter:
2417+
def __init__(self, prog: str, indent_increment: int = 2) -> None: ...
2418+
""",
2419+
runtime="""
2420+
class HelpFormatter:
2421+
def __init__(self, prog, indent_increment=2) -> None: ...
2422+
2423+
class ArgumentParser:
2424+
def __init__(self, formatter_class=HelpFormatter): ...
2425+
""",
2426+
error=None,
2427+
)
2428+
24042429

24052430
def remove_color_code(s: str) -> str:
24062431
return re.sub("\\x1b.*?m", "", s) # this works!

0 commit comments

Comments
 (0)