149149from typing import (
150150 Tuple ,
151151 Optional ,
152- Iterator ,
153- Iterable ,
154152 TypeVar ,
155- Callable ,
156153 Dict ,
157- Mapping ,
158154 Union ,
159155)
156+ from collections .abc import Iterator , Iterable , Callable , Mapping
160157from functools import partial
161158
162159
@@ -249,7 +246,7 @@ def parse_body(body, *, body_index=None):
249246
250247
251248# Note: generalize? glom?
252- def parse_assignment (body : ast .Assign , info = None ) -> Tuple :
249+ def parse_assignment (body : ast .Assign , info = None ) -> tuple :
253250 # TODO: Make this validation better (at least more help in raised error)
254251 # TODO: extract validating code out as validation functions?
255252 info = _ast_info_str (body )
@@ -430,7 +427,7 @@ def parse_steps(src):
430427
431428def src_to_func_node_factory (
432429 src , exclude_names = None
433- ) -> Iterator [Union [ FuncNode , FuncNodeFactory ] ]:
430+ ) -> Iterator [FuncNode | FuncNodeFactory ]:
434431 """
435432 :param src: Callable or string of callable.
436433 :param exclude_names: Names to exclude when making func_nodes
@@ -454,7 +451,7 @@ def src_to_func_node_factory(
454451# to make itself. Do we gain much over simply saying "factory, make yourself"?
455452def dlft_factory_to_func (
456453 factory : partial ,
457- name_to_func_map : Optional [ Dict [ str , Callable ]] = None ,
454+ name_to_func_map : dict [ str , Callable ] | None = None ,
458455 use_place_holder_fallback = True ,
459456):
460457 """Get a function for the given factory, using"""
@@ -545,7 +542,7 @@ def code_to_fnodes(
545542 * ,
546543 func_src : FuncSource = dlft_factory_to_func ,
547544 use_place_holder_fallback = False ,
548- ) -> Tuple [FuncNode ]:
545+ ) -> tuple [FuncNode ]:
549546 """Get func_nodes from src code"""
550547 func_src = _ensure_func_src (func_src , use_place_holder_fallback )
551548 # Pass on to _code_to_fnodes to get func nodes iterable needed to make DAG
@@ -593,10 +590,10 @@ def code_to_digraph(src):
593590# from typing import Tuple, Iterable, Iterator
594591# from meshed import FuncNode, code_to_dag, code_to_fnodes, DAG
595592
596- extract_tokens = re .compile ("\w+" ).findall
593+ extract_tokens = re .compile (r "\w+" ).findall
597594
598595
599- def triples_to_fnodes (triples : Iterable [Tuple [str , str , str ]]) -> Iterable [FuncNode ]:
596+ def triples_to_fnodes (triples : Iterable [tuple [str , str , str ]]) -> Iterable [FuncNode ]:
600597 """Converts an iterable of func call triples to an iterable of ``FuncNode``s.
601598 (Which in turn can be converted to a ``DAG``.)
602599
@@ -624,9 +621,9 @@ def triples_to_fnodes(triples: Iterable[Tuple[str, str, str]]) -> Iterable[FuncN
624621
625622
626623def _triple_to_func_call_str (
627- outputs : Union [ str , Iterable [str ] ],
624+ outputs : str | Iterable [str ],
628625 func_name : str ,
629- inputs : Union [ str , Iterable [str ] ],
626+ inputs : str | Iterable [str ],
630627) -> str :
631628 """Converts a `(outputs, func_name, inputs)` triple to a function call string.
632629
@@ -699,7 +696,7 @@ def lined_dag(funcs):
699696 return dag
700697
701698
702- from typing import Callable , Mapping , Iterable
699+ from collections . abc import Callable , Mapping , Iterable
703700
704701NamedFuncs = Mapping [str , Callable ]
705702
0 commit comments