Treat static methods as class methods instead of instance methods in actors (#6756)

* Treat static methods as class methods rather than instance methods

* Add tests for static methods in actors

* Revert formatting changes

* Readd future imports

* Restructure static method check

* Documentation enhancements

* Fix linting issues
This commit is contained in:
Ziyad Edher
2020-01-15 20:38:41 -05:00
committed by Edward Oakes
parent 2e972e725a
commit c480d1d1e4
4 changed files with 76 additions and 2 deletions
+15
View File
@@ -127,6 +127,21 @@ def is_class_method(f):
return hasattr(f, "__self__") and f.__self__ is not None
def is_static_method(cls, f_name):
"""Returns whether the class has a static method with the given name.
Args:
cls: The Python class (i.e. object of type `type`) to
search for the method in.
f_name: The name of the method to look up in this class
and check whether or not it is static.
"""
for cls in inspect.getmro(cls):
if f_name in cls.__dict__:
return isinstance(cls.__dict__[f_name], staticmethod)
return False
def random_string():
"""Generate a random string to use as an ID.