Merge pull request #61 from timabbott/tabbott-six

Add stubs for some of the most heavily used parts of six.moves
This commit is contained in:
Guido van Rossum
2016-01-27 09:09:10 -08:00
33 changed files with 510 additions and 50 deletions

View File

@@ -0,0 +1,7 @@
class RobotFileParser:
def set_url(self, url: str): ...
def read(self): ...
def parse(self, lines: str): ...
def can_fetch(self, user_agent: str, url: str): ...
def mtime(self): ...
def modified(self): ...

View File

@@ -1,6 +1,5 @@
# Stubs for urllib.error
# NOTE: These are incomplete!
class URLError(IOError): ...
class HTTPError(URLError): ...
class ContentTooShortError(URLError): ...

View File

@@ -19,6 +19,14 @@ __all__ = (
'unquote_to_bytes'
)
uses_relative = [] # type: List[str]
uses_netloc = [] # type: List[str]
uses_params = [] # type: List[str]
non_hierarchical = [] # type: List[str]
uses_query = [] # type: List[str]
uses_fragment = [] # type: List[str]
scheme_chars = ... # type: str
MAX_CACHE_SIZE = 0
class _ResultMixinBase(Generic[AnyStr]):
def geturl(self) -> AnyStr: ...
@@ -90,6 +98,8 @@ def unquote(string: str, encoding: str = ..., errors: str = ...) -> str: ...
def unquote_to_bytes(string: AnyStr) -> bytes: ...
def unquote_plus(string: str, encoding: str = ..., errors: str = ...) -> str: ...
@overload
def urldefrag(url: str) -> DefragResult: ...
@overload

View File

@@ -0,0 +1,32 @@
from typing import Any
class addbase:
fp = ... # type: Any
read = ... # type: Any
readline = ... # type: Any
readlines = ... # type: Any
fileno = ... # type: Any
__iter__ = ... # type: Any
next = ... # type: Any
def __init__(self, fp) -> None: ...
def close(self): ...
class addclosehook(addbase):
closehook = ... # type: Any
hookargs = ... # type: Any
def __init__(self, fp, closehook, *hookargs) -> None: ...
def close(self): ...
class addinfo(addbase):
headers = ... # type: Any
def __init__(self, fp, headers) -> None: ...
def info(self): ...
class addinfourl(addbase):
headers = ... # type: Any
url = ... # type: Any
code = ... # type: Any
def __init__(self, fp, headers, url, code=...) -> None: ...
def info(self): ...
def getcode(self): ...
def geturl(self): ...

View File

@@ -0,0 +1,7 @@
class RobotFileParser:
def set_url(self, url: str): ...
def read(self): ...
def parse(self, lines: str): ...
def can_fetch(self, user_agent: str, url: str): ...
def mtime(self): ...
def modified(self): ...

View File

@@ -1,24 +0,0 @@
# Provisional stubs for six.moves (Python 2.7)
from typing import overload, TypeVar, Tuple, Iterable, Iterator
_T1 = TypeVar('_T1')
_T2 = TypeVar('_T2')
_T3 = TypeVar('_T3')
_T4 = TypeVar('_T4')
@overload
def zip(iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2]) -> Iterator[Tuple[_T1, _T2]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3]) -> Iterator[Tuple[_T1, _T2, _T3]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2,
_T3, _T4]]: ... # TODO more than four iterables
# For re-export.
import cStringIO as cStringIO
import cPickle as cPickle

27
third_party/2.7/six/moves/__init__.pyi vendored Normal file
View File

@@ -0,0 +1,27 @@
# Provisional stubs for six.moves (Python 2.7)
from cStringIO import StringIO as cStringIO
from itertools import ifilter as filter
from itertools import ifilterfalse as filterfalse
from __builtin__ import raw_input as input
from __builtin__ import intern as intern
from itertools import imap as map
from os import getcwdu as getcwd
from os import getcwd as getcwdb
from __builtin__ import xrange as range
from __builtin__ import reload as reload_module
from __builtin__ import reduce as reduce
from pipes import quote as shlex_quote
from StringIO import StringIO as StringIO
from UserDict import UserDict as UserDict
from UserList import UserList as UserList
from UserString import UserString as UserString
from __builtin__ import xrange as xrange
from itertools import izip as zip
from itertools import izip_longest as zip_longest
import six.moves.cPickle as cPickle
import six.moves.urllib_parse as urllib_parse
import six.moves.urllib_error as urllib_error
import six.moves.urllib as urllib
import six.moves.urllib_robotparser as urllib_robotparser

6
third_party/2.7/six/moves/cPickle.pyi vendored Normal file
View File

@@ -0,0 +1,6 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.cPickle (Python 2.7)
from cPickle import *

View File

@@ -0,0 +1,10 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib (Python 2.7)
import six.moves.urllib.error as error
import six.moves.urllib.parse as parse
import six.moves.urllib.request as request
import six.moves.urllib.response as response
import six.moves.urllib.robotparser as robotparser

View File

@@ -0,0 +1,8 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.error (Python 2.7)
from urllib2 import URLError as URLError
from urllib2 import HTTPError as HTTPError
from urllib import ContentTooShortError as ContentTooShortError

View File

@@ -0,0 +1,30 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.parse (Python 2.7)
from six.moves.urllib_parse import (
ParseResult as ParseResult,
SplitResult as SplitResult,
parse_qs as parse_qs,
parse_qsl as parse_qsl,
urldefrag as urldefrag,
urljoin as urljoin,
urlparse as urlparse,
urlsplit as urlsplit,
urlunparse as urlunparse,
urlunsplit as urlunsplit,
quote as quote,
quote_plus as quote_plus,
unquote as unquote,
unquote_plus as unquote_plus,
urlencode as urlencode,
splitquery as splitquery,
splittag as splittag,
splituser as splituser,
uses_fragment as uses_fragment,
uses_netloc as uses_netloc,
uses_params as uses_params,
uses_query as uses_query,
uses_relative as uses_relative,
)

View File

@@ -0,0 +1,39 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.request (Python 2.7)
from urllib2 import urlopen as urlopen
from urllib2 import install_opener as install_opener
from urllib2 import build_opener as build_opener
from urllib import pathname2url as pathname2url
from urllib import url2pathname as url2pathname
from urllib import getproxies as getproxies
from urllib2 import Request as Request
from urllib2 import OpenerDirector as OpenerDirector
from urllib2 import HTTPDefaultErrorHandler as HTTPDefaultErrorHandler
from urllib2 import HTTPRedirectHandler as HTTPRedirectHandler
from urllib2 import HTTPCookieProcessor as HTTPCookieProcessor
from urllib2 import ProxyHandler as ProxyHandler
from urllib2 import BaseHandler as BaseHandler
from urllib2 import HTTPPasswordMgr as HTTPPasswordMgr
from urllib2 import HTTPPasswordMgrWithDefaultRealm as HTTPPasswordMgrWithDefaultRealm
from urllib2 import AbstractBasicAuthHandler as AbstractBasicAuthHandler
from urllib2 import HTTPBasicAuthHandler as HTTPBasicAuthHandler
from urllib2 import ProxyBasicAuthHandler as ProxyBasicAuthHandler
from urllib2 import AbstractDigestAuthHandler as AbstractDigestAuthHandler
from urllib2 import HTTPDigestAuthHandler as HTTPDigestAuthHandler
from urllib2 import ProxyDigestAuthHandler as ProxyDigestAuthHandler
from urllib2 import HTTPHandler as HTTPHandler
from urllib2 import HTTPSHandler as HTTPSHandler
from urllib2 import FileHandler as FileHandler
from urllib2 import FTPHandler as FTPHandler
from urllib2 import CacheFTPHandler as CacheFTPHandler
from urllib2 import UnknownHandler as UnknownHandler
from urllib2 import HTTPErrorProcessor as HTTPErrorProcessor
from urllib import urlretrieve as urlretrieve
from urllib import urlcleanup as urlcleanup
from urllib import URLopener as URLopener
from urllib import FancyURLopener as FancyURLopener
# Don't have type stubs for proxy_bypass in stdlib urllib
# from urllib import proxy_bypass as proxy_bypass

View File

@@ -0,0 +1,9 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.response (Python 2.7)
from urllib import addbase as addbase
from urllib import addclosehook as addclosehook
from urllib import addinfo as addinfo
from urllib import addinfourl as addinfourl

View File

@@ -0,0 +1,6 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.robotparser (Python 2.7)
from robotparser import RobotFileParser as RobotFileParser

View File

@@ -0,0 +1,10 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_error (Python 2.7)
from six.moves.urllib.error import (
URLError as URLError,
HTTPError as HTTPError,
ContentTooShortError as ContentTooShortError,
)

View File

@@ -0,0 +1,28 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_parse (Python 2.7)
from urlparse import ParseResult as ParseResult
from urlparse import SplitResult as SplitResult
from urlparse import parse_qs as parse_qs
from urlparse import parse_qsl as parse_qsl
from urlparse import urldefrag as urldefrag
from urlparse import urljoin as urljoin
from urlparse import urlparse as urlparse
from urlparse import urlsplit as urlsplit
from urlparse import urlunparse as urlunparse
from urlparse import urlunsplit as urlunsplit
from urllib import quote as quote
from urllib import quote_plus as quote_plus
from urllib import unquote as unquote
from urllib import unquote_plus as unquote_plus
from urllib import urlencode as urlencode
from urllib import splitquery as splitquery
from urllib import splittag as splittag
from urllib import splituser as splituser
from urlparse import uses_fragment as uses_fragment
from urlparse import uses_netloc as uses_netloc
from urlparse import uses_params as uses_params
from urlparse import uses_query as uses_query
from urlparse import uses_relative as uses_relative

View File

@@ -0,0 +1,40 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_request (Python 2.7)
from six.moves.urllib.request import (
urlopen as urlopen,
install_opener as install_opener,
build_opener as build_opener,
pathname2url as pathname2url,
url2pathname as url2pathname,
getproxies as getproxies,
Request as Request,
OpenerDirector as OpenerDirector,
HTTPDefaultErrorHandler as HTTPDefaultErrorHandler,
HTTPRedirectHandler as HTTPRedirectHandler,
HTTPCookieProcessor as HTTPCookieProcessor,
ProxyHandler as ProxyHandler,
BaseHandler as BaseHandler,
HTTPPasswordMgr as HTTPPasswordMgr,
HTTPPasswordMgrWithDefaultRealm as HTTPPasswordMgrWithDefaultRealm,
AbstractBasicAuthHandler as AbstractBasicAuthHandler,
HTTPBasicAuthHandler as HTTPBasicAuthHandler,
ProxyBasicAuthHandler as ProxyBasicAuthHandler,
AbstractDigestAuthHandler as AbstractDigestAuthHandler,
HTTPDigestAuthHandler as HTTPDigestAuthHandler,
ProxyDigestAuthHandler as ProxyDigestAuthHandler,
HTTPHandler as HTTPHandler,
HTTPSHandler as HTTPSHandler,
FileHandler as FileHandler,
FTPHandler as FTPHandler,
CacheFTPHandler as CacheFTPHandler,
UnknownHandler as UnknownHandler,
HTTPErrorProcessor as HTTPErrorProcessor,
urlretrieve as urlretrieve,
urlcleanup as urlcleanup,
URLopener as URLopener,
FancyURLopener as FancyURLopener,
proxy_bypass as proxy_bypass,
)

View File

@@ -0,0 +1,11 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_response (Python 2.7)
from six.moves.urllib.response import (
addbase as addbase,
addclosehook as addclosehook,
addinfo as addinfo,
addinfourl as addinfourl,
)

View File

@@ -0,0 +1,8 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_robotparser (Python 2.7)
from six.moves.urllib.robotparser import (
RobotFileParser as RobotFileParser,
)

View File

@@ -1,24 +0,0 @@
# Provisional stubs for six.moves (Python 2.7)
from typing import overload, TypeVar, Tuple, Iterable, Iterator
_T1 = TypeVar('_T1')
_T2 = TypeVar('_T2')
_T3 = TypeVar('_T3')
_T4 = TypeVar('_T4')
@overload
def zip(iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2]) -> Iterator[Tuple[_T1, _T2]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3]) -> Iterator[Tuple[_T1, _T2, _T3]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2,
_T3, _T4]]: ... # TODO more than four iterables
# For re-export.
from io import StringIO as cStringIO
import pickle as cPickle

30
third_party/3/six/moves/__init__.pyi vendored Normal file
View File

@@ -0,0 +1,30 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves (Python 3.2)
from io import StringIO as cStringIO
from builtins import filter as filter
from itertools import filterfalse as filterfalse
from builtins import input as input
from sys import intern as intern
from builtins import map as map
from os import getcwd as getcwd
from os import getcwdb as getcwdb
from builtins import range as range
from imp import reload as reload_module
from functools import reduce as reduce
from shlex import quote as shlex_quote
from io import StringIO as StringIO
# from collections import UserDict as UserDict
# from collections import UserList as UserList
# from collections import UserString as UserString
from builtins import range as xrange
from builtins import zip as zip
from itertools import zip_longest as zip_longest
import six.moves.cPickle as cPickle
import six.moves.urllib_parse as urllib_parse
import six.moves.urllib_error as urllib_error
import six.moves.urllib as urllib
import six.moves.urllib_robotparser as urllib_robotparser

6
third_party/3/six/moves/cPickle.pyi vendored Normal file
View File

@@ -0,0 +1,6 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.cPickle (Python 3.2)
from pickle import *

View File

@@ -0,0 +1,10 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib (Python 3.2)
import six.moves.urllib.error as error
import six.moves.urllib.parse as parse
import six.moves.urllib.request as request
import six.moves.urllib.response as response
import six.moves.urllib.robotparser as robotparser

View File

@@ -0,0 +1,8 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.error (Python 3.2)
from urllib.error import URLError as URLError
from urllib.error import HTTPError as HTTPError
from urllib.error import ContentTooShortError as ContentTooShortError

View File

@@ -0,0 +1,22 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.parse (Python 3.2)
from six.moves.urllib_parse import (
ParseResult as ParseResult,
SplitResult as SplitResult,
parse_qs as parse_qs,
parse_qsl as parse_qsl,
urldefrag as urldefrag,
urljoin as urljoin,
urlparse as urlparse,
urlsplit as urlsplit,
urlunparse as urlunparse,
urlunsplit as urlunsplit,
quote as quote,
quote_plus as quote_plus,
unquote as unquote,
unquote_plus as unquote_plus,
urlencode as urlencode,
)

View File

@@ -0,0 +1,40 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.request (Python 3.2)
from urllib.request import BaseHandler as BaseHandler
from urllib.request import HTTPRedirectHandler as HTTPRedirectHandler
from urllib.request import OpenerDirector as OpenerDirector
from urllib.request import install_opener as install_opener
from urllib.request import build_opener as build_opener
# from urllib.request import urlopen as urlopen
# from urllib.request import pathname2url as pathname2url
# from urllib.request import url2pathname as url2pathname
# from urllib.request import getproxies as getproxies
# from urllib.request import Request as Request
# from urllib.request import HTTPDefaultErrorHandler as HTTPDefaultErrorHandler
# from urllib.request import HTTPCookieProcessor as HTTPCookieProcessor
# from urllib.request import ProxyHandler as ProxyHandler
# from urllib.request import HTTPPasswordMgr as HTTPPasswordMgr
# from urllib.request import HTTPPasswordMgrWithDefaultRealm as HTTPPasswordMgrWithDefaultRealm
# from urllib.request import AbstractBasicAuthHandler as AbstractBasicAuthHandler
# from urllib.request import HTTPBasicAuthHandler as HTTPBasicAuthHandler
# from urllib.request import ProxyBasicAuthHandler as ProxyBasicAuthHandler
# from urllib.request import AbstractDigestAuthHandler as AbstractDigestAuthHandler
# from urllib.request import HTTPDigestAuthHandler as HTTPDigestAuthHandler
# from urllib.request import ProxyDigestAuthHandler as ProxyDigestAuthHandler
# from urllib.request import HTTPHandler as HTTPHandler
# from urllib.request import HTTPSHandler as HTTPSHandler
# from urllib.request import FileHandler as FileHandler
# from urllib.request import FTPHandler as FTPHandler
# from urllib.request import CacheFTPHandler as CacheFTPHandler
# from urllib.request import UnknownHandler as UnknownHandler
# from urllib.request import HTTPErrorProcessor as HTTPErrorProcessor
# from urllib.request import urlretrieve as urlretrieve
# from urllib.request import urlcleanup as urlcleanup
# from urllib.request import URLopener as URLopener
# from urllib.request import FancyURLopener as FancyURLopener
# from urllib.request import proxy_bypass as proxy_bypass

View File

@@ -0,0 +1,9 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.response (Python 3.2)
from urllib.response import addbase as addbase
from urllib.response import addclosehook as addclosehook
from urllib.response import addinfo as addinfo
from urllib.response import addinfourl as addinfourl

View File

@@ -0,0 +1,6 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib.robotparser (Python 3.2)
from urllib.robotparser import RobotFileParser as RobotFileParser

View File

@@ -0,0 +1,10 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_error (Python 3.2)
from six.moves.urllib.error import (
URLError as URLError,
HTTPError as HTTPError,
ContentTooShortError as ContentTooShortError,
)

View File

@@ -0,0 +1,20 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_parse (Python 3.2)
from urllib.parse import ParseResult as ParseResult
from urllib.parse import SplitResult as SplitResult
from urllib.parse import parse_qs as parse_qs
from urllib.parse import parse_qsl as parse_qsl
from urllib.parse import urldefrag as urldefrag
from urllib.parse import urljoin as urljoin
from urllib.parse import urlparse as urlparse
from urllib.parse import urlsplit as urlsplit
from urllib.parse import urlunparse as urlunparse
from urllib.parse import urlunsplit as urlunsplit
from urllib.parse import quote as quote
from urllib.parse import quote_plus as quote_plus
from urllib.parse import unquote as unquote
from urllib.parse import unquote_plus as unquote_plus
from urllib.parse import urlencode as urlencode

View File

@@ -0,0 +1,41 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_request (Python 3.2)
from six.moves.urllib.request import (
install_opener as install_opener,
build_opener as build_opener,
BaseHandler as BaseHandler,
OpenerDirector as OpenerDirector,
HTTPRedirectHandler as HTTPRedirectHandler,
# urlopen as urlopen,
# pathname2url as pathname2url,
# url2pathname as url2pathname,
# getproxies as getproxies,
# Request as Request,
# HTTPDefaultErrorHandler as HTTPDefaultErrorHandler,
# HTTPCookieProcessor as HTTPCookieProcessor,
# ProxyHandler as ProxyHandler,
# HTTPPasswordMgr as HTTPPasswordMgr,
# HTTPPasswordMgrWithDefaultRealm as HTTPPasswordMgrWithDefaultRealm,
# AbstractBasicAuthHandler as AbstractBasicAuthHandler,
# HTTPBasicAuthHandler as HTTPBasicAuthHandler,
# ProxyBasicAuthHandler as ProxyBasicAuthHandler,
# AbstractDigestAuthHandler as AbstractDigestAuthHandler,
# HTTPDigestAuthHandler as HTTPDigestAuthHandler,
# ProxyDigestAuthHandler as ProxyDigestAuthHandler,
# HTTPHandler as HTTPHandler,
# HTTPSHandler as HTTPSHandler,
# FileHandler as FileHandler,
# FTPHandler as FTPHandler,
# CacheFTPHandler as CacheFTPHandler,
# UnknownHandler as UnknownHandler,
# HTTPErrorProcessor as HTTPErrorProcessor,
# urlretrieve as urlretrieve,
# urlcleanup as urlcleanup,
# URLopener as URLopener,
# FancyURLopener as FancyURLopener,
# proxy_bypass as proxy_bypass,
)

View File

@@ -0,0 +1,11 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_response (Python 3.2)
from six.moves.urllib.response import (
addbase as addbase,
addclosehook as addclosehook,
addinfo as addinfo,
addinfourl as addinfourl,
)

View File

@@ -0,0 +1,8 @@
# Generated by stubtool 0.1, DO NOT EDIT
# See https://github.com/o11c/stubtool
#
# Stubs for six.moves.urllib_robotparser (Python 3.2)
from six.moves.urllib.robotparser import (
RobotFileParser as RobotFileParser,
)