It's hard to write custom operators after the change of #4880 #4915
Replies: 1 comment 1 reply
-
Pyright already implemented this check for non-overloaded methods. I noticed that mypy was reporting this error for overloaded methods as well, which is what prompted me to implement it. Mypy generates errors for your code sample above. I can see some utility for the check, but I can also see how it can produce false positives in some cases. I think our options are:
I don't like the idea of creating a separate rule specifically for this check. It's too specific for its own rule. Plus, it's not clear whether it should be on by default in "basic" or "strict" mode. If it's not on by default in either, then it's not worth having the rule at all (option 1 or 2). My inclination is to go with option 2, which simply reverts the recent change. The change was prompted not by a user request but by my own observation that mypy was producing an error that pyright didn't detect. But that's probably not a good enough justification for the change if it's causing problems for existing pyright users. |
Beta Was this translation helpful? Give feedback.
-
Here's what I would typically write custom operators for a set of classes (a root class and several known subclasses)--
For simplicity, only addition is illustrated here.
After #4880, without any
type: ignore
s, the code would become --As we can see, the overrides in subclasses exist merely to provide method signatures, and they seem very repeating.
Even by using
type: ignore
s, there would be a lot of lines to modify because of the number of all kinds of operators. And as the issue is reported inreportGeneralTypeIssues
category, it would be preferred that theself
line be wrapped as an individual line to be ignored, which would cause additional nuisance.I'd expect #4880 be reverted, or a new category be created for it.
Edit
Use better samples and re-word.
Beta Was this translation helpful? Give feedback.
All reactions