-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typing: use mypy to verify runtime behaviour matches type stubs #338
Comments
I did use stubtest, but that turns out to check stubs exists and are syntactically valid. The primary bug here is that I should also use mypy to verify that runtime behaviour matches the types. Changing title to match. |
Cursor
is not iterable, and Cursor.execute()
doesn't return Cursor
Although cursor is an iterator. Refs #338
FYI: It's probably "fine" to release changes to type stubs that break the type-checking of existing users, in a non-breaking update of apsw. This is just the state of type checking in python. Every release of |
So far you've found bugs in the typing information, so I have no problem fixing them, just like any other bug. I am going to try to run the example code (exercises every api) under I was a bit surprised at having to expose the __iter__/__next__ methods since that machinery is not normally exposed (for example doc doesn't mention them). The type stubs for sqlite3 do so that is the right thing to do. I'll have to make sure it stays out of the doc though - currently the stubs are generated from the docstrings. |
Refs #338 As of this commit, the sample code in the issue works (open db, do a query). The example code has more issues to resolve like also accepting zeroblobs and the Shell.
Closing because this is 99% done |
I'm using apsw from pypi (thanks for that!)
I found some issues with the type stubs.
Some valid code that fails type-checking:
Cursor.execute()
returnsIterator
Cursor
. (Actually it should returntyping.Self
, but that's new in 3.11 beta, and there isn't a nice way to declare this in a backwards-compatible way yet)Cursor
doesn't expose__iter__()
/__next__()
in type stubs.Cursor.__iter__()
should returnCursor
(orSelf
)Cursor.__next__()
should returnAny
, or perhaps a narrower row type (IMO the row type should be narrower thanAny
, but I'll file a separate issue about this)The text was updated successfully, but these errors were encountered: