mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-19 02:15:59 +08:00
Large update (#909)
* Make module declaration precise. * Make settings match real file. * Replace `include` with import. * Make types more specific. * Replace `WSGIRequest` with `HttpRequest` where possible. * Replace all `OrderedDict` occurrences with plain `Dict` (it is not used in Django 3.2 and later) * Add fake datastructures for convenience: _PropertyDescriptor and _ListOrTuple now can live here. Added _IndexableCollection (often useful as alias for 'sequence or queryset') * Actualize other datastructures. * Rework MultiValueDict to reflect the fact that some methods can return empty list instead of value. * Deprecate SafeText in favor of SafeString. * Minor improvements to utils * Disallow using str in TimeFormat and DateFormat, drop removed fmt `B` * Do not let classproperty expect classmethod, make return value covariant. * Sync with real file. * Improve types for timezone. * Sync deprecated, new and removed features in translation utils. * Drop removed files, sync huge deprecations. * Fix incompatible decorators (properties, contextmanagers) * Rework pagination. * Sync validators with real code. Add _ValidatorCallable for any external use (field validation etc.) * Add shared type definitions (for fields of both forms and models). Actualize model fields. Mark keyword-only args explicitly in stubs (where code uses **kwargs). Disallow bytes for verbose_name. * Make all checks return Sequence[CheckMessage] or subclass to be covariant. * Add bidirectional references between backend.base and other files. Replace some Any's with specific types. * Actualize db.migrations: remove removed methods, replace "None" annotations in wrong places, improve some wrong annotations. * Actualize db.utils to match real file. * Replace FileResponse and TemplateResponse with HttpResponse(Base) where needed: at least HttpResponseNotModified/HttpResponseRedirect can be returned instead of it, so annotation was wrong. * Replace Any in forms where possible. Actualize class bases and method arguments. * Improve typing of serializers. * Actualize views, rename variable bound to Model to _M for consistency. * Make types of file-related code consistent. Disallow using bytes as path, because many methods expect str-only paths. Make File inherit from IO[AnyStr] instead of IO[Any]: it makes impossible to instantiate file of union type, but allows precise types for some methods. * Minor improvements: stop using None as annotation in wrong places, replace obvious Any's with precise types, actualize methods (missing/renamed/signature changed). * Allow less specific containers, replace Any's with specific types. * Improve types for requests and responses. * Use AbstractBaseUser instead of User in auth. * Use broader type for permission_required * Use wider container types. Add 'type: ignore' to avoid issues with mypy.stubtest. * Disallow using backend class as argument (it is passed to import_string). * Add required methods to PasseordValidator. * Allow using Path instance as argument. * Actualize methods. * Add 'type: ignore' to avoid issues with mypy.stubtest. * Replace Any's with specific types and BaseForm with ModelForm. * Actualize contrib.postgres * Remove render_to_response, add 'get_absolute_url' to corresponding protocol. * Actualize signers. * Use precise types for handlers. Disallow str as stream type for LimitedStream. * Exact types for ValidationError * Replace wrong used Union with Sequence. * Actualize static handlers. * More specific types for admin. Fixes #874. * Improve types and replace 'Tags' with str (it isn't Enum, so annotation was wrong). * Replace Any with specific types, actualize signatures. * Add async variants of handlers and clients. Use fake class to distinguish between request types in RequestFactory and AsyncRequestFactory. * Fix signature, minor improvements. * Actualize signatures and class names, replace Any with more specific types. * Fix signature. * Add some missing methods to Collector * Combinable rarely returns Self type: almost always it's CombinedExpression. * No Random in source anymore. * Drop removed SimpleCol. * Replace _OutputField with Field: nothing in docs about strings. * Introduce reusable types, add missing methods. Remove strange types (probably created by stubgen). Remove RawQuery from Compiler: it obviously doesn't work with RawQuery. * Use literal constants. * Actualize base classes. * Callable is not accepted by get_field. * Add precise types. * Use property and broader containers where possible. Add missing methods. * Actualize indexes. * More specific types for signals. * Fix signatures, drop missing methods. * Actualize window functions to match source. * Actualize text functions, add missing methods, use type aliases for consistency. * Add missing property decorators, methods and attributes. Use type aliases. Remove absent YearComparisonLookup and any SafeText references (they aren't related to lookups at all). * Use bound TypeVar, mark all BuiltinLookup descendants as generic explicitly. Remove strange Union from Lookup.__init__ * Apply type alias, fix base class and argument name. * Actualize BaseExpression methods. * Fix imports. * Add missing class and fix incompatible bases. * Use same types in __init__ and attribute. * OrderBy accepts F or Expression. * Non-expressions are converted to Values. * Add missing attributes. * Add missing methods, fix 'None' argument type. * Define properties where possible, remove 'None' argument annotations, remove inadequate type in make_immutable_fields_list. * Remove absent QueryWrapper. Replace some Any with precise types. * Fix wrong types and actualize signatures. Deny ManagerDescriptor.__get__ on model instances. * Use more specific types. * Arity can be None in subclasses. * Reformat with black * Make DeletionMixin generic. * Fix wrong type variable in _RequestFactory. * Fix variable name in signature. * Disallow returning None from Form.clean() * Allow again returning None from Form.clean * Drop some unused imports. * Add tests for MultiValueDict. * Add tests for utils.timezone. * Fix #834. * Add more files to import_all test * Allow None for `context_object_name` * Fix CI * Fix test to work on python 3.8
This commit is contained in:
@@ -1,13 +1,36 @@
|
||||
from typing import Any, Optional
|
||||
from contextlib import contextmanager
|
||||
from typing import Any, Generator, Optional, Type
|
||||
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper as BaseDatabaseWrapper
|
||||
|
||||
def wrap_oracle_errors() -> None: ...
|
||||
from .client import DatabaseClient
|
||||
from .creation import DatabaseCreation
|
||||
from .features import DatabaseFeatures
|
||||
from .introspection import DatabaseIntrospection
|
||||
from .operations import DatabaseOperations
|
||||
from .validation import DatabaseValidation
|
||||
|
||||
@contextmanager
|
||||
def wrap_oracle_errors() -> Generator[None, None, None]: ...
|
||||
|
||||
class _UninitializedOperatorsDescriptor:
|
||||
def __get__(self, instance: Any, cls: Optional[Any] = ...): ...
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
client: DatabaseClient
|
||||
creation: DatabaseCreation
|
||||
features: DatabaseFeatures
|
||||
introspection: DatabaseIntrospection
|
||||
validation: DatabaseValidation
|
||||
ops: DatabaseOperations
|
||||
|
||||
client_class: Type[DatabaseClient]
|
||||
creation_class: Type[DatabaseCreation]
|
||||
features_class: Type[DatabaseFeatures]
|
||||
introspection_class: Type[DatabaseIntrospection]
|
||||
ops_class: Type[DatabaseOperations]
|
||||
validation_class: Type[DatabaseValidation]
|
||||
|
||||
vendor: str = ...
|
||||
display_name: str = ...
|
||||
data_types: Any = ...
|
||||
@@ -16,12 +39,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
pattern_esc: str = ...
|
||||
Database: Any = ...
|
||||
SchemaEditorClass: Any = ...
|
||||
client_class: Any = ...
|
||||
creation_class: Any = ...
|
||||
features_class: Any = ...
|
||||
introspection_class: Any = ...
|
||||
ops_class: Any = ...
|
||||
validation_class: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def get_connection_params(self): ...
|
||||
def get_new_connection(self, conn_params: Any): ...
|
||||
@@ -30,7 +47,9 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
def create_cursor(self, name: Optional[Any] = ...): ...
|
||||
def check_constraints(self, table_names: Optional[Any] = ...) -> None: ...
|
||||
def is_usable(self): ...
|
||||
@property
|
||||
def cx_oracle_version(self): ...
|
||||
@property
|
||||
def oracle_version(self): ...
|
||||
|
||||
class OracleParam:
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
from typing import Any, Dict, Iterable, List, Tuple
|
||||
|
||||
from django.db.backends.base.client import BaseDatabaseClient as BaseDatabaseClient
|
||||
from django.db.backends.oracle.base import DatabaseWrapper
|
||||
|
||||
class DatabaseClient(BaseDatabaseClient):
|
||||
connection: DatabaseWrapper
|
||||
executable_name: str = ...
|
||||
wrapper_name: str = ...
|
||||
@staticmethod
|
||||
def connect_string(settings_dict: Dict[str, Any]) -> str: ...
|
||||
@classmethod
|
||||
def settings_to_cmd_args_env(
|
||||
self, settings_dict: Dict[str, Any], parameters: Iterable[str]
|
||||
cls, settings_dict: Dict[str, Any], parameters: Iterable[str]
|
||||
) -> Tuple[List[str], None]: ...
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
from typing import Any
|
||||
|
||||
from django.db.backends.base.creation import BaseDatabaseCreation as BaseDatabaseCreation
|
||||
from django.db.backends.oracle.base import DatabaseWrapper
|
||||
|
||||
TEST_DATABASE_PREFIX: str
|
||||
|
||||
class DatabaseCreation(BaseDatabaseCreation):
|
||||
connection: DatabaseWrapper
|
||||
def set_as_test_mirror(self, primary_settings_dict: Any) -> None: ...
|
||||
def test_db_signature(self): ...
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from typing import Any
|
||||
|
||||
from django.db.backends.base.features import BaseDatabaseFeatures as BaseDatabaseFeatures
|
||||
from django.db.backends.oracle.base import DatabaseWrapper
|
||||
|
||||
class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
connection: DatabaseWrapper
|
||||
interprets_empty_strings_as_nulls: bool = ...
|
||||
has_select_for_update: bool = ...
|
||||
has_select_for_update_nowait: bool = ...
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
from typing import Any
|
||||
|
||||
from django.db.backends.base.introspection import BaseDatabaseIntrospection as BaseDatabaseIntrospection
|
||||
from django.db.backends.oracle.base import DatabaseWrapper
|
||||
|
||||
FieldInfo: Any
|
||||
|
||||
class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||
connection: DatabaseWrapper
|
||||
cache_bust_counter: int = ...
|
||||
@property
|
||||
def data_types_reverse(self): ...
|
||||
def get_field_type(self, data_type: Any, description: Any): ...
|
||||
def get_table_list(self, cursor: Any): ...
|
||||
|
||||
@@ -1,58 +1,59 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.db.backends.base.operations import BaseDatabaseOperations as BaseDatabaseOperations
|
||||
from django.db.backends.oracle.base import DatabaseWrapper
|
||||
|
||||
class DatabaseOperations(BaseDatabaseOperations):
|
||||
connection: DatabaseWrapper
|
||||
integer_field_ranges: Any = ...
|
||||
set_operators: Any = ...
|
||||
cast_char_field_without_max_length: str = ...
|
||||
cast_data_types: Any = ...
|
||||
def cache_key_culling_sql(self): ...
|
||||
def date_extract_sql(self, lookup_type: Any, field_name: Any): ...
|
||||
def date_trunc_sql(self, lookup_type: Any, field_name: Any): ...
|
||||
def datetime_cast_date_sql(self, field_name: Any, tzname: Any): ...
|
||||
def datetime_cast_time_sql(self, field_name: Any, tzname: Any): ...
|
||||
def datetime_extract_sql(self, lookup_type: Any, field_name: Any, tzname: Any): ...
|
||||
def datetime_trunc_sql(self, lookup_type: Any, field_name: Any, tzname: Any): ...
|
||||
def time_trunc_sql(self, lookup_type: Any, field_name: Any): ...
|
||||
def get_db_converters(self, expression: Any): ...
|
||||
def convert_textfield_value(self, value: Any, expression: Any, connection: Any): ...
|
||||
def convert_binaryfield_value(self, value: Any, expression: Any, connection: Any): ...
|
||||
def convert_booleanfield_value(self, value: Any, expression: Any, connection: Any): ...
|
||||
def convert_datetimefield_value(self, value: Any, expression: Any, connection: Any): ...
|
||||
def convert_datefield_value(self, value: Any, expression: Any, connection: Any): ...
|
||||
def convert_timefield_value(self, value: Any, expression: Any, connection: Any): ...
|
||||
def convert_uuidfield_value(self, value: Any, expression: Any, connection: Any): ...
|
||||
def cache_key_culling_sql(self) -> str: ...
|
||||
def date_extract_sql(self, lookup_type: str, field_name: str) -> str: ...
|
||||
def date_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str] = ...) -> str: ...
|
||||
def datetime_cast_date_sql(self, field_name: str, tzname: Optional[str]) -> str: ...
|
||||
def datetime_cast_time_sql(self, field_name: str, tzname: Optional[str]) -> str: ...
|
||||
def datetime_extract_sql(self, lookup_type: str, field_name: str, tzname: Optional[str]) -> str: ...
|
||||
def datetime_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str]) -> str: ...
|
||||
def time_trunc_sql(self, lookup_type: str, field_name: str, tzname: Optional[str] = ...) -> str: ...
|
||||
def get_db_converters(self, expression: Any) -> List[Any]: ...
|
||||
def convert_textfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
def convert_binaryfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
def convert_booleanfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
def convert_datetimefield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
def convert_datefield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
def convert_timefield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
def convert_uuidfield_value(self, value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
@staticmethod
|
||||
def convert_empty_string(value: Any, expression: Any, connection: Any): ...
|
||||
def convert_empty_string(value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
@staticmethod
|
||||
def convert_empty_bytes(value: Any, expression: Any, connection: Any): ...
|
||||
def deferrable_sql(self): ...
|
||||
def fetch_returned_insert_columns(self, cursor: Any, returning_params: Any): ...
|
||||
def field_cast_sql(self, db_type: Any, internal_type: Any): ...
|
||||
def no_limit_value(self) -> None: ...
|
||||
def limit_offset_sql(self, low_mark: Any, high_mark: Any): ...
|
||||
def last_executed_query(self, cursor: Any, sql: Any, params: Any): ...
|
||||
def last_insert_id(self, cursor: Any, table_name: Any, pk_name: Any): ...
|
||||
def lookup_cast(self, lookup_type: Any, internal_type: Optional[Any] = ...): ...
|
||||
def max_in_list_size(self): ...
|
||||
def max_name_length(self): ...
|
||||
def pk_default_value(self): ...
|
||||
def prep_for_iexact_query(self, x: Any): ...
|
||||
def process_clob(self, value: Any): ...
|
||||
def quote_name(self, name: Any): ...
|
||||
def random_function_sql(self): ...
|
||||
def regex_lookup(self, lookup_type: Any): ...
|
||||
def return_insert_columns(self, fields: Any): ...
|
||||
def sequence_reset_by_name_sql(self, style: Any, sequences: Any): ...
|
||||
def sequence_reset_sql(self, style: Any, model_list: Any): ...
|
||||
def start_transaction_sql(self): ...
|
||||
def tablespace_sql(self, tablespace: Any, inline: bool = ...): ...
|
||||
def adapt_datefield_value(self, value: Any): ...
|
||||
def adapt_datetimefield_value(self, value: Any): ...
|
||||
def adapt_timefield_value(self, value: Any): ...
|
||||
def combine_expression(self, connector: Any, sub_expressions: Any): ...
|
||||
def bulk_insert_sql(self, fields: Any, placeholder_rows: Any): ...
|
||||
def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any): ...
|
||||
def bulk_batch_size(self, fields: Any, objs: Any): ...
|
||||
def conditional_expression_supported_in_where_clause(self, expression: Any): ...
|
||||
def convert_empty_bytes(value: Any, expression: Any, connection: Any) -> Any: ...
|
||||
def deferrable_sql(self) -> str: ...
|
||||
def fetch_returned_insert_columns(self, cursor: Any, returning_params: Any) -> Any: ...
|
||||
def field_cast_sql(self, db_type: Any, internal_type: Any) -> str: ...
|
||||
def no_limit_value(self) -> Optional[str]: ...
|
||||
def limit_offset_sql(self, low_mark: Any, high_mark: Any) -> str: ...
|
||||
def last_executed_query(self, cursor: Any, sql: Any, params: Any) -> str: ...
|
||||
def last_insert_id(self, cursor: Any, table_name: Any, pk_name: Any) -> Any: ...
|
||||
def lookup_cast(self, lookup_type: str, internal_type: Optional[Any] = ...) -> str: ...
|
||||
def max_in_list_size(self) -> int: ...
|
||||
def max_name_length(self) -> int: ...
|
||||
def pk_default_value(self) -> str: ...
|
||||
def prep_for_iexact_query(self, x: Any) -> str: ...
|
||||
def process_clob(self, value: Any) -> Any: ...
|
||||
def quote_name(self, name: str) -> str: ...
|
||||
def regex_lookup(self, lookup_type: str) -> str: ...
|
||||
def return_insert_columns(self, fields: Any) -> Any: ...
|
||||
def sequence_reset_by_name_sql(self, style: Any, sequences: Any) -> List[str]: ...
|
||||
def sequence_reset_sql(self, style: Any, model_list: Any) -> List[str]: ...
|
||||
def start_transaction_sql(self) -> str: ...
|
||||
def tablespace_sql(self, tablespace: Any, inline: bool = ...) -> str: ...
|
||||
def adapt_datefield_value(self, value: Any) -> Any: ...
|
||||
def adapt_datetimefield_value(self, value: Any) -> Any: ...
|
||||
def adapt_timefield_value(self, value: Any) -> Any: ...
|
||||
def combine_expression(self, connector: Any, sub_expressions: Any) -> Any: ...
|
||||
def bulk_insert_sql(self, fields: Any, placeholder_rows: Any) -> str: ...
|
||||
def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any) -> Any: ...
|
||||
def bulk_batch_size(self, fields: Any, objs: Any) -> int: ...
|
||||
def conditional_expression_supported_in_where_clause(self, expression: Any) -> bool: ...
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from typing import Any
|
||||
|
||||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor as BaseDatabaseSchemaEditor
|
||||
from django.db.backends.oracle.base import DatabaseWrapper
|
||||
|
||||
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
||||
connection: DatabaseWrapper
|
||||
sql_create_column: str = ...
|
||||
sql_alter_column_type: str = ...
|
||||
sql_alter_column_null: str = ...
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from typing import Any
|
||||
|
||||
from django.db.backends.base.validation import BaseDatabaseValidation as BaseDatabaseValidation
|
||||
from django.db.backends.oracle.base import DatabaseWrapper
|
||||
|
||||
class DatabaseValidation(BaseDatabaseValidation):
|
||||
connection: DatabaseWrapper
|
||||
def check_field_type(self, field: Any, field_type: Any): ...
|
||||
|
||||
Reference in New Issue
Block a user