Skip to content

Conversation

@davidhalter
Copy link
Contributor

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.

It does seem like this was first added in ecb4314
and does not serve a bigger purpose.
@davidhalter
Copy link
Contributor Author

Nevermind, there are probably a lot of issues around this, because we want to be able to return this in all __eq__ methods.

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).

@github-actions
Copy link
Contributor

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]

@JelleZijlstra
Copy link
Member

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 raise NotImplemented that should be NotImplementedError). So maybe there's other special casing in mypy that makes this more tractable than it would seem.

@davidhalter
Copy link
Contributor Author

Yes, it is indeed very surprising how low the fallout is.

I stumbled upon this, because Mypy was fixing the case around manticore and I tried to implement it in my Mypy rewrite in Rust, see python/mypy#17890.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants