From fee871a8a1b3271b272a88ce629adf954124d947 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 17 Oct 2024 06:49:20 -0700 Subject: [PATCH 1/2] unittest: make protocol parameter positional-only unittest only calls this positionally. From PyCQA/flake8-pyi#442. --- stdlib/unittest/runner.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index 46da85619d30..958482956460 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -13,7 +13,7 @@ class _SupportsWriteAndFlush(SupportsWrite[str], SupportsFlush, Protocol): ... # All methods used by unittest.runner.TextTestResult's stream class _TextTestStream(_SupportsWriteAndFlush, Protocol): - def writeln(self, arg: str | None = None) -> str: ... + def writeln(self, arg: str | None = None, /) -> str: ... # _WritelnDecorator should have all the same attrs as its stream param. # But that's not feasible to do Generically From 6fd00b10e521d3556b1ccfdfe013f7002137508b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 17 Oct 2024 06:54:05 -0700 Subject: [PATCH 2/2] not pos-only in concrete class --- stdlib/unittest/runner.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index 958482956460..be546f42315e 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -20,6 +20,7 @@ class _TextTestStream(_SupportsWriteAndFlush, Protocol): # We can expand the attributes if requested class _WritelnDecorator(_TextTestStream): def __init__(self, stream: _TextTestStream) -> None: ... + def writeln(self, arg: str | None = None) -> str: ... def __getattr__(self, attr: str) -> Any: ... # Any attribute from the stream type passed to __init__ # These attributes are prevented by __getattr__ stream: Never