11from __future__ import annotations
22
33import warnings
4- from typing import TYPE_CHECKING , Any , Literal , Optional , Union , overload
4+ from typing import TYPE_CHECKING , Any , Literal , overload
55from urllib .parse import urlencode
66
77from pydantic import BaseModel
1717class BranchData (BaseModel ):
1818 id : str
1919 name : str
20- description : Optional [ str ] = None
20+ description : str | None = None
2121 sync_with_git : bool
2222 is_default : bool
2323 has_schema_changes : bool
24- origin_branch : Optional [ str ] = None
24+ origin_branch : str | None = None
2525 branched_from : str
2626
2727
@@ -50,11 +50,11 @@ class InfraHubBranchManagerBase:
5050 @classmethod
5151 def generate_diff_data_url (
5252 cls ,
53- client : Union [ InfrahubClient , InfrahubClientSync ] ,
53+ client : InfrahubClient | InfrahubClientSync ,
5454 branch_name : str ,
5555 branch_only : bool = True ,
56- time_from : Optional [ str ] = None ,
57- time_to : Optional [ str ] = None ,
56+ time_from : str | None = None ,
57+ time_to : str | None = None ,
5858 ) -> str :
5959 """Generate the URL for the diff_data function."""
6060 url = f"{ client .address } /api/diff/data"
@@ -80,7 +80,7 @@ async def create(
8080 sync_with_git : bool = True ,
8181 description : str = "" ,
8282 wait_until_completion : Literal [True ] = True ,
83- background_execution : Optional [ bool ] = False ,
83+ background_execution : bool | None = False ,
8484 ) -> BranchData : ...
8585
8686 @overload
@@ -90,7 +90,7 @@ async def create(
9090 sync_with_git : bool = True ,
9191 description : str = "" ,
9292 wait_until_completion : Literal [False ] = False ,
93- background_execution : Optional [ bool ] = False ,
93+ background_execution : bool | None = False ,
9494 ) -> str : ...
9595
9696 async def create (
@@ -99,8 +99,8 @@ async def create(
9999 sync_with_git : bool = True ,
100100 description : str = "" ,
101101 wait_until_completion : bool = True ,
102- background_execution : Optional [ bool ] = False ,
103- ) -> Union [ BranchData , str ] :
102+ background_execution : bool | None = False ,
103+ ) -> BranchData | str :
104104 if background_execution is not None :
105105 warnings .warn (
106106 "`background_execution` is deprecated, please use `wait_until_completion` instead." ,
@@ -206,8 +206,8 @@ async def diff_data(
206206 self ,
207207 branch_name : str ,
208208 branch_only : bool = True ,
209- time_from : Optional [ str ] = None ,
210- time_to : Optional [ str ] = None ,
209+ time_from : str | None = None ,
210+ time_to : str | None = None ,
211211 ) -> dict [Any , Any ]:
212212 url = self .generate_diff_data_url (
213213 client = self .client ,
@@ -251,7 +251,7 @@ def create(
251251 sync_with_git : bool = True ,
252252 description : str = "" ,
253253 wait_until_completion : Literal [True ] = True ,
254- background_execution : Optional [ bool ] = False ,
254+ background_execution : bool | None = False ,
255255 ) -> BranchData : ...
256256
257257 @overload
@@ -261,7 +261,7 @@ def create(
261261 sync_with_git : bool = True ,
262262 description : str = "" ,
263263 wait_until_completion : Literal [False ] = False ,
264- background_execution : Optional [ bool ] = False ,
264+ background_execution : bool | None = False ,
265265 ) -> str : ...
266266
267267 def create (
@@ -270,8 +270,8 @@ def create(
270270 sync_with_git : bool = True ,
271271 description : str = "" ,
272272 wait_until_completion : bool = True ,
273- background_execution : Optional [ bool ] = False ,
274- ) -> Union [ BranchData , str ] :
273+ background_execution : bool | None = False ,
274+ ) -> BranchData | str :
275275 if background_execution is not None :
276276 warnings .warn (
277277 "`background_execution` is deprecated, please use `wait_until_completion` instead." ,
@@ -313,8 +313,8 @@ def diff_data(
313313 self ,
314314 branch_name : str ,
315315 branch_only : bool = True ,
316- time_from : Optional [ str ] = None ,
317- time_to : Optional [ str ] = None ,
316+ time_from : str | None = None ,
317+ time_to : str | None = None ,
318318 ) -> dict [Any , Any ]:
319319 url = self .generate_diff_data_url (
320320 client = self .client ,
0 commit comments