Skip to content

Update *func* parameter annotation for sqlite3's create_function(). #8727

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

Closed
shawnbrown opened this issue Sep 12, 2022 · 1 comment
Closed

Comments

@shawnbrown
Copy link
Contributor

The func parameter type for sqlite3's create_function() is defined as callback | None (see docs) but the typeshed stub does not include None as a valid type. This is a long-undocumented feature that was only recently added to the docs (see related issue python/cpython#95235 and commit python/cpython@5012bed).

In stdlib/sqlite3/dbapi2.pyi, the annotation for this parameter currently reads func: Callable[..., _SqliteData] (link) but it should be changed to func: Callable[..., _SqliteData] | None:

if sys.version_info >= (3, 8):
    def create_function(
        self, name: str, narg: int, func: Callable[..., _SqliteData] | None, *, deterministic: bool = ...
    ) -> None: ...
else:
    def create_function(
        self, name: str, num_params: int, func: Callable[..., _SqliteData] | None
    ) -> None: ...
shawnbrown added a commit to shawnbrown/toron that referenced this issue Sep 12, 2022
TODO: Remove "type: ignore" comments after python/typeshed#8727 is resolved.
@srittau
Copy link
Collaborator

srittau commented Sep 12, 2022

Fixed in #8728.

@srittau srittau closed this as completed Sep 12, 2022
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

No branches or pull requests

2 participants