mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-08 04:54:48 +08:00
fix classonlymethod, replace with six from typeshed
This commit is contained in:
@@ -1,18 +1,10 @@
|
|||||||
from typing import Any, Callable, Optional, Set, Tuple, Type, Union
|
from typing import Any, Callable, Optional, Set, Tuple, Type, Union
|
||||||
|
|
||||||
from django.contrib.auth.mixins import AccessMixin
|
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
|
||||||
from django.middleware.cache import CacheMiddleware
|
from django.middleware.cache import CacheMiddleware
|
||||||
from django.test.testcases import LiveServerTestCase
|
from django.test.testcases import LiveServerTestCase
|
||||||
from django.utils.deprecation import MiddlewareMixin
|
from django.utils.deprecation import MiddlewareMixin
|
||||||
from django.views.generic.base import TemplateResponseMixin, View
|
|
||||||
|
|
||||||
class classonlymethod(classmethod):
|
class classonlymethod(classmethod): ...
|
||||||
def __get__(
|
|
||||||
self,
|
|
||||||
instance: Optional[View],
|
|
||||||
cls: Type[Union[AccessMixin, SuccessMessageMixin, TemplateResponseMixin, View]] = ...,
|
|
||||||
) -> Callable: ...
|
|
||||||
|
|
||||||
def method_decorator(
|
def method_decorator(
|
||||||
decorator: Union[Callable, Set[Callable], Tuple[Callable, Callable]], name: str = ...
|
decorator: Union[Callable, Set[Callable], Tuple[Callable, Callable]], name: str = ...
|
||||||
|
|||||||
@@ -1,144 +1,106 @@
|
|||||||
import types
|
from __future__ import print_function
|
||||||
from typing import Any, Optional
|
|
||||||
|
|
||||||
PY2: Any
|
import types
|
||||||
PY3: Any
|
import typing
|
||||||
PY34: Any
|
import unittest
|
||||||
string_types: Any
|
from typing import (
|
||||||
integer_types: Any
|
Any,
|
||||||
class_types: Any
|
AnyStr,
|
||||||
|
Callable,
|
||||||
|
Dict,
|
||||||
|
ItemsView,
|
||||||
|
Iterable,
|
||||||
|
KeysView,
|
||||||
|
Mapping,
|
||||||
|
NoReturn,
|
||||||
|
Optional,
|
||||||
|
Pattern,
|
||||||
|
Text,
|
||||||
|
Tuple,
|
||||||
|
Type,
|
||||||
|
TypeVar,
|
||||||
|
Union,
|
||||||
|
ValuesView,
|
||||||
|
overload,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Exports
|
||||||
|
|
||||||
|
_T = TypeVar("_T")
|
||||||
|
_K = TypeVar("_K")
|
||||||
|
_V = TypeVar("_V")
|
||||||
|
|
||||||
|
# TODO make constant, then move this stub to 2and3
|
||||||
|
# https://github.com/python/typeshed/issues/17
|
||||||
|
PY2 = False
|
||||||
|
PY3 = True
|
||||||
|
PY34 = ... # type: bool
|
||||||
|
|
||||||
|
string_types = (str,)
|
||||||
|
integer_types = (int,)
|
||||||
|
class_types = (type,)
|
||||||
text_type = str
|
text_type = str
|
||||||
binary_type = bytes
|
binary_type = bytes
|
||||||
MAXSIZE: Any
|
|
||||||
text_type = unicode
|
|
||||||
binary_type = str
|
|
||||||
|
|
||||||
class X:
|
MAXSIZE = ... # type: int
|
||||||
def __len__(self): ...
|
|
||||||
|
|
||||||
class _LazyDescr:
|
# def add_move
|
||||||
name: Any = ...
|
# def remove_move
|
||||||
def __init__(self, name: Any) -> None: ...
|
|
||||||
def __get__(self, obj: Any, tp: Any): ...
|
|
||||||
|
|
||||||
class MovedModule(_LazyDescr):
|
def callable(obj: object) -> bool: ...
|
||||||
mod: Any = ...
|
def get_unbound_function(unbound: types.FunctionType) -> types.FunctionType: ...
|
||||||
def __init__(self, name: Any, old: Any, new: Optional[Any] = ...) -> None: ...
|
def create_bound_method(func: types.FunctionType, obj: object) -> types.MethodType: ...
|
||||||
def __getattr__(self, attr: Any): ...
|
def create_unbound_method(func: types.FunctionType, cls: type) -> types.FunctionType: ...
|
||||||
|
|
||||||
class _LazyModule(types.ModuleType):
|
|
||||||
__doc__: Any = ...
|
|
||||||
def __init__(self, name: Any) -> None: ...
|
|
||||||
def __dir__(self): ...
|
|
||||||
|
|
||||||
class MovedAttribute(_LazyDescr):
|
|
||||||
mod: Any = ...
|
|
||||||
attr: Any = ...
|
|
||||||
def __init__(
|
|
||||||
self, name: Any, old_mod: Any, new_mod: Any, old_attr: Optional[Any] = ..., new_attr: Optional[Any] = ...
|
|
||||||
) -> None: ...
|
|
||||||
|
|
||||||
class _SixMetaPathImporter:
|
|
||||||
name: Any = ...
|
|
||||||
known_modules: Any = ...
|
|
||||||
def __init__(self, six_module_name: Any) -> None: ...
|
|
||||||
def find_module(self, fullname: Any, path: Optional[Any] = ...): ...
|
|
||||||
def load_module(self, fullname: Any): ...
|
|
||||||
def is_package(self, fullname: Any): ...
|
|
||||||
def get_code(self, fullname: Any): ...
|
|
||||||
get_source: Any = ...
|
|
||||||
|
|
||||||
class _MovedItems(_LazyModule):
|
|
||||||
__path__: Any = ...
|
|
||||||
|
|
||||||
moves: Any
|
|
||||||
|
|
||||||
class Module_six_moves_urllib_parse(_LazyModule): ...
|
|
||||||
class Module_six_moves_urllib_error(_LazyModule): ...
|
|
||||||
class Module_six_moves_urllib_request(_LazyModule): ...
|
|
||||||
class Module_six_moves_urllib_response(_LazyModule): ...
|
|
||||||
class Module_six_moves_urllib_robotparser(_LazyModule): ...
|
|
||||||
|
|
||||||
class Module_six_moves_urllib(types.ModuleType):
|
|
||||||
__path__: Any = ...
|
|
||||||
parse: Any = ...
|
|
||||||
error: Any = ...
|
|
||||||
request: Any = ...
|
|
||||||
response: Any = ...
|
|
||||||
robotparser: Any = ...
|
|
||||||
def __dir__(self): ...
|
|
||||||
|
|
||||||
def add_move(move: Any) -> None: ...
|
|
||||||
def remove_move(name: Any) -> None: ...
|
|
||||||
|
|
||||||
advance_iterator = next
|
|
||||||
next = advance_iterator
|
|
||||||
callable = callable
|
|
||||||
|
|
||||||
def get_unbound_function(unbound: Any): ...
|
|
||||||
|
|
||||||
create_bound_method: Any
|
|
||||||
|
|
||||||
def create_unbound_method(func: Any, cls: Any): ...
|
|
||||||
|
|
||||||
Iterator = object
|
Iterator = object
|
||||||
|
|
||||||
class Iterator:
|
def get_method_function(meth: types.MethodType) -> types.FunctionType: ...
|
||||||
def next(self): ...
|
def get_method_self(meth: types.MethodType) -> Optional[object]: ...
|
||||||
|
def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ...
|
||||||
|
def get_function_code(fun: types.FunctionType) -> types.CodeType: ...
|
||||||
|
def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ...
|
||||||
|
def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ...
|
||||||
|
def iterkeys(d: Mapping[_K, _V]) -> typing.Iterator[_K]: ...
|
||||||
|
def itervalues(d: Mapping[_K, _V]) -> typing.Iterator[_V]: ...
|
||||||
|
def iteritems(d: Mapping[_K, _V]) -> typing.Iterator[Tuple[_K, _V]]: ...
|
||||||
|
|
||||||
callable = callable
|
# def iterlists
|
||||||
get_method_function: Any
|
|
||||||
get_method_self: Any
|
|
||||||
get_function_closure: Any
|
|
||||||
get_function_code: Any
|
|
||||||
get_function_defaults: Any
|
|
||||||
get_function_globals: Any
|
|
||||||
|
|
||||||
def iterkeys(d: Any, **kw: Any): ...
|
def viewkeys(d: Mapping[_K, _V]) -> KeysView[_K]: ...
|
||||||
def itervalues(d: Any, **kw: Any): ...
|
def viewvalues(d: Mapping[_K, _V]) -> ValuesView[_V]: ...
|
||||||
def iteritems(d: Any, **kw: Any): ...
|
def viewitems(d: Mapping[_K, _V]) -> ItemsView[_K, _V]: ...
|
||||||
def iterlists(d: Any, **kw: Any): ...
|
def b(s: str) -> binary_type: ...
|
||||||
|
def u(s: str) -> text_type: ...
|
||||||
viewkeys: Any
|
|
||||||
viewvalues: Any
|
|
||||||
viewitems: Any
|
|
||||||
|
|
||||||
def b(s: Any): ...
|
|
||||||
def u(s: Any): ...
|
|
||||||
|
|
||||||
unichr = chr
|
unichr = chr
|
||||||
int2byte: Any
|
|
||||||
byte2int: Any
|
|
||||||
indexbytes: Any
|
|
||||||
iterbytes = iter
|
|
||||||
StringIO: Any
|
|
||||||
BytesIO: Any
|
|
||||||
unichr = unichr
|
|
||||||
int2byte = chr
|
|
||||||
|
|
||||||
def assertCountEqual(self, *args: Any, **kwargs: Any): ...
|
def int2byte(i: int) -> bytes: ...
|
||||||
def assertRaisesRegex(self, *args: Any, **kwargs: Any): ...
|
def byte2int(bs: binary_type) -> int: ...
|
||||||
def assertRegex(self, *args: Any, **kwargs: Any): ...
|
def indexbytes(buf: binary_type, i: int) -> int: ...
|
||||||
|
def iterbytes(buf: binary_type) -> typing.Iterator[int]: ...
|
||||||
|
def assertCountEqual(
|
||||||
|
self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: Optional[str] = ...
|
||||||
|
) -> None: ...
|
||||||
|
@overload
|
||||||
|
def assertRaisesRegex(self: unittest.TestCase, msg: Optional[str] = ...) -> Any: ...
|
||||||
|
@overload
|
||||||
|
def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ...
|
||||||
|
def assertRegex(
|
||||||
|
self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: Optional[str] = ...
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
exec_: Any
|
exec_ = exec
|
||||||
|
|
||||||
def reraise(tp: Any, value: Any, tb: Optional[Any] = ...) -> None: ...
|
def reraise(
|
||||||
def raise_from(value: Any, from_value: Any) -> None: ...
|
tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ...
|
||||||
|
) -> NoReturn: ...
|
||||||
|
def raise_from(value: Union[BaseException, Type[BaseException]], from_value: Optional[BaseException]) -> NoReturn: ...
|
||||||
|
|
||||||
print_: Any
|
print_ = print
|
||||||
_print = print_
|
|
||||||
|
|
||||||
def wraps(wrapped: Any, assigned: Any = ..., updated: Any = ...): ...
|
def with_metaclass(meta: type, *bases: type) -> type: ...
|
||||||
|
def add_metaclass(metaclass: type) -> Callable[[_T], _T]: ...
|
||||||
wraps: Any
|
def ensure_binary(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> bytes: ...
|
||||||
|
def ensure_str(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> str: ...
|
||||||
def with_metaclass(meta: Any, *bases: Any): ...
|
def ensure_text(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> Text: ...
|
||||||
def add_metaclass(metaclass: Any): ...
|
def python_2_unicode_compatible(klass: _T) -> _T: ...
|
||||||
def python_2_unicode_compatible(klass: Any): ...
|
|
||||||
|
|
||||||
__path__: Any
|
|
||||||
__package__ = __name__
|
|
||||||
memoryview = memoryview
|
|
||||||
buffer_types: Any
|
|
||||||
memoryview = memoryview
|
|
||||||
memoryview = buffer
|
|
||||||
|
|||||||
Reference in New Issue
Block a user