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