2424import re
2525from collections .abc import Sequence
2626from dataclasses import dataclass
27- from typing import IO , Any , Optional , Union
27+ from typing import IO , Any
2828
2929import yaml
3030from typing_extensions import NotRequired , TypedDict
@@ -95,11 +95,9 @@ def _guess_project(self, names: Sequence[str]) -> Sequence[str]:
9595class ManifestDict (TypedDict , total = True ): # pylint: disable=too-many-ancestors
9696 """Serialized dict types."""
9797
98- version : Union [int , str ]
99- remotes : NotRequired [Sequence [Union [RemoteDict , Remote ]]]
100- projects : Sequence [
101- Union [ProjectEntryDict , ProjectEntry , dict [str , Union [str , list [str ]]]]
102- ]
98+ version : int | str
99+ remotes : NotRequired [Sequence [RemoteDict | Remote ]]
100+ projects : Sequence [ProjectEntryDict | ProjectEntry | dict [str , str | list [str ]]]
103101
104102
105103class Manifest :
@@ -113,8 +111,8 @@ class Manifest:
113111 def __init__ (
114112 self ,
115113 manifest : ManifestDict ,
116- text : Optional [ str ] = None ,
117- path : Optional [ Union [ str , os .PathLike [str ]]] = None ,
114+ text : str | None = None ,
115+ path : str | os .PathLike [str ] | None = None ,
118116 ) -> None :
119117 """Create the manifest."""
120118 self .__version : str = str (manifest .get ("version" , self .CURRENT_VERSION ))
@@ -142,7 +140,7 @@ def __init__(
142140 def _init_projects (
143141 self ,
144142 projects : Sequence [
145- Union [ ProjectEntryDict , ProjectEntry , dict [str , Union [ str , list [str ]] ]]
143+ ProjectEntryDict | ProjectEntry | dict [str , str | list [str ]]
146144 ],
147145 ) -> dict [str , ProjectEntry ]:
148146 """Iterate over projects from manifest and initialize ProjectEntries from it.
@@ -189,7 +187,7 @@ def _init_projects(
189187
190188 @staticmethod
191189 def _determine_remotes (
192- remotes_from_manifest : Sequence [Union [ RemoteDict , Remote ] ],
190+ remotes_from_manifest : Sequence [RemoteDict | Remote ],
193191 ) -> tuple [dict [str , Remote ], list [Remote ]]:
194192 default_remotes : list [Remote ] = []
195193 remotes : dict [str , Remote ] = {}
@@ -208,8 +206,8 @@ def _determine_remotes(
208206
209207 @staticmethod
210208 def from_yaml (
211- text : Union [ io .TextIOWrapper , str , IO [str ] ],
212- path : Optional [ Union [ str , os .PathLike [str ]]] = None ,
209+ text : io .TextIOWrapper | str | IO [str ],
210+ path : str | os .PathLike [str ] | None = None ,
213211 ) -> "Manifest" :
214212 """Create a manifest from a file like object."""
215213 if isinstance (text , (io .TextIOWrapper , IO )):
@@ -228,7 +226,7 @@ def from_yaml(
228226 return Manifest (manifest , text = text , path = path )
229227
230228 @staticmethod
231- def _load_yaml (text : Union [ io .TextIOWrapper , str , IO [str ] ]) -> Any :
229+ def _load_yaml (text : io .TextIOWrapper | str | IO [str ]) -> Any :
232230 try :
233231 return yaml .safe_load (text )
234232 except yaml .YAMLError as exc :
@@ -306,9 +304,9 @@ def _as_dict(self) -> dict[str, ManifestDict]:
306304 if len (remotes ) == 1 :
307305 remotes [0 ].pop ("default" , None )
308306
309- projects : list [dict [str , Union [ str , list [str ] ]]] = []
307+ projects : list [dict [str , str | list [str ]]] = []
310308 for project in self .projects :
311- project_yaml : dict [str , Union [ str , list [str ] ]] = project .as_yaml ()
309+ project_yaml : dict [str , str | list [str ]] = project .as_yaml ()
312310 if len (remotes ) == 1 :
313311 project_yaml .pop ("remote" , None )
314312 projects .append (project_yaml )
0 commit comments