Skip to content
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

improve Data typing #260

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

trim21
Copy link

@trim21 trim21 commented Aug 31, 2024

Data does not need to be a Mapping[str, Any] but just object with keys and __getitem__

This make it possible to use some dict-like object, for example asyncpg.Record without typing error.

for example, asyncpg.Record has keys() -> Iterable[str] bot not keys() -> KeysView[str], and we convert keys to set so it also doesn't need keys to return KeysView

before:

row = pg.fetchrow(...)
v = from_dict(..., row) # mypy raise typing error, asyncpg.Record doesn't satisfy Mapping[str, Any]

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.

1 participant