Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve feedback when misconfiguring a strategy #5

Open
PeterJCLaw opened this issue Sep 8, 2021 · 0 comments
Open

Improve feedback when misconfiguring a strategy #5

PeterJCLaw opened this issue Sep 8, 2021 · 0 comments

Comments

@PeterJCLaw
Copy link
Collaborator

PeterJCLaw commented Sep 8, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant