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

Static typing improvements, add Mermaid support and may_trigger for models #677

Merged
merged 10 commits into from
Jun 18, 2024

Conversation

aleneum
Copy link
Member

@aleneum aleneum commented Jun 12, 2024

This is meant to improve type-safe-ish work with transitions. expect_override was replaced with model_override as a construction parameter. With model_override=True it is expected that the model defines all intended decorated methods. Thus, transitions will only override methods that are already available.
This PR also improves stub files by explicitly noting on_final, on_exception, allow_override.

Related Issues:

This will undo #676

@aleneum aleneum force-pushed the dev-experimental-model-creation branch from c76b91f to 05ec3ed Compare June 12, 2024 16:23
@coveralls
Copy link

Coverage Status

coverage: 98.524% (-0.004%) from 98.528%
when pulling 05ec3ed on dev-experimental-model-creation
into 4a611dd on master.

@coveralls
Copy link

Coverage Status

coverage: 98.281% (-0.2%) from 98.528%
when pulling dfef212 on dev-experimental-model-creation
into 4a611dd on master.

@coveralls
Copy link

Coverage Status

coverage: 98.315% (-0.2%) from 98.528%
when pulling 8f9aff5 on dev-experimental-model-creation
into 4a611dd on master.

@coveralls
Copy link

Coverage Status

coverage: 98.272% (-0.3%) from 98.528%
when pulling d7d05ab on dev-experimental-model-creation
into 4a611dd on master.

@coveralls
Copy link

Coverage Status

coverage: 98.379% (-0.1%) from 98.528%
when pulling 2fee317 on dev-experimental-model-creation
into 4a611dd on master.

@coveralls
Copy link

Coverage Status

coverage: 98.379% (-0.1%) from 98.528%
when pulling 33c04d4 on dev-experimental-model-creation
into 4a611dd on master.

Scope of expect_override was too narrow and does not solve the typing issue adequately
this reverts #676
…ils.generate_base_model`

When `model_override` is set to True, Machine will assign only methods to a model that are already defined. This eases static type checking (#658) and enables tailored helper function assigment. Default value is False which prevents override of already defined model functions.
Adds state.final, on_exception, on_final and model_override
…ns, event, with_model_definitions, transition}

Add helper functions to define transitions on a model class for better type checking (#658)
`model.may_trigger(event_name)` allows to call `model.may_event_name` by name, juas as `model.trigger(event_name)` does for `model.event_name`
mermaid graph backend can generate valid mermaid diagram strings that can be passed to e.g. GitHub/GitLab or some other web services.

use_graphviz is deprecated now. Use graph_engine with `pygraphviz` (default), `graphviz` or `mermaid`

this closes #611
@aleneum aleneum force-pushed the dev-experimental-model-creation branch from 33c04d4 to fc82b15 Compare June 18, 2024 13:17
@aleneum aleneum changed the title Remove expect_override;introduce new __init__ attribute model_override, generate_base_model and trigger Static typing improvements, add Mermaid support and may_trigger for models Jun 18, 2024
@aleneum aleneum merged commit 8614ce3 into master Jun 18, 2024
8 checks passed
@aleneum aleneum deleted the dev-experimental-model-creation branch June 18, 2024 13:23
@coveralls
Copy link

Coverage Status

coverage: 98.379% (-0.1%) from 98.528%
when pulling fc82b15 on dev-experimental-model-creation
into 4a611dd on master.

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

Successfully merging this pull request may close these issues.

None yet

2 participants