-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Labels
Description
A user should be able to annotate an argument/variable that is expected to take rows of a specific table/join/etc. For example:
class BasicData(SQLResult):
id: int
name: str
We can also support a Python 2 compatible syntax like for named tuples. This type should be added to an actual tiny runtime package that will be shipped with stubs/plugins. This should be accompanied by
at least two plugin hooks:
- One type analyzer hook that will transform an occurrence
BasicData
into something likeSQLResult[TypedDict(x=int, name=str)]
(SQLResult
should be declared a subclass ofRowProxy
) - Another hook for attribute access, so that
SQLResult
will provide bothNamedTuple
- andTypedDict
-like APIs (to match runtime magic).
Note that SQLResult
, Iterable[SQLResult]
can be used as a more precise result for some functions in #4.