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

Don't turn types containing None into partial types (in strict Optional mode) #2289

Merged
merged 1 commit into from
Oct 22, 2016

Conversation

ddfisher
Copy link
Collaborator

This means mypy will no longer give Need type annotation for variable errors for assignments with values of type Generator[str, None, None] or List[None] or similar. However, lists, sets, and dicts that are initialized with None values that were previously inferred may now need type annotations. I.e. constructs that look like:

x = [None]
x.append(0)

will now be type errors unless they have explicit annotations.

Supplants #2225. Fixes #2246. Fixes #2195. Fixes #2258.

[builtins fixtures/dict.pyi]
[out]
main:2: error: Invalid index type "str" for "dict"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off-topic: this ought to be "key type" not "index type".

@gvanrossum gvanrossum merged commit ad62a08 into master Oct 22, 2016
@gvanrossum gvanrossum deleted the none-collection-annotation branch October 22, 2016 00:18
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