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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the main uses of dol.sources.AttrContainer is to be able to wrap mappings (say dicts) that allow a user to use tab-completion to access values through a path of keys. For example, being able to write this:
value=a.key.path
instead of
value = a['key']['path']
With dol.sources.AttrContainer, tab-completion works in browser-based jupyter, but doesn't work in PyCharm.
Is there a magic/dunder method that I can add to make it work?
If I define attributes at class definition time, tab-completion works though.
classSettingAttrWithSetattr:
def__init__(self, **kwargs):
fork, vinkwargs.items():
setattr(self, k, v)
fromdol.sourcesimportAttrContainerdefwrap_mapping_with_attr_access(**kwargs):
returntype('A', (), kwargs)() # works# mk_instance = AttrContainer # (tab-completion) doesn't work (in pycharm)mk_instance=SettingAttrWithSetattr# (tab-completion) doesn't work (in pycharm)# mk_instance = wrap_mapping_with_attr_access # WORKS# mk_instance = WithHardCodedClassAttributes # WORKSa=mk_instance(apple=1, banana=2)
t=a.apple
setattr(a, 'cherry', 3)
tt=a.cherry# tab-complete DOES NOT worka.cherry=3tt=a.cherry# tab-complete works
One of the main uses of
dol.sources.AttrContainer
is to be able to wrap mappings (say dicts) that allow a user to use tab-completion to access values through a path of keys. For example, being able to write this:instead of
With
dol.sources.AttrContainer
, tab-completion works in browser-based jupyter, but doesn't work in PyCharm.Is there a magic/dunder method that I can add to make it work?
If I define attributes at class definition time, tab-completion works though.
┆Issue is synchronized with this Asana task by Unito
The text was updated successfully, but these errors were encountered: