From 5ebf59f698703a9a8f709108cce41f43c91df7ab Mon Sep 17 00:00:00 2001 From: Bluebottle Date: Sat, 17 Aug 2019 20:42:00 +0100 Subject: [PATCH 1/2] Add stubs for CGIHTTPServer This commit adds: * Stubs for CGIHTTPServer in the Python 2 standard library, as requested in #1147. * Stubs for six.moves.CGIHTTPServer in Python 2, as requested in #22. --- stdlib/2/CGIHTTPServer.pyi | 8 ++++++++ tests/mypy_selftest.py | 2 +- third_party/2/six/moves/CGIHTTPServer.pyi | 1 + third_party/2/six/moves/__init__.pyi | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 stdlib/2/CGIHTTPServer.pyi create mode 100644 third_party/2/six/moves/CGIHTTPServer.pyi diff --git a/stdlib/2/CGIHTTPServer.pyi b/stdlib/2/CGIHTTPServer.pyi new file mode 100644 index 000000000000..4eae666d86d0 --- /dev/null +++ b/stdlib/2/CGIHTTPServer.pyi @@ -0,0 +1,8 @@ +# Stubs for CGIHTTPServer (Python 2.7) + +from typing import List +import SimpleHTTPServer + +class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): + cgi_directories: List[str] + def do_POST(self) -> None: ... diff --git a/tests/mypy_selftest.py b/tests/mypy_selftest.py index fd7f23b105bb..f0089abb62f1 100755 --- a/tests/mypy_selftest.py +++ b/tests/mypy_selftest.py @@ -11,7 +11,7 @@ if __name__ == '__main__': with tempfile.TemporaryDirectory() as tempdir: dirpath = Path(tempdir) - subprocess.run(['python2.7', '-m', 'pip', 'install', '--user', 'typing'], check=True) + subprocess.run(['/Users/bluebottle/.pyenv/versions/2.7.15/bin/python2.7', '-m', 'pip', 'install', '--user', 'typing'], check=True) subprocess.run(['git', 'clone', '--depth', '1', 'git://github.com/python/mypy', str(dirpath / 'mypy')], check=True) subprocess.run([sys.executable, '-m', 'pip', 'install', '-U', '-r', diff --git a/third_party/2/six/moves/CGIHTTPServer.pyi b/third_party/2/six/moves/CGIHTTPServer.pyi new file mode 100644 index 000000000000..b39390c67abf --- /dev/null +++ b/third_party/2/six/moves/CGIHTTPServer.pyi @@ -0,0 +1 @@ +from CGIHTTPServer import * diff --git a/third_party/2/six/moves/__init__.pyi b/third_party/2/six/moves/__init__.pyi index ade03042ca7c..2bc82cbc675b 100644 --- a/third_party/2/six/moves/__init__.pyi +++ b/third_party/2/six/moves/__init__.pyi @@ -36,7 +36,7 @@ from . import http_client from . import email_mime_text # import email.MIMEBase as email_mime_base from . import BaseHTTPServer -# import CGIHTTPServer as CGIHTTPServer +from . import CGIHTTPServer from . import SimpleHTTPServer from . import cPickle from . import queue From d4fc74a12ad1658b1a4d0d03d39b3089fa006b30 Mon Sep 17 00:00:00 2001 From: Bluebottle Date: Mon, 19 Aug 2019 07:31:55 +0100 Subject: [PATCH 2/2] Change python2.7 executable back to the default in tests/mypy_selftest.py --- tests/mypy_selftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mypy_selftest.py b/tests/mypy_selftest.py index f0089abb62f1..fd7f23b105bb 100755 --- a/tests/mypy_selftest.py +++ b/tests/mypy_selftest.py @@ -11,7 +11,7 @@ if __name__ == '__main__': with tempfile.TemporaryDirectory() as tempdir: dirpath = Path(tempdir) - subprocess.run(['/Users/bluebottle/.pyenv/versions/2.7.15/bin/python2.7', '-m', 'pip', 'install', '--user', 'typing'], check=True) + subprocess.run(['python2.7', '-m', 'pip', 'install', '--user', 'typing'], check=True) subprocess.run(['git', 'clone', '--depth', '1', 'git://github.com/python/mypy', str(dirpath / 'mypy')], check=True) subprocess.run([sys.executable, '-m', 'pip', 'install', '-U', '-r',