-
Notifications
You must be signed in to change notification settings - Fork 23
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
Standardizing Union of Literal
and None
#424
Comments
If we do this, I'd prefer to standardize on |
I don't mind much either way, but I agree it would be nice for flake8-pyi to have an opinion on this, so we can standardise this across typeshed. |
Some of my thoughts:
But I don't feel strongly either way. |
Let's standardise on |
Also, it would be kind of strange (to me) to have an Union like |
Hey again! I should have the time this week so I thought I'd take a stab at this (in case none of you is already working on it?) |
You're very welcome to it! :D |
Literal["foo", None]
is equivalent toLiteral["foo"] | None
andOptional[Literal["foo"]]
. This came up a handful of times in my PR reviews on typeshed. I can still find usages of either form. Flake8-PYI should be able to detect simpleLiteral | None
unions (ie: as long as it's not aliased) and could help standardize its usage, if this feature is wanted.Ref. https://peps.python.org/pep-0586/#legal-parameters-for-literal-at-type-check-time
The text was updated successfully, but these errors were encountered: