11from collections .abc import Iterable
2- from typing import Any , NamedTuple
2+ from typing import Any , Literal , NamedTuple , type_check_only
33
44from django .db .backends .base .base import BaseDatabaseWrapper
55from django .db .backends .utils import CursorWrapper
66from django .db .models .base import Model
7+ from django .db .models .fields import Field
8+ from typing_extensions import NotRequired , TypedDict
79
810class TableInfo (NamedTuple ):
911 name : str
@@ -20,6 +22,19 @@ class FieldInfo(NamedTuple):
2022 default : str
2123 collation : str
2224
25+ @type_check_only
26+ class _ConstraintDict (TypedDict ):
27+ columns : list [str ]
28+ primary_key : bool
29+ unique : bool
30+ foreign_key : tuple [str , str ] | None
31+ check : bool
32+ index : bool
33+ orders : NotRequired [list [Literal ["ASC" , "DESC" ]]]
34+ type : NotRequired [str ]
35+ definition : NotRequired [str | None ]
36+ options : NotRequired [dict [str , str ] | None ]
37+
2338class BaseDatabaseIntrospection :
2439 data_types_reverse : Any
2540 connection : BaseDatabaseWrapper
@@ -28,14 +43,16 @@ class BaseDatabaseIntrospection:
2843 def get_field_type (self , data_type : str , description : FieldInfo ) -> str : ...
2944 def identifier_converter (self , name : str ) -> str : ...
3045 def table_names (self , cursor : CursorWrapper | None = None , include_views : bool = False ) -> list [str ]: ...
31- def get_table_list (self , cursor : CursorWrapper | None ) -> Any : ...
32- def get_table_description (self , cursor : CursorWrapper | None , table_name : str ) -> Any : ...
46+ def get_table_list (self , cursor : CursorWrapper ) -> list : ...
47+ def get_table_description (self , cursor : CursorWrapper , table_name : str ) -> list : ...
3348 def get_migratable_models (self ) -> Iterable [type [Model ]]: ...
3449 def django_table_names (self , only_existing : bool = False , include_views : bool = True ) -> list [str ]: ...
3550 def installed_models (self , tables : list [str ]) -> set [type [Model ]]: ...
3651 def sequence_list (self ) -> list [dict [str , str ]]: ...
37- def get_sequences (self , cursor : CursorWrapper | None , table_name : str , table_fields : Any = ()) -> Any : ...
38- def get_relations (self , cursor : CursorWrapper | None , table_name : str ) -> dict [str , tuple [str , str ]]: ...
39- def get_primary_key_column (self , cursor : CursorWrapper | None , table_name : str ) -> str | None : ...
40- def get_primary_key_columns (self , cursor : CursorWrapper | None , table_name : str ) -> list [str ] | None : ...
41- def get_constraints (self , cursor : CursorWrapper | None , table_name : str ) -> Any : ...
52+ def get_sequences (
53+ self , cursor : CursorWrapper , table_name : str , table_fields : Iterable [Field ] = ()
54+ ) -> list [dict ]: ...
55+ def get_relations (self , cursor : CursorWrapper , table_name : str ) -> dict [str , tuple [str , str ]]: ...
56+ def get_primary_key_column (self , cursor : CursorWrapper , table_name : str ) -> str | None : ...
57+ def get_primary_key_columns (self , cursor : CursorWrapper , table_name : str ) -> list [str ] | None : ...
58+ def get_constraints (self , cursor : CursorWrapper , table_name : str ) -> dict [str , _ConstraintDict ]: ...
0 commit comments