Skip to content

Commit 842350d

Browse files
Fix column __init__ args typing for EventSchemaTarget (#73)
* Fix column __init__ args typing for EventSchemaTarget * Add Column.__init__ kwargs * Fix import of literal from typing_extensions * Fix column __init__ for name and type args and kwargs * Revent SchemaInfo.info back to memoized_property. * Remove Column name and type keyword-arguments * Address review comments Co-authored-by: Federico Caselli <cfederico87@gmail.com>
1 parent 786d46c commit 842350d

File tree

1 file changed

+80
-11
lines changed

1 file changed

+80
-11
lines changed

sqlalchemy-stubs/sql/schema.pyi

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ from typing import Generic
55
from typing import Iterable
66
from typing import Iterator
77
from typing import List
8+
from typing import Mapping
89
from typing import Optional
910
from typing import overload
1011
from typing import Set
1112
from typing import Type
1213
from typing import TypeVar
1314
from typing import Union
1415

16+
from typing_extensions import Literal
17+
1518
from . import functions
1619
from . import roles
1720
from . import sqltypes
@@ -22,6 +25,7 @@ from .base import DialectKWArgs
2225
from .base import SchemaEventTarget
2326
from .elements import ClauseElement
2427
from .elements import ColumnClause
28+
from .elements import TextClause
2529
from .selectable import TableClause
2630
from .. import util
2731
from ..engine import Connection
@@ -121,40 +125,105 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_TE]):
121125
primary_key: bool = ...
122126
nullable: bool = ...
123127
default: Optional[Any] = ...
124-
server_default: Optional[Any] = ...
128+
server_default: Optional[Union[FetchedValue, str, TextClause]] = ...
125129
server_onupdate: Optional[FetchedValue] = ...
126130
index: Optional[bool] = ...
127131
unique: Optional[bool] = ...
128132
system: bool = ...
129133
doc: Optional[str] = ...
130134
onupdate: Optional[Any] = ...
131-
autoincrement: Union[bool, str] = ...
135+
autoincrement: Union[bool, Literal["auto", "ignore_fk"]] = ...
132136
constraints: Set[Constraint] = ...
133137
foreign_keys: Set[ForeignKey] = ...
134138
comment: Optional[str] = ...
135139
computed: Optional[Computed] = ...
136140
identity: Optional[Identity] = ...
137141
@overload
138142
def __init__(
139-
self, name: str, typ: Union[_TE, Type[_TE]], *args: Any, **kwargs: Any
143+
self: Column[sqltypes.NullType],
144+
__name: str,
145+
*args: SchemaEventTarget,
146+
autoincrement: Union[bool, Literal["auto", "ignore_fk"]] = ...,
147+
default: Optional[Any] = ...,
148+
doc: Optional[str] = ...,
149+
key: Optional[str] = ...,
150+
index: Optional[bool] = ...,
151+
info: Mapping[Any, Any] = ...,
152+
nullable: bool = ...,
153+
onupdate: Optional[Any] = ...,
154+
primary_key: bool = ...,
155+
server_default: Optional[Union[FetchedValue, str, TextClause]] = ...,
156+
server_onupdate: Optional[FetchedValue] = ...,
157+
quote: Optional[bool] = ...,
158+
unique: Optional[bool] = ...,
159+
system: bool = ...,
160+
comment: Optional[str] = ...,
161+
**kwargs: Any,
140162
) -> None: ...
141163
@overload
142164
def __init__(
143-
self, typ: Union[_TE, Type[_TE]], *args: Any, **kwargs: Any
165+
self: Column[sqltypes.NullType],
166+
*args: SchemaEventTarget,
167+
autoincrement: Union[bool, Literal["auto", "ignore_fk"]] = ...,
168+
default: Optional[Any] = ...,
169+
doc: Optional[str] = ...,
170+
key: Optional[str] = ...,
171+
index: Optional[bool] = ...,
172+
info: Mapping[Any, Any] = ...,
173+
nullable: bool = ...,
174+
onupdate: Optional[Any] = ...,
175+
primary_key: bool = ...,
176+
server_default: Optional[Union[FetchedValue, str, TextClause]] = ...,
177+
server_onupdate: Optional[FetchedValue] = ...,
178+
quote: Optional[bool] = ...,
179+
unique: Optional[bool] = ...,
180+
system: bool = ...,
181+
comment: Optional[str] = ...,
182+
**kwargs: Any,
144183
) -> None: ...
145184
@overload
146185
def __init__(
147-
self: Column[sqltypes.NullType],
148-
name: str,
149-
typ: None = ...,
150-
*args: Any,
186+
self,
187+
__name: str,
188+
__type: Union[_TE, Type[_TE]],
189+
*args: SchemaEventTarget,
190+
autoincrement: Union[bool, Literal["auto", "ignore_fk"]] = ...,
191+
default: Optional[Any] = ...,
192+
doc: Optional[str] = ...,
193+
key: Optional[str] = ...,
194+
index: Optional[bool] = ...,
195+
info: Mapping[Any, Any] = ...,
196+
nullable: bool = ...,
197+
onupdate: Optional[Any] = ...,
198+
primary_key: bool = ...,
199+
server_default: Optional[Union[FetchedValue, str, TextClause]] = ...,
200+
server_onupdate: Optional[FetchedValue] = ...,
201+
quote: Optional[bool] = ...,
202+
unique: Optional[bool] = ...,
203+
system: bool = ...,
204+
comment: Optional[str] = ...,
151205
**kwargs: Any,
152206
) -> None: ...
153207
@overload
154208
def __init__(
155-
self: Column[sqltypes.NullType],
156-
typ: None = ...,
157-
*args: Any,
209+
self,
210+
__type: Union[_TE, Type[_TE]],
211+
*args: SchemaEventTarget,
212+
autoincrement: Union[bool, Literal["auto", "ignore_fk"]] = ...,
213+
default: Optional[Any] = ...,
214+
doc: Optional[str] = ...,
215+
key: Optional[str] = ...,
216+
index: Optional[bool] = ...,
217+
info: Mapping[Any, Any] = ...,
218+
nullable: bool = ...,
219+
onupdate: Optional[Any] = ...,
220+
primary_key: bool = ...,
221+
server_default: Optional[Union[FetchedValue, str, TextClause]] = ...,
222+
server_onupdate: Optional[FetchedValue] = ...,
223+
quote: Optional[bool] = ...,
224+
unique: Optional[bool] = ...,
225+
system: bool = ...,
226+
comment: Optional[str] = ...,
158227
**kwargs: Any,
159228
) -> None: ...
160229
def references(self, column: Column[Any]) -> bool: ...

0 commit comments

Comments
 (0)