Skip to content

Commit ba45818

Browse files
committed
stdlib: Use pos-only parameters for many Protocols
Some of the fallout from PyCQA/flake8-pyi#442. In each case, I looked at CPython to check how the protocol is being used.
1 parent a5c1a4c commit ba45818

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

stdlib/_typeshed/wsgi.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ from typing import Any, Protocol
1111
from typing_extensions import TypeAlias
1212

1313
class _Readable(Protocol):
14-
def read(self, size: int = ...) -> bytes: ...
14+
def read(self, __size: int = ...) -> bytes: ...
1515
# Optional: def close(self) -> object: ...
1616

1717
if sys.version_info >= (3, 11):

stdlib/_typeshed/xml.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ from typing import Any, Protocol
44

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

stdlib/argparse.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class _ActionsContainer:
120120
def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> None: ...
121121

122122
class _FormatterClass(Protocol):
123-
def __call__(self, prog: str) -> HelpFormatter: ...
123+
def __call__(self, *, prog: str) -> HelpFormatter: ...
124124

125125
class ArgumentParser(_AttributeHolder, _ActionsContainer):
126126
prog: str

stdlib/codecs.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ class _StreamWriter(Protocol):
9090
def __call__(self, __stream: _WritableStream, __errors: str = ...) -> StreamWriter: ...
9191

9292
class _IncrementalEncoder(Protocol):
93-
def __call__(self, errors: str = ...) -> IncrementalEncoder: ...
93+
def __call__(self, __errors: str = ...) -> IncrementalEncoder: ...
9494

9595
class _IncrementalDecoder(Protocol):
96-
def __call__(self, errors: str = ...) -> IncrementalDecoder: ...
96+
def __call__(self, __errors: str = ...) -> IncrementalDecoder: ...
9797

9898
class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
9999
_is_text_encoding: bool

stdlib/compileall.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from typing import Any, Protocol
66
__all__ = ["compile_dir", "compile_file", "compile_path"]
77

88
class _SupportsSearch(Protocol):
9-
def search(self, string: str) -> Any: ...
9+
def search(self, __string: str) -> Any: ...
1010

1111
if sys.version_info >= (3, 10):
1212
def compile_dir(

stdlib/email/headerregistry.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ if sys.version_info >= (3, 8):
143143
class _HeaderParser(Protocol):
144144
max_count: ClassVar[Literal[1] | None]
145145
@staticmethod
146-
def value_parser(value: str) -> TokenList: ...
146+
def value_parser(__value: str) -> TokenList: ...
147147
@classmethod
148-
def parse(cls, value: str, kwds: dict[str, Any]) -> None: ...
148+
def parse(cls, __value: str, __kwds: dict[str, Any]) -> None: ...
149149

150150
class HeaderRegistry:
151151
registry: dict[str, type[_HeaderParser]]

stdlib/imghdr.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ __all__ = ["what"]
66

77
class _ReadableBinary(Protocol):
88
def tell(self) -> int: ...
9-
def read(self, size: int) -> bytes: ...
10-
def seek(self, offset: int) -> Any: ...
9+
def read(self, __size: int) -> bytes: ...
10+
def seek(self, __offset: int) -> Any: ...
1111

1212
@overload
1313
def what(file: StrPath | _ReadableBinary, h: None = None) -> str | None: ...

stdlib/imp.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class _FileLike(Protocol):
4545
def read(self) -> str | bytes: ...
4646
def close(self) -> Any: ...
4747
def __enter__(self) -> Any: ...
48-
def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> Any: ...
48+
def __exit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: TracebackType | None) -> Any: ...
4949

5050
# PathLike doesn't work for the pathname argument here
5151
def load_source(name: str, pathname: str, file: _FileLike | None = None) -> types.ModuleType: ...

stdlib/importlib/abc.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ if sys.version_info >= (3, 9):
138138
# which is not the case.
139139
@overload
140140
@abstractmethod
141-
def open(self, mode: Literal["r", "w"] = "r", *, encoding: str | None = None, errors: str | None = None) -> IO[str]: ...
141+
def open(self, __mode: Literal["r", "w"] = "r", *, encoding: str | None = None, errors: str | None = None) -> IO[str]: ...
142142
@overload
143143
@abstractmethod
144-
def open(self, mode: Literal["rb", "wb"]) -> IO[bytes]: ...
144+
def open(self, __mode: Literal["rb", "wb"]) -> IO[bytes]: ...
145145
@property
146146
@abstractmethod
147147
def name(self) -> str: ...

stdlib/types.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class SimpleNamespace:
335335
def __delattr__(self, __name: str) -> None: ...
336336

337337
class _LoaderProtocol(Protocol):
338-
def load_module(self, fullname: str) -> ModuleType: ...
338+
def load_module(self, __fullname: str) -> ModuleType: ...
339339

340340
class ModuleType:
341341
__name__: str

0 commit comments

Comments
 (0)