Skip to content

Commit

Permalink
Added overload signature for query select with a function
Browse files Browse the repository at this point in the history
  • Loading branch information
daveraja committed Mar 4, 2024
1 parent 92a292a commit 846b3ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions clorm/orm/_queryimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,11 @@ def group_by(self, *expressions: Any) -> "GroupedQuery[Any, _T]":
# --------------------------------------------------------------------------
# Explicitly select the elements to output or delete
# --------------------------------------------------------------------------

@overload
def select(self, __ent0: Callable[..., _T0]) -> "UnGroupedQuery[_T0]":
...

# START OVERLOADED FUNCTIONS self.select;UnGroupedQuery[{0}];1;5;Type;Y

# code within this block is **programmatically,
Expand Down Expand Up @@ -1153,6 +1158,10 @@ def group_by(self, *expressions):
# doesn't need to implement group_by
raise ValueError("Cannot specify 'group_by' multiple times")

@overload
def select(self, __ent0: Callable[..., _T0]) -> "GroupedQuery[_KT, _T0]":
...

# START OVERLOADED FUNCTIONS self.select;GroupedQuery[_KT, {0}];1;5;Type;Y

# code within this block is **programmatically,
Expand Down
2 changes: 1 addition & 1 deletion clorm/orm/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def functor(self):

def func(paths: List[Any], functor: Callable[..., _T]) -> _T:
"""Return a wrapped functor for use in a 'query' where or 'select' clause"""
return FuncInputSpec(paths, functor)
return cast(_T, FuncInputSpec(paths, functor))

# Note: used to just return a FunctionComparator but that is only suitable
# for a where clause
Expand Down

0 comments on commit 846b3ab

Please sign in to comment.