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
It's a duplicate from SO but as it seems to be either a bug or a limitation. so I narrowed down my question to the best IDE, i.e vscode
Context
I'm building an extention package on top of a Google API called Google Earth Engine: geetools. In short I want to add to an existing package object extra functions that are repetitive or complicated for new users.
The choice of using extention is dictated from the client VS server interaction of this API and I cannot use simple class definition if I want to remain server sided. The complete explaination and inspiration is documented here: https://geetools.readthedocs.io/en/latest/setup/pattern.html
Issue
My extentions are perfectly working but they remain undetected by Intellisence so I see no documentation and prototype when hover in VSCode, I cannot "go to definition" or even see the parameters names which makes it very difficult to use.
reproduce example
This is a completely unecessary overload of an empty class but it shows exactly what I perform and where it fails:
fromtypingimportCallableclassToto(object):
def__init__(self):
self.a=1defprint(self):
print(self.a)
defregister_class_accessor(klass: type, name: str) ->Callable:
"""Create an accessor through the provided namespace to a given class. Parameters: klass: The class to set the accessor to. name: The name of the accessor namespace Returns: The accessor function to to the class. """defdecorator(accessor: Callable) ->object:
classClassAccessor:
def__init__(self, name: str, accessor: Callable):
self.name, self.accessor=name, accessordef__get__(self, obj: object, *args) ->object:
returnself.accessor(obj)
# check if the accessor already exists for this classifhasattr(klass, name):
raiseAttributeError(f"Accessor {name} already exists for {klass}")
# register the accessor to the classsetattr(klass, name, ClassAccessor(name, accessor))
returnaccessorreturndecorator@register_class_accessor(Toto, "tools")classAccessor:
"""Toolbox for the ``Toto`` class."""def__init__(self, obj: ee.Array):
"""Initialize the Array class."""self._obj=objdeftool_print(self):
"""Print the array."""print(f"tool object: {self._obj.a}")
The calls work:
Toto().tools.tool_print()
>>>>toolobject: 1
but lookup is not working:
What should I modify in my code to make the accessor content detected ?
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
-
Note
It's a duplicate from SO but as it seems to be either a bug or a limitation. so I narrowed down my question to the best IDE, i.e vscode
Context
I'm building an extention package on top of a Google API called Google Earth Engine:
geetools
. In short I want to add to an existing package object extra functions that are repetitive or complicated for new users.The choice of using extention is dictated from the client VS server interaction of this API and I cannot use simple class definition if I want to remain server sided. The complete explaination and inspiration is documented here: https://geetools.readthedocs.io/en/latest/setup/pattern.html
Issue
My extentions are perfectly working but they remain undetected by Intellisence so I see no documentation and prototype when hover in VSCode, I cannot "go to definition" or even see the parameters names which makes it very difficult to use.
reproduce example
This is a completely unecessary overload of an empty class but it shows exactly what I perform and where it fails:
The calls work:
but lookup is not working:
What should I modify in my code to make the accessor content detected ?
Beta Was this translation helpful? Give feedback.
All reactions