1
1
from typing import Any
2
+ from typing import Callable
3
+ from typing import FrozenSet
2
4
from typing import Generic
5
+ from typing import MutableMapping
3
6
from typing import Optional
7
+ from typing import Tuple
8
+ from typing import Type
4
9
from typing import TypeVar
5
10
from typing import Union
6
11
@@ -12,11 +17,14 @@ from .mapper import Mapper as Mapper
12
17
from .. import inspection as inspection
13
18
from .. import util as util
14
19
from ..sql import ColumnElement
20
+ from ..sql import FromClause
15
21
from ..sql .schema import MetaData as MetaData
16
22
from ..util import hybridmethod as hybridmethod
17
23
from ..util import hybridproperty as hybridproperty
18
24
19
- def has_inherited_table (cls ): ...
25
+ _T = TypeVar ("_T" )
26
+
27
+ def has_inherited_table (cls : type ) -> bool : ...
20
28
21
29
class DeclarativeMeta (type ):
22
30
def __init__ (
@@ -25,13 +33,10 @@ class DeclarativeMeta(type):
25
33
def __setattr__ (cls , key : Any , value : Any ) -> None : ...
26
34
def __delattr__ (cls , key : Any ) -> None : ...
27
35
metadata : MetaData
28
- registry : "registry"
36
+ registry : _registry # Avoid circural reference
29
37
30
38
def synonym_for (name : Any , map_column : bool = ...): ...
31
39
32
- _T = TypeVar ("_T" )
33
- _Generic_T = Generic [_T ]
34
-
35
40
class declared_attr (interfaces ._MappedAttribute , property , Generic [_T ]):
36
41
__doc__ : Any = ...
37
42
def __init__ (self , fget : Any , cascading : bool = ...) -> None : ...
@@ -46,42 +51,51 @@ class _stateful_declared_attr(declared_attr):
46
51
def __call__ (self , fn : Any ): ...
47
52
48
53
def declarative_base (
49
- bind : Optional [Any ] = ...,
50
- metadata : Optional [Any ] = ...,
51
- mapper : Optional [Any ] = ...,
52
- cls : Any = ...,
54
+ bind : Optional [
55
+ Any
56
+ ] = ..., # NOTE: Deprecated in 1.4, to be removed in 2.0.
57
+ metadata : Optional [MetaData ] = ...,
58
+ mapper : Optional [Callable [..., Mapper ]] = ...,
59
+ cls : Union [type , Tuple [type , ...]] = ...,
53
60
name : str = ...,
54
- constructor : Any = ...,
55
- class_registry : Optional [Any ] = ...,
56
- metaclass : Any = ...,
57
- ): ...
61
+ constructor : Callable [..., None ] = ...,
62
+ class_registry : Optional [MutableMapping [ Any , Any ] ] = ...,
63
+ metaclass : type = ...,
64
+ ) -> type : ...
58
65
59
66
class registry :
60
- metadata : Any = ...
61
- constructor : Any = ...
67
+ metadata : MetaData
68
+ constructor : Callable [ ..., None ]
62
69
def __init__ (
63
70
self ,
64
- metadata : Optional [Any ] = ...,
65
- class_registry : Optional [Any ] = ...,
66
- constructor : Any = ...,
71
+ metadata : Optional [MetaData ] = ...,
72
+ class_registry : Optional [MutableMapping [ Any , Any ] ] = ...,
73
+ constructor : Callable [..., None ] = ...,
67
74
_bind : Optional [Any ] = ...,
68
75
) -> None : ...
69
76
@property
70
- def mappers (self ): ...
77
+ def mappers (self ) -> FrozenSet [ Mapper ] : ...
71
78
def configure (self , cascade : bool = ...) -> None : ...
72
79
def dispose (self , cascade : bool = ...) -> None : ...
73
80
def generate_base (
74
81
self ,
75
- mapper : Optional [Any ] = ...,
76
- cls : Any = ...,
82
+ mapper : Optional [Callable [..., Mapper ] ] = ...,
83
+ cls : Union [ type , Tuple [ type , ...]] = ...,
77
84
name : str = ...,
78
- metaclass : Any = ...,
79
- ): ...
80
- def mapped (self , cls : Any ): ...
81
- def as_declarative_base (self , ** kw : Any ): ...
85
+ metaclass : type = ...,
86
+ ) -> type : ...
87
+ def mapped (self , cls : Type [_T ]) -> Type [_T ]: ...
88
+ def as_declarative_base (
89
+ self , ** kw : Any
90
+ ) -> Callable [[Type [_T ]], Type [_T ]]: ...
82
91
def map_declaratively (self , cls : type ) -> Mapper : ...
83
92
def map_imperatively (
84
- self , class_ : Any , local_table : Optional [Any ] = ..., ** kw : Any
85
- ): ...
93
+ self ,
94
+ class_ : type ,
95
+ local_table : Optional [FromClause ] = ...,
96
+ ** kw : Any ,
97
+ ) -> Mapper : ...
98
+
99
+ _registry = registry
86
100
87
- def as_declarative (** kw : Any ): ...
101
+ def as_declarative (** kw : Any ) -> Callable [[ Type [ _T ]], Type [ _T ]] : ...
0 commit comments