I'm trying to type a generic class with a method that takes a parameter added to its generic attribute and returns a new instance. This is the slightly simplified example:
I would like to use something other than Any to annotate the bar parameter, but I cannot find a solution that correctly handles both self.value.__add__(bar) and bar.__radd__(self.value).
Add a bulleted list, <Ctrl+Shift+8>Add a numbered list, <Ctrl+Shift+7>Add a task list, <Ctrl+Shift+l>
Directly mention a user or teamReference an issue or pull request
Add heading textAdd bold text, <Ctrl+b>Add italic text, <Ctrl+i>Add a bulleted list, <Ctrl+Shift+8>Add a numbered list, <Ctrl+Shift+7>Add a task list, <Ctrl+Shift+l>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
-
I'm trying to type a generic class with a method that takes a parameter added to its generic attribute and returns a new instance. This is the slightly simplified example:
I would like to use something other than
Any
to annotate thebar
parameter, but I cannot find a solution that correctly handles bothself.value.__add__(bar)
andbar.__radd__(self.value)
.Any idea?
Beta Was this translation helpful? Give feedback.