Skip to content

Better type hint for Connection.text_factory #179

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

Merged
merged 1 commit into from
Dec 16, 2022

Conversation

hellocoldworld
Copy link
Contributor

text_factory type hint was simply "Type" which is kinda right for the
most common cases of the parameter (str and bytes).

However, text_fatory can be any other callable that accepts a bytes
parameter and returns the resulting object as described in the docs for
sqlite3 python standard module.
(ref: https://docs.python.org/3/library/sqlite3.html )

In particular this fix is for support another common enough idiom,
which is setting

conn.text_factory = lambda b: b.decode(errors=ignore)

text_factory type hint was simply "Type" which is kinda right for the
most common cases of the parameter (str and bytes).

However, text_fatory can be any other callable that accepts a bytes
parameter and returns the resulting object as described in the docs for
sqlite3 python standard module.
(ref: https://docs.python.org/3/library/sqlite3.html )

In particular this fix is for support another common enough idiom,
which is setting

`conn.text_factory = lambda b: b.decode(errors=ignore)`
@hellocoldworld
Copy link
Contributor Author

Hi, have you been able to review this?

@amyreese amyreese merged commit b92dec8 into omnilib:main Dec 16, 2022
@amyreese
Copy link
Member

Sorry I missed that! Thank you 😊

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.

None yet

2 participants