Skip to content

add cysqlite to typeshed#15502

Open
Vizonex wants to merge 24 commits intopython:mainfrom
Vizonex:cysqlite
Open

add cysqlite to typeshed#15502
Vizonex wants to merge 24 commits intopython:mainfrom
Vizonex:cysqlite

Conversation

@Vizonex
Copy link

@Vizonex Vizonex commented Mar 10, 2026

I have created type stubs for cysqlite so that a separate package does not need inventing I have a library that needs these type hints called anyio-cysqlite that uses this package and having type hints that are readily accessible and available for it is extremely helpful. I have already made a pull request to that repo and having had it turned down I decided to put everything into here instead.

SEE:

The alternative and final option is to maintain it myself which I do not see as being a feasible option at the moment.

fixes #15469

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Vizonex
Copy link
Author

Vizonex commented Mar 11, 2026

It's ready for review.

Copy link
Collaborator

@brianschubert brianschubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did an initial pass, see comments below. Please check the allowlist entries; the few I spot checked seem to be valid errors that should be corrected. Thanks!

Comment on lines +2 to +3
cysqlite.Connection
cysqlite.Connection.commit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comment(s) indicating why the allowlist entries are necessary.

Spot checking the first few errors from this run: https://github.com/python/typeshed/actions/runs/22920350806/job/66516765808, many of these look like valid errors that should be corrected in the stubs.

For example:

error: cysqlite.Connection is marked as @disjoint_base, but also marked as @final; remove @disjoint_base
Stub: in file /home/runner/work/typeshed/typeshed/stubs/cysqlite/cysqlite/__init__.pyi:108
<TypeInfo cysqlite._cysqlite.Connection>
Runtime:
<class 'cysqlite._cysqlite.Connection'>

This is correct - Connection shouldn't be marked as both @final and @disjoint_base.

error: cysqlite.Connection.commit is inconsistent, runtime does not have parameter "begin"
Stub: in file /home/runner/work/typeshed/typeshed/stubs/cysqlite/cysqlite/__init__.pyi:162
def (self: cysqlite._cysqlite.Connection, begin: builtins.bool =) -> Any
Runtime:
def (self)

This appears correct - the runtime method does not have a begin parameter: https://github.com/coleifer/cysqlite/blob/861ea9e7965c4770e29cc50a726bd06164ca47a8/src/cysqlite/_cysqlite.pyx#L1111

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is multiple different ways commit is used there is a couple commit functions where begin is needed unless it's is in the main Connection class and Cursor class. Those are the only few that do not require a begin. The other in relation to Atomic, such as a Savepoint and Transaction need it to be visable.

restart: bool
name: str | Buffer | None

SHUTDOWN: object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants can be marked as Final.

(review note: this sentinel isn't exposed to the user, so there's no need to use the usual sentinel patterns)

check_table_sizes: bool = False,
dry_run: bool = False,
) -> Cursor: ...
def pragma(self, key: str, value: Any = ..., database: str | None = None, multi: bool = False) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def pragma(self, key: str, value: Any = ..., database: str | None = None, multi: bool = False) -> None: ...
def pragma(self, key: str, value: Any = sentinel, database: str | None = None, multi: bool = False) -> None: ...

and import from _typeshed import sentinel. See the definition in _typeshed for details

@Vizonex Vizonex requested a review from brianschubert March 13, 2026 02:17
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Cysqlite to typeshed

2 participants