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

Treating NoneType as None and warning against using NoneType. #13153

Merged
merged 1 commit into from
Jul 17, 2022
Merged

Treating NoneType as None and warning against using NoneType. #13153

merged 1 commit into from
Jul 17, 2022

Conversation

strny0
Copy link
Contributor

@strny0 strny0 commented Jul 16, 2022

Description

Fixes #11288

Warns people to not use NoneType as a type annotation, as requested in #11288.

Example

Before

from types import NoneType

def f(x: NoneType) -> None:
    pass

f(None) # E: Argument 1 to "f" has incompatible type "None"; expected "NoneType"

After

from types import NoneType

def f(x: NoneType) -> None: # E: NoneType should not be used as a type, please use None instead 
    pass

f(None)

Had to edit test-data/unit/lib-stub/types.pyi to allow NoneType type annotation.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks, this lgtm

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@ilevkivskyi ilevkivskyi merged commit baf4af4 into python:master Jul 17, 2022
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.

(🎁) Warn when NoneType is used in a type
3 participants