-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Include nested applications in Lifespan (#130)
- Loading branch information
Showing
10 changed files
with
601 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,37 @@ | ||
import enum | ||
import sys | ||
import typing as t | ||
|
||
__all__ = ["AppStatus"] | ||
if t.TYPE_CHECKING: | ||
from flama import Flama | ||
|
||
|
||
if sys.version_info < (3, 10): # PORT: Remove when stop supporting 3.9 # pragma: no cover | ||
from typing_extensions import TypeGuard | ||
|
||
t.TypeGuard = TypeGuard # type: ignore | ||
|
||
|
||
__all__ = ["AppStatus", "is_flama_instance"] | ||
|
||
|
||
class AppStatus(enum.Enum): | ||
NOT_INITIALIZED = enum.auto() | ||
NOT_STARTED = enum.auto() | ||
STARTING = enum.auto() | ||
READY = enum.auto() | ||
SHUTTING_DOWN = enum.auto() | ||
SHUT_DOWN = enum.auto() | ||
FAILED = enum.auto() | ||
|
||
|
||
def is_flama_instance( | ||
obj: t.Any, | ||
) -> t.TypeGuard["Flama"]: # type: ignore # PORT: Remove this comment when stop supporting 3.9 | ||
"""Checks if an object is an instance of Flama. | ||
:param obj: The object to check. | ||
:return: True if the object is an instance of Flama, False otherwise. | ||
""" | ||
from flama import Flama | ||
|
||
return isinstance(obj, Flama) |
Oops, something went wrong.