unittest: make protocol parameter positional-only (#12834)

This commit is contained in:
Jelle Zijlstra
2024-10-17 07:55:50 -07:00
committed by GitHub
parent b78b3f10ba
commit a2ee32ba5d

View File

@@ -13,13 +13,14 @@ 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
# 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