Cursor, Blob, and Backup are not members of the apsw module, as explained here:
|
/* we don't add cursor, blob or backup to the module since users shouldn't be able to instantiate them directly */ |
However, instantiating is not the only reason for exposing a class. Maybe people want to use isinstance, for example. However I think the most compelling use case is to support PEP 484 type hints. Right now, in a file where all other function parameters are annotated, we have the choice to either leave a function unannotated (or annotated as Any which is not much better), or to try to get the Cursor type manually with e.g. Cursor = type(apsw.Connection(":memory:").cursor()) and use that to annotate our functions. Neither of these are particularly satisfying; it would be nicer if apsw.Cursor and friends were directly accessible, even if they are not directly instantiable.
Cursor,Blob, andBackupare not members of theapswmodule, as explained here:apsw/src/apsw.c
Line 1303 in d0ce7ac
However, instantiating is not the only reason for exposing a class. Maybe people want to use
isinstance, for example. However I think the most compelling use case is to support PEP 484 type hints. Right now, in a file where all other function parameters are annotated, we have the choice to either leave a function unannotated (or annotated asAnywhich is not much better), or to try to get theCursortype manually with e.g.Cursor = type(apsw.Connection(":memory:").cursor())and use that to annotate our functions. Neither of these are particularly satisfying; it would be nicer ifapsw.Cursorand friends were directly accessible, even if they are not directly instantiable.