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

types: more general type hint for type_hooks #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sinback
Copy link
Contributor

@sinback sinback commented Nov 27, 2020

Update the type hint for type_hooks to accept the more general Mapping rather than Dict. It looks like transform_value will work with any type_hooks that supports __getitem__, which the Mapping ABC / type signature requires that users do.

This makes the typechecker happier with us since I want to start using a Mapping implementation for a type_hooks that we use, to allow a little more flexibility. I can't think of any particular drawbacks to having a more general type hint here.

Out of self-interest, I added a test which I think will ensure dacite continues to support the use case I have in mind (tests a Mapping which is exactly like a dict but has an augmented __getitem__ method).

Also add a test to help ensure that type_hooks continues to work with a
very general Mapping implementation.
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