Skip to content

Commit b64325e

Browse files
authored
Improve engine.reflection (#102)
1 parent 14eab1e commit b64325e

File tree

1 file changed

+61
-47
lines changed

1 file changed

+61
-47
lines changed
Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,83 @@
11
from typing import Any
2+
from typing import Collection
3+
from typing import Dict
4+
from typing import List
25
from typing import Optional
6+
from typing import Set
7+
from typing import Tuple
8+
from typing import Type
9+
from typing import TypeVar
310

4-
from .base import Connectable as Connectable
5-
from .base import Connection as Connection
6-
from .base import Engine as Engine
7-
from .. import exc as exc
8-
from .. import inspection as inspection
9-
from .. import sql as sql
10-
from .. import util as util
11-
from ..sql import operators as operators
12-
from ..sql.type_api import TypeEngine as TypeEngine
13-
from ..util import topological as topological
11+
from .base import Connectable
12+
from ..sql.schema import Table
1413

15-
def cache(fn: Any, self: Any, con: Any, *args: Any, **kw: Any): ...
14+
_TInspector = TypeVar("_TInspector", bound=Inspector)
15+
16+
def cache(fn: Any, self: Any, con: Any, *args: Any, **kw: Any) -> Any: ...
1617

1718
class Inspector:
18-
def __init__(self, bind: Any): ...
19+
def __init__(self, bind: Connectable): ...
1920
@classmethod
20-
def from_engine(cls, bind: Any): ...
21+
def from_engine(
22+
cls: Type[_TInspector], bind: Connectable
23+
) -> _TInspector: ...
2124
@property
22-
def default_schema_name(self): ...
23-
def get_schema_names(self): ...
24-
def get_table_names(self, schema: Optional[Any] = ...): ...
25-
def has_table(self, table_name: Any, schema: Optional[Any] = ...): ...
25+
def default_schema_name(self) -> str: ...
26+
def get_schema_names(self) -> List[str]: ...
27+
def get_table_names(self, schema: Optional[str] = ...) -> List[str]: ...
28+
def has_table(
29+
self, table_name: str, schema: Optional[str] = ...
30+
) -> bool: ...
2631
def has_sequence(
27-
self, sequence_name: Any, schema: Optional[Any] = ...
28-
): ...
29-
def get_sorted_table_and_fkc_names(self, schema: Optional[Any] = ...): ...
30-
def get_temp_table_names(self): ...
31-
def get_temp_view_names(self): ...
32+
self, sequence_name: str, schema: Optional[str] = ...
33+
) -> bool: ...
34+
def get_sorted_table_and_fkc_names(
35+
self, schema: Optional[str] = ...
36+
) -> List[Tuple[Optional[str], List[Tuple[str, str]]]]: ...
37+
def get_temp_table_names(self) -> List[str]: ...
38+
def get_temp_view_names(self) -> List[str]: ...
3239
def get_table_options(
33-
self, table_name: Any, schema: Optional[Any] = ..., **kw: Any
34-
): ...
35-
def get_view_names(self, schema: Optional[Any] = ...): ...
36-
def get_sequence_names(self, schema: Optional[Any] = ...): ...
40+
self, table_name: str, schema: Optional[str] = ..., **kw: Any
41+
) -> Dict[str, Any]: ...
42+
def get_view_names(self, schema: Optional[str] = ...) -> List[str]: ...
43+
def get_sequence_names(self, schema: Optional[str] = ...) -> List[str]: ...
3744
def get_view_definition(
38-
self, view_name: Any, schema: Optional[Any] = ...
39-
): ...
45+
self, view_name: str, schema: Optional[str] = ...
46+
) -> Any: ...
4047
def get_columns(
41-
self, table_name: Any, schema: Optional[Any] = ..., **kw: Any
42-
): ...
48+
self, table_name: str, schema: Optional[str] = ..., **kw: Any
49+
) -> List[Dict[str, Any]]: ...
4350
def get_pk_constraint(
44-
self, table_name: Any, schema: Optional[Any] = ..., **kw: Any
45-
): ...
51+
self, table_name: str, schema: Optional[str] = ..., **kw: Any
52+
) -> Dict[str, Any]: ...
4653
def get_foreign_keys(
47-
self, table_name: Any, schema: Optional[Any] = ..., **kw: Any
48-
): ...
54+
self, table_name: str, schema: Optional[str] = ..., **kw: Any
55+
) -> List[Dict[str, Any]]: ...
4956
def get_indexes(
50-
self, table_name: Any, schema: Optional[Any] = ..., **kw: Any
51-
): ...
57+
self, table_name: str, schema: Optional[str] = ..., **kw: Any
58+
) -> List[Dict[str, Any]]: ...
5259
def get_unique_constraints(
53-
self, table_name: Any, schema: Optional[Any] = ..., **kw: Any
54-
): ...
60+
self, table_name: str, schema: Optional[str] = ..., **kw: Any
61+
) -> List[Dict[str, Any]]: ...
5562
def get_table_comment(
56-
self, table_name: Any, schema: Optional[Any] = ..., **kw: Any
57-
): ...
63+
self, table_name: str, schema: Optional[str] = ..., **kw: Any
64+
) -> Dict[str, Any]: ...
5865
def get_check_constraints(
59-
self, table_name: Any, schema: Optional[Any] = ..., **kw: Any
60-
): ...
61-
def reflecttable(self, *args: Any, **kwargs: Any): ...
66+
self, table_name: str, schema: Optional[str] = ..., **kw: Any
67+
) -> List[Dict[str, Any]]: ...
68+
def reflecttable(
69+
self,
70+
table: Table,
71+
include_columns: Collection[str],
72+
exclude_columns: Collection[str] = ...,
73+
resolve_fks: bool = ...,
74+
_extend_on: Set[Table] = ...,
75+
) -> None: ...
6276
def reflect_table(
6377
self,
64-
table: Any,
65-
include_columns: Any,
66-
exclude_columns: Any = ...,
78+
table: Table,
79+
include_columns: Collection[str],
80+
exclude_columns: Collection[str] = ...,
6781
resolve_fks: bool = ...,
68-
_extend_on: Optional[Any] = ...,
82+
_extend_on: Set[Table] = ...,
6983
) -> None: ...

0 commit comments

Comments
 (0)