jyveapp / django-action-framework

Create many types of interfaces from functions
https://django-action-framework.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
18 stars 3 forks source link

SyntaxError if object_arg not defined #15

Open jayvdb opened 4 years ago

jayvdb commented 4 years ago

I had a ObjectAction with a objects_arg (extra s), and the exception didnt help show what was wrong.

  File "daf/actions.py", line 21, in __new__
    cls.check_class_definition()
  File "daf/actions.py", line 337, in check_class_definition
    super().check_class_definition()
  File "daf/actions.py", line 259, in check_class_definition
    super().check_class_definition()
  File "daf/actions.py", line 206, in check_class_definition
    if not re.match(r'\w+', cls.name):
  File "daf/utils.py", line 36, in __get__
    return self.getter(owner)
  File "daf/actions.py", line 49, in name
    return arg.s()(cls.func).func.__name__
  File "daf/utils.py", line 36, in __get__
    return self.getter(owner)
  File "daf/actions.py", line 144, in func
    return cls.get_wrapper()(cls.callable)
  File "daf/actions.py", line 139, in get_wrapper
    return cls.wrapper
  File "daf/utils.py", line 36, in __get__
    return self.getter(owner)
  File "daf/actions.py", line 314, in wrapper
    daf.contrib.single_list(cls.object_arg),
  File "arg/core.py", line 229, in __init__
    super().__init__(eval(f'lambda {arg}: {arg}'), default=default)
  File "<string>", line 1
    lambda None: None
           ^
SyntaxError: invalid syntax
jayvdb commented 3 years ago

Note that happens on startup of django.

The check_class_definition class methods of these classes does the necessary check. I'm not sure why it isnt being used to give a better error message sooner.