Skip to content

Compatibility between typed dicts and instance types #2493

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
JukkaL opened this issue Nov 24, 2016 · 2 comments
Closed

Compatibility between typed dicts and instance types #2493

JukkaL opened this issue Nov 24, 2016 · 2 comments

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Nov 24, 2016

Currently the fallback type of typed dicts is Mapping[str, join(item_types)]. This might be too limiting for some typical use cases. For example, maybe a typed dict should be compatible with Dict[str, Any] (and vice versa).

One idea is to keep the fallback like that, but special case compatibility with Dict[str, Any] (maybe also MutableMapping[str, Any]).

We may want to wait until typed dict support is more complete and try it in practice with production code before deciding what to do with this.

@JukkaL
Copy link
Collaborator Author

JukkaL commented Nov 16, 2018

The current behavior seems flexible enough, and it's reasonably safe (Mapping[str, object] would actually be a safer fallback due to structural subtyping). I'm proposing to close this issue.

Interoperability with Dict[str, Any] types can be achieved through explicit casts.

@ilevkivskyi
Copy link
Member

OK, let's close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants