11from __future__ import annotations
22
3- import warnings
43from enum import Enum
54from typing import TYPE_CHECKING , Any , Literal , overload
65from urllib .parse import urlencode
@@ -93,7 +92,6 @@ async def create(
9392 sync_with_git : bool = True ,
9493 description : str = "" ,
9594 wait_until_completion : Literal [True ] = True ,
96- background_execution : bool | None = False ,
9795 ) -> BranchData : ...
9896
9997 @overload
@@ -103,7 +101,6 @@ async def create(
103101 sync_with_git : bool = True ,
104102 description : str = "" ,
105103 wait_until_completion : Literal [False ] = False ,
106- background_execution : bool | None = False ,
107104 ) -> str : ...
108105
109106 async def create (
@@ -112,35 +109,24 @@ async def create(
112109 sync_with_git : bool = True ,
113110 description : str = "" ,
114111 wait_until_completion : bool = True ,
115- background_execution : bool | None = False ,
116112 ) -> BranchData | str :
117- if background_execution is not None :
118- warnings .warn (
119- "`background_execution` is deprecated, please use `wait_until_completion` instead." ,
120- DeprecationWarning ,
121- stacklevel = 1 ,
122- )
123-
124- background_execution = background_execution or not wait_until_completion
125113 input_data = {
126- # Should be switched to `wait_until_completion` once `background_execution` is removed server side.
127- "background_execution" : background_execution ,
114+ "wait_until_completion" : wait_until_completion ,
128115 "data" : {
129116 "name" : branch_name ,
130117 "description" : description ,
131118 "sync_with_git" : sync_with_git ,
132119 },
133120 }
134121
135- mutation_query = MUTATION_QUERY_TASK if background_execution else MUTATION_QUERY_DATA
122+ mutation_query = MUTATION_QUERY_DATA if wait_until_completion else MUTATION_QUERY_TASK
136123 query = Mutation (mutation = "BranchCreate" , input_data = input_data , query = mutation_query )
137124 response = await self .client .execute_graphql (query = query .render (), tracker = "mutation-branch-create" )
138125
139- # Make sure server version is recent enough to support background execution, as previously
140- # using background_execution=True had no effect.
141- if background_execution and "task" in response ["BranchCreate" ]:
142- return response ["BranchCreate" ]["task" ]["id" ]
143- return BranchData (** response ["BranchCreate" ]["object" ])
126+ if wait_until_completion :
127+ return BranchData (** response ["BranchCreate" ]["object" ])
128+
129+ return response ["BranchCreate" ]["task" ]["id" ]
144130
145131 async def delete (self , branch_name : str ) -> bool :
146132 input_data = {
@@ -261,7 +247,6 @@ def create(
261247 sync_with_git : bool = True ,
262248 description : str = "" ,
263249 wait_until_completion : Literal [True ] = True ,
264- background_execution : bool | None = False ,
265250 ) -> BranchData : ...
266251
267252 @overload
@@ -271,7 +256,6 @@ def create(
271256 sync_with_git : bool = True ,
272257 description : str = "" ,
273258 wait_until_completion : Literal [False ] = False ,
274- background_execution : bool | None = False ,
275259 ) -> str : ...
276260
277261 def create (
@@ -280,35 +264,24 @@ def create(
280264 sync_with_git : bool = True ,
281265 description : str = "" ,
282266 wait_until_completion : bool = True ,
283- background_execution : bool | None = False ,
284267 ) -> BranchData | str :
285- if background_execution is not None :
286- warnings .warn (
287- "`background_execution` is deprecated, please use `wait_until_completion` instead." ,
288- DeprecationWarning ,
289- stacklevel = 1 ,
290- )
291-
292- background_execution = background_execution or not wait_until_completion
293268 input_data = {
294- # Should be switched to `wait_until_completion` once `background_execution` is removed server side.
295- "background_execution" : background_execution ,
269+ "wait_until_completion" : wait_until_completion ,
296270 "data" : {
297271 "name" : branch_name ,
298272 "description" : description ,
299273 "sync_with_git" : sync_with_git ,
300274 },
301275 }
302276
303- mutation_query = MUTATION_QUERY_TASK if background_execution else MUTATION_QUERY_DATA
277+ mutation_query = MUTATION_QUERY_DATA if wait_until_completion else MUTATION_QUERY_TASK
304278 query = Mutation (mutation = "BranchCreate" , input_data = input_data , query = mutation_query )
305279 response = self .client .execute_graphql (query = query .render (), tracker = "mutation-branch-create" )
306280
307- # Make sure server version is recent enough to support background execution, as previously
308- # using background_execution=True had no effect.
309- if background_execution and "task" in response ["BranchCreate" ]:
310- return response ["BranchCreate" ]["task" ]["id" ]
311- return BranchData (** response ["BranchCreate" ]["object" ])
281+ if wait_until_completion :
282+ return BranchData (** response ["BranchCreate" ]["object" ])
283+
284+ return response ["BranchCreate" ]["task" ]["id" ]
312285
313286 def delete (self , branch_name : str ) -> bool :
314287 input_data = {
0 commit comments