Skip to content

Domain Model check uses __bool_ rather than 'is not None' #531

@jgrey4296

Description

@jgrey4296

If you provide a domain model with a __bool__ method, that evaluates to False when constructing a a statemachine, the logic falls back to use the default model. If there are domain model conditions, then the StateMachine instantiation fails with an error like:

statemachine.exceptions.InvalidDefinition: Error on transition setup progress from Named to Dead when resolving callbacks: not found name 'spec_missing' from model or statemachine

Which doesn't provide any information to say the Domain Model is the default domain rather than the expected domain.

Probably, a StateMachine's __init__ should use model if model is not None else model() rather than the implicit bool, or missing conditions/validations/callback errors should specify the type of the domain model so the user can see their model isn't being used.

Relevant line:

self.model = model if model else Model()

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