From 24c843fbc47ba6e4fef92b4c4f3c2b4904686de4 Mon Sep 17 00:00:00 2001
From: Jelle Zijlstra
Date: Wed, 28 Mar 2018 19:47:18 -0700
Subject: [PATCH] add more minor 3.7 new features
part of #1965
---
stdlib/2and3/hmac.pyi | 3 +++
stdlib/2and3/locale.pyi | 8 ++++++--
stdlib/2and3/math.pyi | 2 ++
stdlib/3/http/client.pyi | 9 ++++++++-
stdlib/3/http/server.pyi | 12 ++++++++++--
5 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/stdlib/2and3/hmac.pyi b/stdlib/2and3/hmac.pyi
index 9be9cf1c8547..830d53ecb5db 100644
--- a/stdlib/2and3/hmac.pyi
+++ b/stdlib/2and3/hmac.pyi
@@ -35,3 +35,6 @@ def compare_digest(a: str, b: str) -> bool: ...
def compare_digest(a: bytes, b: bytes) -> bool: ...
@overload
def compare_digest(a: bytearray, b: bytearray) -> bool: ...
+
+if sys.version_info >= (3, 7):
+ def digest(key: _B, msg: _B, digest: str) -> bytes: ...
diff --git a/stdlib/2and3/locale.pyi b/stdlib/2and3/locale.pyi
index 59ac3c45217c..73ed0c759d7b 100644
--- a/stdlib/2and3/locale.pyi
+++ b/stdlib/2and3/locale.pyi
@@ -94,8 +94,12 @@ def strcoll(string1: _str, string2: _str) -> int: ...
def strxfrm(string: _str) -> _str: ...
def format(format: _str, val: Union[float, Decimal], grouping: bool = ...,
monetary: bool = ...) -> _str: ...
-def format_string(format: _str, val: Sequence[Any],
- grouping: bool = ...) -> _str: ...
+if sys.version_info >= (3, 7):
+ def format_string(format: _str, val: Sequence[Any],
+ grouping: bool = ..., monetary: bool = ...) -> _str: ...
+else:
+ def format_string(format: _str, val: Sequence[Any],
+ grouping: bool = ...) -> _str: ...
def currency(val: int, symbol: bool = ..., grouping: bool = ...,
international: bool = ...) -> _str: ...
if sys.version_info >= (3, 5):
diff --git a/stdlib/2and3/math.pyi b/stdlib/2and3/math.pyi
index a4fc306f7f52..92ea4ba69ada 100644
--- a/stdlib/2and3/math.pyi
+++ b/stdlib/2and3/math.pyi
@@ -61,6 +61,8 @@ if sys.version_info >= (3, 3):
def modf(x: float) -> Tuple[float, float]: ...
def pow(x: float, y: float) -> float: ...
def radians(x: float) -> float: ...
+if sys.version_info >= (3, 7):
+ def remainder(x: float, y: float) -> float: ...
def sin(x: float) -> float: ...
def sinh(x: float) -> float: ...
def sqrt(x: float) -> float: ...
diff --git a/stdlib/3/http/client.pyi b/stdlib/3/http/client.pyi
index 9cd46574669a..6bf90c9a2204 100644
--- a/stdlib/3/http/client.pyi
+++ b/stdlib/3/http/client.pyi
@@ -125,7 +125,14 @@ else:
exc_tb: Optional[types.TracebackType]) -> bool: ...
class HTTPConnection:
- if sys.version_info >= (3, 4):
+ if sys.version_info >= (3, 7):
+ def __init__(
+ self,
+ host: str, port: Optional[int] = ...,
+ timeout: int = ...,
+ source_address: Optional[Tuple[str, int]] = ..., blocksize: int = ...
+ ) -> None: ...
+ elif sys.version_info >= (3, 4):
def __init__(
self,
host: str, port: Optional[int] = ...,
diff --git a/stdlib/3/http/server.pyi b/stdlib/3/http/server.pyi
index 2f1d0c2a345c..2e610e547135 100644
--- a/stdlib/3/http/server.pyi
+++ b/stdlib/3/http/server.pyi
@@ -1,9 +1,13 @@
# Stubs for http.server (Python 3.4)
+import sys
from typing import Any, BinaryIO, Dict, List, Mapping, Optional, Tuple, Union
import socketserver
import email.message
+if sys.version_info >= (3, 7):
+ from builtins import _PathLike
+
class HTTPServer(socketserver.TCPServer):
server_name = ... # type: str
server_port = ... # type: int
@@ -53,8 +57,12 @@ class BaseHTTPRequestHandler:
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
extensions_map = ... # type: Dict[str, str]
- def __init__(self, request: bytes, client_address: Tuple[str, int],
- server: socketserver.BaseServer) -> None: ...
+ if sys.version_info >= (3, 7):
+ def __init__(self, request: bytes, client_address: Tuple[str, int],
+ server: socketserver.BaseServer, directory: Optional[Union[str, _PathLike[str]]]) -> None: ...
+ else:
+ def __init__(self, request: bytes, client_address: Tuple[str, int],
+ server: socketserver.BaseServer) -> None: ...
def do_GET(self) -> None: ...
def do_HEAD(self) -> None: ...