Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Typing for select of arbitrary length #839

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion sqlmodel/sql/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class SelectOfScalar(SelectBase[_T]):
Column, # type: ignore
Sequence, # type: ignore
Mapping, # type: ignore
Label, # type: ignore
UUID,
datetime,
float,
Expand All @@ -275,6 +276,7 @@ class SelectOfScalar(SelectBase[_T]):
Column, # type: ignore
Sequence, # type: ignore
Mapping, # type: ignore
Label, # type: ignore
UUID,
datetime,
float,
Expand All @@ -293,6 +295,7 @@ class SelectOfScalar(SelectBase[_T]):
Column, # type: ignore
Sequence, # type: ignore
Mapping, # type: ignore
Label, # type: ignore
UUID,
datetime,
float,
Expand All @@ -311,6 +314,7 @@ class SelectOfScalar(SelectBase[_T]):
Column, # type: ignore
Sequence, # type: ignore
Mapping, # type: ignore
Label, # type: ignore
UUID,
datetime,
float,
Expand All @@ -328,7 +332,7 @@ class SelectOfScalar(SelectBase[_T]):


@overload
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]:
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]: # type: ignore
...


Expand All @@ -337,6 +341,16 @@ def select(__ent0: _TScalar_0) -> SelectOfScalar[_TScalar_0]: # type: ignore
...


@overload
def select(*entities: _TCCA[_T0]) -> Select[Tuple[_T0, ...]]: # type: ignore
...


@overload
def select(*entities: _TScalar_0) -> Select[Tuple[_TScalar_0, ...]]: # type: ignore
...


# Generated overloads start


Expand Down
13 changes: 12 additions & 1 deletion sqlmodel/sql/expression.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ _TScalar_{{ i }} = TypeVar(
Column, # type: ignore
Sequence, # type: ignore
Mapping, # type: ignore
Label, # type: ignore
UUID,
datetime,
float,
Expand All @@ -273,7 +274,7 @@ _T{{ i }} = TypeVar("_T{{ i }}")
# Generated TypeVars end

@overload
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]:
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]: # type: ignore
...


Expand All @@ -282,6 +283,16 @@ def select(__ent0: _TScalar_0) -> SelectOfScalar[_TScalar_0]: # type: ignore
...


@overload
def select(*entities: _TCCA[_T0]) -> Select[Tuple[_T0, ...]]: # type: ignore
...


@overload
def select(*entities: _TScalar_0) -> Select[Tuple[_TScalar_0, ...]]: # type: ignore
...


# Generated overloads start

{% for signature in signatures %}
Expand Down