mirror of
https://github.com/wassname/ray.git
synced 2026-07-07 06:55:53 +08:00
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:
committed by
Edward Oakes
parent
2e972e725a
commit
c480d1d1e4
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user