-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Remove Any from _NotImplementedType inheritance #13488
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
Conversation
It does seem like this was first added in ecb4314 and does not serve a bigger purpose.
|
Nevermind, there are probably a lot of issues around this, because we want to be able to return this in all Closing, because this is clearly the wrong idea if we don't want to do quite a bit of work in type checkers (even though I personally don't like the Any in there). |
|
Diff from mypy_primer, showing the effect of this PR on open source code: Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/annotations.py:2324: error: Dict entry 0 has incompatible type "type[Attachment]": "_NotImplementedType"; expected "Any": "tuple[Callable[..., Any], ...]" [dict-item]
+ tanjun/annotations.py:2326: error: Dict entry 2 has incompatible type "type[PartialChannel]": "_NotImplementedType"; expected "Any": "tuple[Callable[..., Any], ...]" [dict-item]
+ tanjun/annotations.py:2327: error: Dict entry 3 has incompatible type "type[InteractionChannel]": "_NotImplementedType"; expected "Any": "tuple[Callable[..., Any], ...]" [dict-item]
+ tanjun/annotations.py:2331: error: Dict entry 7 has incompatible type "type[InteractionMember]": "_NotImplementedType"; expected "Any": "tuple[Callable[..., Any], ...]" [dict-item]
+ tanjun/annotations.py:2451: error: Non-overlapping identity check (left operand type: "tuple[Callable[..., Any], ...]", right operand type: "_NotImplementedType") [comparison-overlap]
scipy (https://github.com/scipy/scipy)
+ scipy/optimize/_trustregion_constr/report.py:4: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "list[str]") [assignment]
+ scipy/optimize/_trustregion_constr/report.py:5: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "list[int]") [assignment]
+ scipy/optimize/_trustregion_constr/report.py:6: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "list[str]") [assignment]
+ scipy/integrate/_ivp/rk.py:76: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "ndarray[Any, Any]") [assignment]
+ scipy/integrate/_ivp/rk.py:77: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "ndarray[Any, Any]") [assignment]
+ scipy/integrate/_ivp/rk.py:78: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "ndarray[Any, Any]") [assignment]
+ scipy/integrate/_ivp/rk.py:79: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "ndarray[Any, Any]") [assignment]
+ scipy/integrate/_ivp/rk.py:80: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "ndarray[Any, Any]") [assignment]
+ scipy/integrate/_ivp/rk.py:81: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "int") [assignment]
+ scipy/integrate/_ivp/rk.py:82: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "int") [assignment]
+ scipy/integrate/_ivp/rk.py:83: error: Incompatible types in assignment (expression has type "_NotImplementedType", variable has type "int") [assignment]
beartype (https://github.com/beartype/beartype)
- beartype/_conf/confcls.py:1276: error: Unused "type: ignore" comment [unused-ignore]
- beartype/_check/metadata/metasane.py:183: error: Unused "type: ignore" comment [unused-ignore]
manticore (https://github.com/trailofbits/manticore)
+ manticore/platforms/linux.py:328: error: Exception must be derived from BaseException [misc]
+ manticore/platforms/linux.py:331: error: Exception must be derived from BaseException [misc]
+ manticore/platforms/linux.py:334: error: Exception must be derived from BaseException [misc]
+ manticore/platforms/linux.py:341: error: Exception must be derived from BaseException [misc]
+ manticore/platforms/linux.py:344: error: Exception must be derived from BaseException [misc]
+ manticore/platforms/linux.py:347: error: Exception must be derived from BaseException [misc]
+ manticore/platforms/linux.py:350: error: Exception must be derived from BaseException [misc]
+ manticore/platforms/linux.py:353: error: Exception must be derived from BaseException [misc]
|
|
Yes, this is probably necessary until we gain some smarter handling for NotImplemented in dunders. The primer output is surprisingly small though, and at least some of them are true positives (e.g. the manticore ones are |
|
Yes, it is indeed very surprising how low the fallout is. I stumbled upon this, because Mypy was fixing the case around |
It does seem like this was first added in ecb4314 and does not serve a bigger purpose.
I hope the fallout is not too big in Mypy primer, but we'll see.