stdlib: Use pos-only parameters for many Protocols (#10985)

This commit is contained in:
Jelle Zijlstra
2023-11-06 09:09:04 -08:00
committed by GitHub
parent a5c1a4cd3f
commit 5030b7419b
9 changed files with 14 additions and 14 deletions

View File

@@ -11,7 +11,7 @@ from typing import Any, Protocol
from typing_extensions import TypeAlias
class _Readable(Protocol):
def read(self, size: int = ...) -> bytes: ...
def read(self, __size: int = ...) -> bytes: ...
# Optional: def close(self) -> object: ...
if sys.version_info >= (3, 11):

View File

@@ -4,6 +4,6 @@ from typing import Any, Protocol
# As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects
class DOMImplementation(Protocol):
def hasFeature(self, feature: str, version: str | None) -> bool: ...
def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Any | None) -> Any: ...
def createDocumentType(self, qualifiedName: str, publicId: str, systemId: str) -> Any: ...
def hasFeature(self, __feature: str, __version: str | None) -> bool: ...
def createDocument(self, __namespaceUri: str, __qualifiedName: str, __doctype: Any | None) -> Any: ...
def createDocumentType(self, __qualifiedName: str, __publicId: str, __systemId: str) -> Any: ...

View File

@@ -120,7 +120,7 @@ class _ActionsContainer:
def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> None: ...
class _FormatterClass(Protocol):
def __call__(self, prog: str) -> HelpFormatter: ...
def __call__(self, *, prog: str) -> HelpFormatter: ...
class ArgumentParser(_AttributeHolder, _ActionsContainer):
prog: str

View File

@@ -6,7 +6,7 @@ from typing import Any, Protocol
__all__ = ["compile_dir", "compile_file", "compile_path"]
class _SupportsSearch(Protocol):
def search(self, string: str) -> Any: ...
def search(self, __string: str) -> Any: ...
if sys.version_info >= (3, 10):
def compile_dir(

View File

@@ -143,9 +143,9 @@ if sys.version_info >= (3, 8):
class _HeaderParser(Protocol):
max_count: ClassVar[Literal[1] | None]
@staticmethod
def value_parser(value: str) -> TokenList: ...
def value_parser(__value: str) -> TokenList: ...
@classmethod
def parse(cls, value: str, kwds: dict[str, Any]) -> None: ...
def parse(cls, __value: str, __kwds: dict[str, Any]) -> None: ...
class HeaderRegistry:
registry: dict[str, type[_HeaderParser]]

View File

@@ -6,8 +6,8 @@ __all__ = ["what"]
class _ReadableBinary(Protocol):
def tell(self) -> int: ...
def read(self, size: int) -> bytes: ...
def seek(self, offset: int) -> Any: ...
def read(self, __size: int) -> bytes: ...
def seek(self, __offset: int) -> Any: ...
@overload
def what(file: StrPath | _ReadableBinary, h: None = None) -> str | None: ...

View File

@@ -45,7 +45,7 @@ class _FileLike(Protocol):
def read(self) -> str | bytes: ...
def close(self) -> Any: ...
def __enter__(self) -> Any: ...
def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> Any: ...
def __exit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: TracebackType | None) -> Any: ...
# PathLike doesn't work for the pathname argument here
def load_source(name: str, pathname: str, file: _FileLike | None = None) -> types.ModuleType: ...

View File

@@ -138,10 +138,10 @@ if sys.version_info >= (3, 9):
# which is not the case.
@overload
@abstractmethod
def open(self, mode: Literal["r", "w"] = "r", *, encoding: str | None = None, errors: str | None = None) -> IO[str]: ...
def open(self, __mode: Literal["r", "w"] = "r", *, encoding: str | None = None, errors: str | None = None) -> IO[str]: ...
@overload
@abstractmethod
def open(self, mode: Literal["rb", "wb"]) -> IO[bytes]: ...
def open(self, __mode: Literal["rb", "wb"]) -> IO[bytes]: ...
@property
@abstractmethod
def name(self) -> str: ...

View File

@@ -335,7 +335,7 @@ class SimpleNamespace:
def __delattr__(self, __name: str) -> None: ...
class _LoaderProtocol(Protocol):
def load_module(self, fullname: str) -> ModuleType: ...
def load_module(self, __fullname: str) -> ModuleType: ...
class ModuleType:
__name__: str