-
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
Check for redundant object unions #283
Comments
Hmm, I'm not sure. Y041 and Y051 both essentially deal with special cases; since we're not a type checker, there's no easy, generalised way for us to answer the question "Is @twoertwein, have you seen this problem come up much in |
Not with edit: and something like |
See, e.g., the comment in typeshed. Personally, I'd be quite hesitant to ever use And to be fair to mypy, hashability does break all kinds of OOP norms in Python. Consider the following code. Is from typing import Hashable
class X(Hashable):
def __hash__(self) -> int:
return 42
class Y(X):
__hash__ = None |
Strictly speaking that's redundant, but you might often want that for documentation purposes :) |
good to know - pandas(-stubs) use it quite extensively. I assume the same applies to |
Yup! It's |
There was an attempt a while back to make the |
I'm closing this issue for now, but I'm happy to reopen if I see more evidence that this is a widespread issue :) |
This recently came up again in python/typeshed#8801 (comment) |
Hmm, looks like |
Though that's because of a mypy bug (python/mypy#13760). |
Relevant pyright discussion: microsoft/pyright#3949 |
I'd like a check similar to
Y041
, but for unions withobject
. Especially forobject | None
, coming from a Typescript background, it is not obvious to me that this type union is redundant, and I often make that mistake (or forget about it and leave it in a stub).The text was updated successfully, but these errors were encountered: