Skip to content

Set TypedDicts to always be their declared type as opposed to the type inferred when instantiated (2) #3099

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 6 commits into from
Mar 31, 2017

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Mar 31, 2017

This is a slightly updated version of @rowillia's PR #2621.

Roy Williams and others added 6 commits January 6, 2017 14:06
TypedDicts appear to have explicitly decided not to accept subtypes on fields,
but this behavior is counter intuitive.  This made it so TypedDicts didn't
respect `Any` and caused problems with what should have been ducktype
compatible.  This also brings TypedDicts more in line with other container
types and with how fields on classes behave.

```python
from typing import Dict

def foo() -> Dict[float, object]:
    return {
        1: 32
    }
```

This fixes #2610
@JukkaL JukkaL merged commit 2f6d620 into master Mar 31, 2017
@gvanrossum gvanrossum deleted the rowillia-fix_typed_dict_duck_typing branch April 1, 2017 00:29
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