mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-16 08:47:49 +08:00
Add test to import all modules to check validity of stubs (#56)
* add import_all.test builder * fix errors * fix typechecking errors * fix migrations typechecking
This commit is contained in:
22
django-stubs/core/cache/backends/base.pyi
vendored
22
django-stubs/core/cache/backends/base.pyi
vendored
@@ -1,5 +1,4 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, List, Optional, Union
|
||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Union
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
@@ -9,7 +8,7 @@ class CacheKeyWarning(RuntimeWarning): ...
|
||||
DEFAULT_TIMEOUT: Any
|
||||
MEMCACHE_MAX_KEY_LENGTH: int
|
||||
|
||||
def default_key_func(key: Union[int, str], key_prefix: str, version: Union[int, str]) -> str: ...
|
||||
def default_key_func(key: Any, key_prefix: str, version: Any) -> str: ...
|
||||
def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ...
|
||||
|
||||
class BaseCache:
|
||||
@@ -17,9 +16,9 @@ class BaseCache:
|
||||
key_prefix: str = ...
|
||||
version: int = ...
|
||||
key_func: Callable = ...
|
||||
def __init__(self, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ...
|
||||
def __init__(self, params: Dict[str, Any]) -> None: ...
|
||||
def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ...
|
||||
def make_key(self, key: Union[int, str], version: Optional[Union[int, str]] = ...) -> str: ...
|
||||
def make_key(self, key: Any, version: Optional[Any] = ...) -> str: ...
|
||||
def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ...
|
||||
def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
@@ -27,19 +26,14 @@ class BaseCache:
|
||||
def delete(self, key: Any, version: Optional[Any] = ...) -> None: ...
|
||||
def get_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ...
|
||||
def get_or_set(
|
||||
self, key: str, default: Optional[Union[Callable, int, str]], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> Optional[Union[int, str]]: ...
|
||||
self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> Optional[Any]: ...
|
||||
def has_key(self, key: Any, version: Optional[Any] = ...): ...
|
||||
def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def decr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def set_many(
|
||||
self,
|
||||
data: Union[Dict[str, bytes], Dict[str, int], Dict[str, str], OrderedDict],
|
||||
timeout: Any = ...,
|
||||
version: Optional[Union[int, str]] = ...,
|
||||
) -> List[Any]: ...
|
||||
def delete_many(self, keys: Union[Dict[str, str], List[str]], version: None = ...) -> None: ...
|
||||
def set_many(self, data: Dict[str, Any], timeout: Any = ..., version: Optional[Any] = ...) -> List[Any]: ...
|
||||
def delete_many(self, keys: Iterable[Any], version: Optional[Any] = ...) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def validate_key(self, key: str) -> None: ...
|
||||
def incr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
|
||||
23
django-stubs/core/cache/backends/db.pyi
vendored
23
django-stubs/core/cache/backends/db.pyi
vendored
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
@@ -16,24 +16,7 @@ class Options:
|
||||
def __init__(self, table: str) -> None: ...
|
||||
|
||||
class BaseDatabaseCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
cache_model_class: Any = ...
|
||||
def __init__(self, table: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ...
|
||||
def __init__(self, table: str, params: Dict[str, Any]) -> None: ...
|
||||
|
||||
class DatabaseCache(BaseDatabaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
def get(self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...) -> Any: ...
|
||||
def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
|
||||
def add(
|
||||
self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> bool: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
|
||||
def has_key(self, key: str, version: Optional[int] = ...) -> Any: ...
|
||||
def clear(self) -> None: ...
|
||||
class DatabaseCache(BaseDatabaseCache): ...
|
||||
|
||||
15
django-stubs/core/cache/backends/dummy.pyi
vendored
15
django-stubs/core/cache/backends/dummy.pyi
vendored
@@ -1,19 +1,6 @@
|
||||
from typing import Any, Dict, Optional, Union, Callable
|
||||
from typing import Any
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
class DummyCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
def __init__(self, host: str, *args: Any, **kwargs: Any) -> None: ...
|
||||
def add(self, key: str, value: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def get(self, key: str, default: Optional[str] = ..., version: Optional[int] = ...) -> Optional[str]: ...
|
||||
def set(
|
||||
self, key: str, value: Union[Dict[str, Any], int, str], timeout: Any = ..., version: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: None = ...) -> None: ...
|
||||
def has_key(self, key: str, version: None = ...) -> bool: ...
|
||||
def clear(self) -> None: ...
|
||||
|
||||
19
django-stubs/core/cache/backends/filebased.pyi
vendored
19
django-stubs/core/cache/backends/filebased.pyi
vendored
@@ -1,22 +1,7 @@
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
class FileBasedCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
cache_suffix: str = ...
|
||||
def __init__(self, dir: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ...
|
||||
def add(
|
||||
self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> bool: ...
|
||||
def get(
|
||||
self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...
|
||||
) -> Optional[str]: ...
|
||||
def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
|
||||
def has_key(self, key: str, version: Optional[int] = ...) -> bool: ...
|
||||
def clear(self) -> None: ...
|
||||
def __init__(self, dir: str, params: Dict[str, Any]) -> None: ...
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
from ctypes import Structure, c_int64, c_ulong, c_void_p
|
||||
from io import BufferedRandom, TextIOWrapper
|
||||
from typing import Union
|
||||
from ctypes import Structure, Union
|
||||
from typing import Any
|
||||
|
||||
LOCK_SH: int
|
||||
LOCK_NB: int
|
||||
LOCK_EX: int
|
||||
ULONG_PTR = c_int64
|
||||
ULONG_PTR = c_ulong
|
||||
PVOID = c_void_p
|
||||
ULONG_PTR: Any = ...
|
||||
PVOID: Any = ...
|
||||
|
||||
class _OFFSET(Structure): ...
|
||||
class _OFFSET_UNION(Union): ...
|
||||
class OVERLAPPED(Structure): ...
|
||||
|
||||
def lock(f: Union[BufferedRandom, TextIOWrapper, int], flags: int) -> bool: ...
|
||||
def unlock(f: Union[BufferedRandom, int]) -> bool: ...
|
||||
def lock(f: Any, flags: int) -> bool: ...
|
||||
def unlock(f: Any) -> bool: ...
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from typing import Any, List, Optional, Tuple
|
||||
|
||||
from .backends.base import BaseEmailBackend
|
||||
from .message import (
|
||||
BadHeaderError as BadHeaderError,
|
||||
DEFAULT_ATTACHMENT_MIME_TYPE as DEFAULT_ATTACHMENT_MIME_TYPE,
|
||||
@@ -12,7 +11,7 @@ from .message import (
|
||||
)
|
||||
from .utils import CachedDnsName as CachedDnsName, DNS_NAME as DNS_NAME
|
||||
|
||||
def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> BaseEmailBackend: ...
|
||||
def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> Any: ...
|
||||
def send_mail(
|
||||
subject: str,
|
||||
message: str,
|
||||
@@ -21,7 +20,7 @@ def send_mail(
|
||||
fail_silently: bool = ...,
|
||||
auth_user: Optional[str] = ...,
|
||||
auth_password: Optional[str] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> int: ...
|
||||
def send_mass_mail(
|
||||
@@ -29,20 +28,20 @@ def send_mass_mail(
|
||||
fail_silently: bool = ...,
|
||||
auth_user: Optional[str] = ...,
|
||||
auth_password: Optional[str] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
) -> int: ...
|
||||
def mail_admins(
|
||||
subject: str,
|
||||
message: str,
|
||||
fail_silently: bool = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def mail_managers(
|
||||
subject: str,
|
||||
message: str,
|
||||
fail_silently: bool = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
from email._policybase import Policy
|
||||
from email._policybase import Policy # type: ignore
|
||||
from email.mime.message import MIMEMessage
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union, Sequence
|
||||
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
|
||||
|
||||
utf8_charset: Any
|
||||
utf8_charset_qp: Any
|
||||
@@ -20,16 +17,13 @@ def forbid_multi_line_headers(name: str, val: str, encoding: str) -> Tuple[str,
|
||||
def split_addr(addr: str, encoding: str) -> Tuple[str, str]: ...
|
||||
def sanitize_address(addr: Union[Tuple[str, str], str], encoding: str) -> str: ...
|
||||
|
||||
class MIMEMixin:
|
||||
def as_string(self, unixfrom: bool = ..., linesep: str = ...) -> str: ...
|
||||
def as_bytes(self, unixfrom: bool = ..., linesep: str = ...) -> bytes: ...
|
||||
class MIMEMixin: ...
|
||||
|
||||
class SafeMIMEMessage(MIMEMixin, MIMEMessage):
|
||||
defects: List[Any]
|
||||
epilogue: None
|
||||
policy: Policy
|
||||
preamble: None
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
|
||||
class SafeMIMEText(MIMEMixin, MIMEText):
|
||||
defects: List[Any]
|
||||
@@ -38,8 +32,6 @@ class SafeMIMEText(MIMEMixin, MIMEText):
|
||||
preamble: None
|
||||
encoding: str = ...
|
||||
def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ...
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
def set_payload(self, payload: str, charset: str = ...) -> None: ...
|
||||
|
||||
class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
|
||||
defects: List[Any]
|
||||
@@ -50,7 +42,6 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
|
||||
def __init__(
|
||||
self, _subtype: str = ..., boundary: None = ..., _subparts: None = ..., encoding: str = ..., **_params: Any
|
||||
) -> None: ...
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
|
||||
class EmailMessage:
|
||||
content_subtype: str = ...
|
||||
@@ -65,7 +56,7 @@ class EmailMessage:
|
||||
body: str = ...
|
||||
attachments: List[Any] = ...
|
||||
extra_headers: Dict[Any, Any] = ...
|
||||
connection: None = ...
|
||||
connection: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
subject: str = ...,
|
||||
@@ -73,13 +64,13 @@ class EmailMessage:
|
||||
from_email: Optional[str] = ...,
|
||||
to: Optional[Union[Sequence[str], str]] = ...,
|
||||
bcc: Optional[Union[Sequence[str], str]] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
attachments: Optional[Union[List[Tuple[str, str]], List[MIMEText]]] = ...,
|
||||
headers: Optional[Dict[str, str]] = ...,
|
||||
cc: Optional[Union[Sequence[str], str]] = ...,
|
||||
reply_to: Optional[Union[List[Optional[str]], str]] = ...,
|
||||
) -> None: ...
|
||||
def get_connection(self, fail_silently: bool = ...) -> BaseEmailBackend: ...
|
||||
def get_connection(self, fail_silently: bool = ...) -> Any: ...
|
||||
def message(self) -> MIMEMixin: ...
|
||||
def recipients(self) -> List[str]: ...
|
||||
def send(self, fail_silently: bool = ...) -> int: ...
|
||||
@@ -92,16 +83,6 @@ class EmailMessage:
|
||||
def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ...
|
||||
|
||||
class EmailMultiAlternatives(EmailMessage):
|
||||
attachments: List[Any]
|
||||
bcc: List[Any]
|
||||
body: SafeText
|
||||
cc: List[Any]
|
||||
connection: None
|
||||
extra_headers: Dict[Any, Any]
|
||||
from_email: str
|
||||
reply_to: List[Any]
|
||||
subject: str
|
||||
to: List[str]
|
||||
alternative_subtype: str = ...
|
||||
alternatives: Any = ...
|
||||
def __init__(
|
||||
@@ -111,7 +92,7 @@ class EmailMultiAlternatives(EmailMessage):
|
||||
from_email: Optional[str] = ...,
|
||||
to: Optional[List[str]] = ...,
|
||||
bcc: Optional[List[str]] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
attachments: None = ...,
|
||||
headers: Optional[Dict[str, str]] = ...,
|
||||
alternatives: Optional[List[Tuple[str, str]]] = ...,
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class TemplateCommand(BaseCommand):
|
||||
requires_system_checks: bool = ...
|
||||
url_schemes: Any = ...
|
||||
rewrite_template_suffixes: Any = ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
app_or_project: Any = ...
|
||||
paths_to_remove: Any = ...
|
||||
verbosity: Any = ...
|
||||
def handle(self, app_or_project: Any, name: Any, target: Optional[Any] = ..., **options: Any): ...
|
||||
def handle_template(self, template: Any, subdir: Any): ...
|
||||
def validate_name(self, name: Any, app_or_project: Any) -> None: ...
|
||||
def download(self, url: Any): ...
|
||||
|
||||
Reference in New Issue
Block a user