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

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

trim21
Copy link
Contributor

@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]

@trim21
Copy link
Contributor Author

trim21 commented Nov 27, 2024

@konradhalas hi, is it possible to get a code review on this PR?

@trim21
Copy link
Contributor Author

trim21 commented Jan 27, 2025

@mciszczon can you take a look?

@mciszczon
Copy link
Collaborator

@mciszczon can you take a look?

Thanks for pinging me @trim21, seems like a fairly unproblematic addition. Let me ensure it doesn't break anything and we can probably merge it in upcoming days, and sketch out a new release together with #269.

@mciszczon mciszczon changed the base branch from master to feature/generics January 27, 2025 15:13
@mciszczon mciszczon merged commit b3d55f8 into konradhalas:feature/generics Jan 27, 2025
@trim21 trim21 deleted the improve-data-typing branch January 27, 2025 15:47
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.

2 participants