Replies: 2 comments 2 replies
-
A proxy type has been suggested a few times before, there's also this pre-existing issue: #802 |
Beta Was this translation helpful? Give feedback.
-
Most of those suggestions want the wrapping object's methods to be inaccessible. Some don't, and suggest an intersection type, but that is not good enough. If the wrapping class has a method with the same name as the wrapped class, but a different signature, I'd want the wrapped class's method to be the one called and hinted. The wrapped class should strictly be a fallback. I have a plugin which does this, but Pylance doesn't respect mypy plugins... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I encountered a problem in one of my projects, where I wanted to forward member accesses to a member of the class.
Something like this:
I thought this is kind of niche, but the moment I described it to a friend he pulled up his own class which does this.
Is this a common use case? If so, I have 2 ideas.
First idea (typing based):
This requires no language changes, just a new typing thingy.
This
Relay
type would mean exactly what we want - an attribute lookup should be forwarded toT
if it not found.Second idea (python based):
This requires a new python feature, which is essentially my specific use-case as a feature.
This is very similar to rust's
Deref
:What do you think? I'm looking for feedback.
Beta Was this translation helpful? Give feedback.
All reactions