Skip to content

Commit

Permalink
fix: use a custom staticmethod decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau committed Feb 4, 2024
1 parent 2f1a0f0 commit 2c840e9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion geetools/ComputedObject/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
from geetools.types import pathlike


# this hack is necessary for backward compatibility with Python < 3.10
# for earlier version, staticmethod and classmethod were simply descriptors of the function
# making it impossible to call it from outside the class scope or to decorate it.
class _StaticMethod:
def __init__(self, func):
self.func = func

def __get__(self, instance, owner=None):
return self.func


# -- types management ----------------------------------------------------------
@_register_extention(ee.ComputedObject)
def isInstance(self, klass: Type) -> ee.Number:
Expand Down Expand Up @@ -68,7 +79,7 @@ def save(self, path: pathlike) -> Path:
return path


@staticmethod # type: ignore
@_StaticMethod # type: ignore
@_register_extention(ee.ComputedObject) # type: ignore
def open(path: pathlike) -> ee.ComputedObject:
"""Open a .gee file as a ComputedObject.
Expand Down

0 comments on commit 2c840e9

Please sign in to comment.