dropbox / dropbox/sqlalchemy-stubs

Implement SQLResult

Open
#9 2 comments 0 reactions 0 assignees View on GitHub
enhancement priority-high topic-plugins
Dominant language
Python
Stars
583
Forks
96
PR merge metrics
No merged PRs in 30d

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:
```python
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 like `SQLResult[TypedDict(x=int, name=str)]` (`SQLResult` should be declared a subclass of `RowProxy`)
* Another hook for attribute access, so that `SQLResult` will provide both `NamedTuple`- _and_ `TypedDict`-like APIs (to match runtime magic).

Note that `SQLResult`, `Iterable[SQLResult]` can be used as a more precise result for some functions in https://github.com/dropbox/sqlalchemy-stubs/issues/4.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.