Skip to content

Improve feedback when misconfiguring a strategy #5

Open
@PeterJCLaw

Description

@PeterJCLaw

Currently if you misconfigure a strategy, perhaps by omitting a name or by forgetting to call super().__init__() passing everything through in its initialiser, devdata doesn't give much useful feedback.
The error you do get is:

  File ".../devdata/engine.py", line 72, in export_data
    model_strategies = sort_model_strategies(settings.strategies)
  File ".../devdata/utils.py", line 72, in sort_model_strategies
    for dep in strategy.depends_on:
AttributeError: 'tuple' object has no attribute 'depends_on'

Which is unfortunately considerably later in devdata's processing.

I think the fix is likely to change the handling in settings.py, so that the strategy construction logic is more explicitly able to tell the difference between the available valid options and those which are erroneous:

try:
klass_path, kwargs = strategy
klass = import_string(klass_path)
ret[app_model_label].append(klass(**kwargs))
except (ValueError, TypeError, IndexError):
ret[app_model_label].append(strategy)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions