@@ -69,13 +69,14 @@ def list(self, request, *args, **kwargs) -> Response: # type: ignore[no-untyped
6969 )
7070 elif resource_type .startswith ("GITLAB_" ):
7171 try :
72+ import re as _re
73+
7274 from integrations .gitlab .client import (
7375 get_gitlab_issue_mr_title_and_state as get_gitlab_metadata ,
7476 )
7577 from integrations .gitlab .models import (
7678 GitLabConfiguration ,
7779 )
78- import re as _re
7980
8081 feature_obj = get_object_or_404 (
8182 Feature .objects .filter (id = self .kwargs ["feature_pk" ]),
@@ -86,10 +87,16 @@ def list(self, request, *args, **kwargs) -> Response: # type: ignore[no-untyped
8687 if gitlab_config and gitlab_config .gitlab_project_id :
8788 # Parse resource IID from URL
8889 if resource_type == "GITLAB_MR" :
89- match = _re .search (r"https?://[^/]+/([^/-]+(?:/[^/-]+)*)/-/merge_requests/(\d+)$" , resource_url )
90+ match = _re .search (
91+ r"https?://[^/]+/([^/-]+(?:/[^/-]+)*)/-/merge_requests/(\d+)$" ,
92+ resource_url ,
93+ )
9094 api_type = "merge_requests"
9195 else :
92- match = _re .search (r"https?://[^/]+/([^/-]+(?:/[^/-]+)*)/-/(?:issues|work_items)/(\d+)$" , resource_url )
96+ match = _re .search (
97+ r"https?://[^/]+/([^/-]+(?:/[^/-]+)*)/-/(?:issues|work_items)/(\d+)$" ,
98+ resource_url ,
99+ )
93100 api_type = "issues"
94101
95102 if match :
@@ -106,7 +113,9 @@ def list(self, request, *args, **kwargs) -> Response: # type: ignore[no-untyped
106113
107114 return Response (data = {"results" : data })
108115
109- def _create_gitlab_resource (self , request : Any , feature : Any , resource_type : str , * args : Any , ** kwargs : Any ) -> Response :
116+ def _create_gitlab_resource (
117+ self , request : Any , feature : Any , resource_type : str , * args : Any , ** kwargs : Any
118+ ) -> Response :
110119 from integrations .gitlab .models import GitLabConfiguration
111120
112121 try :
@@ -127,12 +136,16 @@ def _create_gitlab_resource(self, request: Any, feature: Any, resource_type: str
127136 if resource_type == "GITLAB_MR" :
128137 pattern = r"https?://[^/]+/([^/-]+(?:/[^/-]+)*)/-/merge_requests/(\d+)$"
129138 else :
130- pattern = r"https?://[^/]+/([^/-]+(?:/[^/-]+)*)/-/(?:issues|work_items)/(\d+)$"
139+ pattern = (
140+ r"https?://[^/]+/([^/-]+(?:/[^/-]+)*)/-/(?:issues|work_items)/(\d+)$"
141+ )
131142
132143 url_match = re .search (pattern , url )
133144 if url_match :
134145 _project_path , resource_iid = url_match .groups ()
135- api_resource_type = "merge_requests" if resource_type == "GITLAB_MR" else "issues"
146+ api_resource_type = (
147+ "merge_requests" if resource_type == "GITLAB_MR" else "issues"
148+ )
136149 if gitlab_config .tagging_enabled and gitlab_config .gitlab_project_id :
137150 label_gitlab_issue_mr (
138151 instance_url = gitlab_config .gitlab_instance_url ,
@@ -149,7 +162,9 @@ def _create_gitlab_resource(self, request: Any, feature: Any, resource_type: str
149162 status = status .HTTP_400_BAD_REQUEST ,
150163 )
151164
152- def _create_github_resource (self , request : Any , feature : Any , resource_type : str , * args : Any , ** kwargs : Any ) -> Response :
165+ def _create_github_resource (
166+ self , request : Any , feature : Any , resource_type : str , * args : Any , ** kwargs : Any
167+ ) -> Response :
153168 github_configuration = (
154169 Organisation .objects .prefetch_related ("github_config" )
155170 .get (id = feature .project .organisation_id )
@@ -212,10 +227,14 @@ def create(self, request, *args, **kwargs): # type: ignore[no-untyped-def]
212227
213228 # Handle GitLab resources
214229 if resource_type in ("GITLAB_MR" , "GITLAB_ISSUE" ):
215- return self ._create_gitlab_resource (request , feature , resource_type , * args , ** kwargs )
230+ return self ._create_gitlab_resource (
231+ request , feature , resource_type , * args , ** kwargs
232+ )
216233
217234 # Handle GitHub resources
218- return self ._create_github_resource (request , feature , resource_type , * args , ** kwargs )
235+ return self ._create_github_resource (
236+ request , feature , resource_type , * args , ** kwargs
237+ )
219238
220239 def perform_update (self , serializer ): # type: ignore[no-untyped-def]
221240 external_resource_id = int (self .kwargs ["pk" ])
0 commit comments