omnilib/aiosqlite

AsyncIterator[sqlite3.Row] is incompatible with row_factory

sbp opened this issue · 1 comments

sbp commented

Description

When a row_factory is set on a Connection, an arbitrary type may be returned instead of a row. In this case the type signature of Cursor.__aiter__and associated functions is wrong. It should be AsyncIterator[Any], not AsyncIterator[sqlite3.Row]. This causes a problem in e.g. mypy checking when code assumes characteristics of the output that are incompatible with sqlite3.Row. In such cases, mypy reports a false positive error.

Details

  • OS: n/a
  • Python version: n/a
  • aiosqlite version: HEAD, bdc6b5d
  • Can you repro on 'main' branch? yes
  • Can you repro in a clean virtualenv? yes

I think this could be better solved using Generic[...] on the Connection class.