From d1da44dc1bbf6cbd4d57d000aad959ffd4a41e85 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2017 08:07:59 -0700 Subject: [PATCH] add bytes.__mod__ (#1212) Fixes python/mypy#3247 Also reviewed some related logic: - __mod__ was added to both bytes and bytearray with PEP 461, which went into 3.5 - str.__mod__ takes only one argument, and the signature calls it "value" - In Python 2, bytearray doesn't have __mod__ (and typeshed correctly omits it) --- stdlib/3/builtins.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 5264f22c4..3cd9da463 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -287,7 +287,7 @@ class str(Sequence[str]): def __add__(self, s: str) -> str: ... def __mul__(self, n: int) -> str: ... def __rmul__(self, n: int) -> str: ... - def __mod__(self, *args: Any) -> str: ... + def __mod__(self, value: Any) -> str: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: str) -> bool: ... @@ -388,6 +388,8 @@ class bytes(ByteString): def __add__(self, s: bytes) -> bytes: ... def __mul__(self, n: int) -> bytes: ... def __rmul__(self, n: int) -> bytes: ... + if sys.version_info >= (3, 5): + def __mod__(self, value: Any) -> bytes: ... def __contains__(self, o: object) -> bool: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... @@ -485,6 +487,8 @@ class bytearray(MutableSequence[int], ByteString): def __mul__(self, n: int) -> bytearray: ... def __rmul__(self, n: int) -> bytearray: ... def __imul__(self, n: int) -> bytearray: ... + if sys.version_info >= (3, 5): + def __mod__(self, value: Any) -> bytes: ... def __contains__(self, o: object) -> bool: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ...