Skip to content
Snippets Groups Projects

Feat: Add parameters to pre_scan

Merged Mikhail Karnevskiy requested to merge feat/meta_to_param into master
7 unresolved threads
Files
4
@@ -43,6 +43,24 @@ def flattened_config_entries(type):
return flattened_entries
def get_config_entry_option(attribute, name):
if hasattr(attribute.metadata[CONFIGURABLE_CONFIG_ENTRY], name):
value = getattr(attribute.metadata[CONFIGURABLE_CONFIG_ENTRY], name)
else:
value = getattr(attribute, name)
return value
def check_type(obj):
for attribute in attr.fields(type(obj)):
expected_type = get_config_entry_option(attribute, 'type')
variable = getattr(obj, attribute.name)
if not isinstance(variable, expected_type):
raise TypeError("Variable '{}' has wrong type '{}', expected '{}'".format(attribute.name,
type(variable),
expected_type))
def Configurable(maybe_cls=None, *args, **kwargs):
def attrs_wrapper(cls):
cls = attr.s(*args, **kwargs)(cls)
Loading