Beispiel #1
0
def test_is_class_method():
    def f1():
        pass

    class F(object):
        def f2(self):
            pass

    assert not is_class_method(f1)
    assert is_class_method(F.f2)
    assert not is_class_method(F().f2)
Beispiel #2
0
 def deco(func: Callable) -> "_FuncAsTunable":
     assert_or_throw(
         not is_class_method(func),
         NotImplementedError(
             "tunable decorator can't be used on class methods"),
     )
     return _FuncAsTunable.from_func(func, distributable=distributable)
Beispiel #3
0
 def deco(func: Callable) -> NonIterativeObjectiveFunc:
     assert_or_throw(
         not is_class_method(func),
         NotImplementedError(
             "non_iterative_objective decorator can't be used on class methods"
         ),
     )
     return _NonIterativeObjectiveFuncWrapper.from_func(func, min_better)
Beispiel #4
0
 def deco(func: Callable) -> "_FuncAsCoTransformer":
     assert_or_throw(
         not is_class_method(func),
         NotImplementedError(
             "cotransformer decorator can't be used on class methods"),
     )
     return _FuncAsCoTransformer.from_func(
         func,
         schema,
         validation_rules=to_validation_rules(validation_rules))