aiosqlite icon indicating copy to clipboard operation
aiosqlite copied to clipboard

AsyncIterator[sqlite3.Row] is incompatible with row_factory

Open sbp opened this issue 3 years ago • 1 comments

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

sbp avatar Oct 05 '22 11:10 sbp

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

amyreese avatar Apr 17 '23 06:04 amyreese