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

Y016 doesn't account for single member unions #484

Open
tusharsadhwani opened this issue May 3, 2024 · 3 comments
Open

Y016 doesn't account for single member unions #484

tusharsadhwani opened this issue May 3, 2024 · 3 comments
Labels

Comments

@tusharsadhwani
Copy link

For code like:

from typing import Union
x: Union[int, Union[int]]

Y016 should be raised but isn't.

@JelleZijlstra
Copy link
Collaborator

Seems more important to raise an error saying that the nested union is useless.

@tusharsadhwani
Copy link
Author

saying that the nested union is useless

More like a single member union Union[X] can always be replaced by X, I believe.

I'd be up for writing that rule. Y067? Does that work?

@JelleZijlstra
Copy link
Collaborator

I guess it's sort of redundant with Y037, which tells you to use | instead of Union. I wouldn't really be opposed to a PR here but I'm not convinced there's a serious problem our existing checks don't catch.

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

2 participants