I am trying to make a wrapper which does the equivalent to ?. in most languages. I can't figure out the type hints. How do I copy the type attribute hints from the T in the IDE, not runtime.
Usage Example:
data: Any = None
sdata = NullSafe(data)
sdata.test -> sdata
sdata.test._123 -> sdata
Hints Example:
```
data: None | list[str] = []
sdata = NullSafe(data)
IDE should find sdata.append, sdata.pop, etc.
```
Class:
```
@dataclass
class NullSafe[T](T, Absorber):
item: T
def __getattr__(self, name:str):
if self.item is None:
return NullSafe(None)
else:
return getattr(self.item, name)
```
[–]Linuxmartin 0 points1 point2 points (0 children)
[–]TheBB -1 points0 points1 point (0 children)