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

Move transitions to enum #35

Open
wants to merge 5 commits into
base: actor
Choose a base branch
from
Open

Move transitions to enum #35

wants to merge 5 commits into from

Conversation

ahopkins
Copy link
Member

Putting all of the transition strings into an enum should make it easier to manage going forward.

@codecov
Copy link

codecov bot commented Mar 14, 2021

Codecov Report

Merging #35 (779b95a) into actor (fe70a97) will increase coverage by 0.25%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            actor      #35      +/-   ##
==========================================
+ Coverage   94.54%   94.79%   +0.25%     
==========================================
  Files           5        5              
  Lines         458      480      +22     
  Branches       62       62              
==========================================
+ Hits          433      455      +22     
  Misses         18       18              
  Partials        7        7              
Flag Coverage Δ
unittests 94.37% <100.00%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jumpstarter/states.py 97.93% <100.00%> (+0.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe70a97...779b95a. Read the comment docs.

@ahopkins ahopkins changed the title Move tranitions to enum Move transitions to enum Mar 14, 2021
@ghost
Copy link

ghost commented Mar 14, 2021

Congratulations 🎉. DeepCode analyzed your code in 3.362 seconds and we found no issues. Enjoy a moment of no bugs ☀️.

👉 View analysis in DeepCode’s Dashboard | Configure the bot

jumpstarter/states.py Outdated Show resolved Hide resolved
@@ -409,7 +454,7 @@ async def _release_resources(event_data: transitions.EventData) -> None:
async def _maybe_set_event(event_data: EventData, event_name: str) -> None:
kwargs = _merge_event_data_kwargs(event_data)
try:
event: Event = kwargs[event_name]
event: EventType = kwargs[event_name]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely not correct. This is an AnyIO event.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the anyio.Event at import to not conflict with the Event enum. It seemed to me that the having a variable Event.bootup and Event.shutdown was more useful than the type annotation. By changing the name of the annotation at import, mypy will still work, and IDEs will still prompt you to use the correct value. It just avoids the name collision.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from anyio.abc import Event as EventType

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename that enum to ActorLifecycleEvent.
That would be more helpful.

@thedrow thedrow added this to the v0.1 milestone Mar 15, 2021
@thedrow thedrow linked an issue Mar 15, 2021 that may be closed by this pull request
@@ -34,6 +34,34 @@
NestedState.separator = "↦"


class Transition(str, Enum):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are triggers, not transitions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️😆

Comment on lines +49 to +50
restarting__starting = auto()
restarting__stopping = auto()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no such triggers.

stop = auto()


class Event(str, Enum):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're using the wrong terminology here.
It could be because my design isn't 100% correct as of yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename that enum to ActorLifecycleEvent.
That would be more helpful.

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.

Create an Enum that specifies the available triggers
3 participants