Skip to content

Allow to alias None #9402

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
Hibou57 opened this issue Sep 3, 2020 · 3 comments
Closed

Allow to alias None #9402

Hibou57 opened this issue Sep 3, 2020 · 3 comments
Labels

Comments

@Hibou57
Copy link

Hibou57 commented Sep 3, 2020

🚀 Feature

Allow aliasing like T = None.

Pitch

None as a type on its own, generally does not make sense except as a singleton type and it is used for optional types, which is just an union including None. But in some corner case, None is not a proper name (ex. cases where Void or Null or Unit matches better) and would need to be aliased and will still be used like None is.

I don’t know if there is anything against it in any PEP.

@Hibou57 Hibou57 added the feature label Sep 3, 2020
@JelleZijlstra
Copy link
Member

Supporting T = None as a type alias is problematic because it's difficult to distinguish between a type alias and a normal assignment (assigning global variables to None is quite common).

PEP 613 would solve this (you'd write T: TypeAlias = None), but isn't supported by mypy yet.

@gvanrossum
Copy link
Member

gvanrossum commented Sep 3, 2020 via email

@Hibou57
Copy link
Author

Hibou57 commented Sep 3, 2020

Done ::-P (PEP 613 seen to be the answer, indeed)

— Edit — Forget to open the issue first: #9404

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

No branches or pull requests

3 participants