1 # Stubs for six (Python 2.7)
\r
3 from __future__ import print_function
\r
7 Any, AnyStr, Callable, Dict, Iterable, Mapping, NoReturn, Optional,
\r
8 Pattern, Tuple, Type, TypeVar, Union, overload, ValuesView, KeysView, ItemsView
\r
14 from __builtin__ import unichr as unichr
\r
15 from StringIO import StringIO as StringIO, StringIO as BytesIO
\r
16 from functools import wraps as wraps
\r
24 # TODO make constant, then move this stub to 2and3
\r
25 # https://github.com/python/typeshed/issues/17
\r
30 string_types = (str, unicode)
\r
31 integer_types = (int, long)
\r
32 class_types = (type, types.ClassType)
\r
36 MAXSIZE = ... # type: int
\r
41 def advance_iterator(it: typing.Iterator[_T]) -> _T: ...
\r
42 next = advance_iterator
\r
44 def callable(obj: object) -> bool: ...
\r
46 def get_unbound_function(unbound: types.MethodType) -> types.FunctionType: ...
\r
47 def create_bound_method(func: types.FunctionType, obj: object) -> types.MethodType: ...
\r
48 def create_unbound_method(func: types.FunctionType, cls: Union[type, types.ClassType]) -> types.MethodType: ...
\r
51 def next(self) -> Any: ...
\r
53 def get_method_function(meth: types.MethodType) -> types.FunctionType: ...
\r
54 def get_method_self(meth: types.MethodType) -> Optional[object]: ...
\r
55 def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ...
\r
56 def get_function_code(fun: types.FunctionType) -> types.CodeType: ...
\r
57 def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ...
\r
58 def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ...
\r
60 def iterkeys(d: Mapping[_K, _V]) -> typing.Iterator[_K]: ...
\r
61 def itervalues(d: Mapping[_K, _V]) -> typing.Iterator[_V]: ...
\r
62 def iteritems(d: Mapping[_K, _V]) -> typing.Iterator[Tuple[_K, _V]]: ...
\r
65 def viewkeys(d: Mapping[_K, _V]) -> KeysView[_K]: ...
\r
66 def viewvalues(d: Mapping[_K, _V]) -> ValuesView[_V]: ...
\r
67 def viewitems(d: Mapping[_K, _V]) -> ItemsView[_K, _V]: ...
\r
69 def b(s: str) -> binary_type: ...
\r
70 def u(s: str) -> text_type: ...
\r
72 def byte2int(bs: binary_type) -> int: ...
\r
73 def indexbytes(buf: binary_type, i: int) -> int: ...
\r
74 def iterbytes(buf: binary_type) -> typing.Iterator[int]: ...
\r
76 def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: str = ...) -> None: ...
\r
78 def assertRaisesRegex(self: unittest.TestCase, msg: str = ...) -> Any: ...
\r
80 def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ...
\r
81 def assertRegex(self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: str = ...) -> None: ...
\r
83 def reraise(tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ...) -> NoReturn: ...
\r
84 def exec_(_code_: Union[unicode, types.CodeType], _globs_: Dict[str, Any] = ..., _locs_: Dict[str, Any] = ...): ...
\r
85 def raise_from(value: BaseException, from_value: Optional[BaseException]) -> NoReturn: ...
\r
89 def with_metaclass(meta: type, *bases: type) -> type: ...
\r
90 def add_metaclass(metaclass: type) -> Callable[[_T], _T]: ...
\r
91 def python_2_unicode_compatible(klass: _T) -> _T: ...
\r