summaryrefslogtreecommitdiffstats
path: root/stator/graph.py
diff options
context:
space:
mode:
authorPaolo Melchiorre2022-12-05 18:38:37 +0100
committerGitHub2022-12-05 10:38:37 -0700
commita9bb4a7122df6d9d4a764de52244c6ec75789ead (patch)
tree14ba582f72ac5e3b133b3644ca03e0f027e7c2ef /stator/graph.py
parentdd8e823d2f3ef22fcaa1e43e74f11f7e49eff9e7 (diff)
downloadtakahe-a9bb4a7122df6d9d4a764de52244c6ec75789ead.tar.gz
takahe-a9bb4a7122df6d9d4a764de52244c6ec75789ead.tar.bz2
takahe-a9bb4a7122df6d9d4a764de52244c6ec75789ead.zip
Add pyupgrade with --py310-plus in pre-commit (#103)
Diffstat (limited to 'stator/graph.py')
-rw-r--r--stator/graph.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/stator/graph.py b/stator/graph.py
index 5c71d4a..0ec5ee7 100644
--- a/stator/graph.py
+++ b/stator/graph.py
@@ -1,4 +1,5 @@
-from typing import Any, Callable, ClassVar, Dict, List, Optional, Set, Tuple, Type
+from collections.abc import Callable
+from typing import Any, ClassVar
class StateGraph:
@@ -7,11 +8,11 @@ class StateGraph:
Does not support subclasses of existing graphs yet.
"""
- states: ClassVar[Dict[str, "State"]]
- choices: ClassVar[List[Tuple[object, str]]]
+ states: ClassVar[dict[str, "State"]]
+ choices: ClassVar[list[tuple[object, str]]]
initial_state: ClassVar["State"]
- terminal_states: ClassVar[Set["State"]]
- automatic_states: ClassVar[Set["State"]]
+ terminal_states: ClassVar[set["State"]]
+ automatic_states: ClassVar[set["State"]]
def __init_subclass__(cls) -> None:
# Collect state members
@@ -84,8 +85,8 @@ class State:
def __init__(
self,
- try_interval: Optional[float] = None,
- handler_name: Optional[str] = None,
+ try_interval: float | None = None,
+ handler_name: str | None = None,
externally_progressed: bool = False,
attempt_immediately: bool = True,
force_initial: bool = False,
@@ -95,10 +96,10 @@ class State:
self.externally_progressed = externally_progressed
self.attempt_immediately = attempt_immediately
self.force_initial = force_initial
- self.parents: Set["State"] = set()
- self.children: Set["State"] = set()
+ self.parents: set["State"] = set()
+ self.children: set["State"] = set()
- def _add_to_graph(self, graph: Type[StateGraph], name: str):
+ def _add_to_graph(self, graph: type[StateGraph], name: str):
self.graph = graph
self.name = name
self.graph.states[name] = self
@@ -132,7 +133,7 @@ class State:
return not self.children
@property
- def handler(self) -> Callable[[Any], Optional[str]]:
+ def handler(self) -> Callable[[Any], str | None]:
# Retrieve it by name off the graph
if self.handler_name is None:
raise AttributeError("No handler defined")