From a5d5dcc4f44c5ddef5b0a7b8ac5265a9a59587b5 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 28 Apr 2016 11:53:51 +0100 Subject: [PATCH] Fixes to os.environ (#172) Add os.environ.copy() to Python 2 stubs. Fix return type of os.environ.copy(). --- stdlib/2.7/os/__init__.pyi | 10 ++++++++-- stdlib/3/os/__init__.pyi | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/stdlib/2.7/os/__init__.pyi b/stdlib/2.7/os/__init__.pyi index 8a71f72e7..5c10abd5e 100644 --- a/stdlib/2.7/os/__init__.pyi +++ b/stdlib/2.7/os/__init__.pyi @@ -1,11 +1,17 @@ # created from https://docs.python.org/2/library/os.html -from typing import List, Tuple, Union, Sequence, Mapping, IO, Any, Optional, AnyStr, MutableMapping, Iterator +from typing import ( + List, Tuple, Union, Sequence, Mapping, IO, Any, Optional, AnyStr, Iterator, MutableMapping +) import os.path as path error = OSError name = ... # type: str -environ = ... # type: MutableMapping[str, str] + +class _Environ(MutableMapping[str, str]): + def copy(self) -> Dict[str, str]: ... + +environ = ... # type: _Environ def chdir(path: unicode) -> None: ... def fchdir(fd: int) -> None: ... diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index 0abf31323..4352a12f3 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -62,7 +62,7 @@ W_OK = 0 X_OK = 0 class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]): - def copy(self) -> _Environ[AnyStr]: ... + def copy(self) -> Dict[AnyStr, AnyStr]: ... environ = ... # type: _Environ[str] environb = ... # type: _Environ[bytes]