@@ -315,7 +315,10 @@ class JiraCookieAuth(AuthBase):
315
315
"""
316
316
317
317
def __init__ (
318
- self , session : ResilientSession , session_api_url : str , auth : tuple [str , str ]
318
+ self ,
319
+ session : ResilientSession ,
320
+ session_api_url : str ,
321
+ auth : tuple [str , str ],
319
322
):
320
323
"""Cookie Based Authentication.
321
324
@@ -888,7 +891,10 @@ def json_params() -> dict[str, Any]:
888
891
page_params ["maxResults" ] = page_size
889
892
890
893
resource = self ._get_json (
891
- request_path , params = page_params , base = base , use_post = use_post
894
+ request_path ,
895
+ params = page_params ,
896
+ base = base ,
897
+ use_post = use_post ,
892
898
)
893
899
if resource :
894
900
next_items_page = self ._get_items_from_page (
@@ -901,12 +907,20 @@ def json_params() -> dict[str, Any]:
901
907
break
902
908
903
909
return ResultList (
904
- items , start_at_from_response , max_results_from_response , total , is_last
910
+ items ,
911
+ start_at_from_response ,
912
+ max_results_from_response ,
913
+ total ,
914
+ is_last ,
905
915
)
906
916
else : # TODO: unreachable
907
917
# it seems that search_users can return a list() containing a single user!
908
918
return ResultList (
909
- [item_type (self ._options , self ._session , resource )], 0 , 1 , 1 , True
919
+ [item_type (self ._options , self ._session , resource )],
920
+ 0 ,
921
+ 1 ,
922
+ 1 ,
923
+ True ,
910
924
)
911
925
912
926
def _get_items_from_page (
@@ -1424,7 +1438,11 @@ def dashboard_item_property(
1424
1438
return dashboard_item_property
1425
1439
1426
1440
def set_dashboard_item_property (
1427
- self , dashboard_id : str , item_id : str , property_key : str , value : dict [str , Any ]
1441
+ self ,
1442
+ dashboard_id : str ,
1443
+ item_id : str ,
1444
+ property_key : str ,
1445
+ value : dict [str , Any ],
1428
1446
) -> DashboardItemProperty :
1429
1447
"""Set a dashboard item property.
1430
1448
@@ -1629,7 +1647,9 @@ def update_filter(
1629
1647
1630
1648
url = self ._get_url (f"filter/{ filter_id } " )
1631
1649
r = self ._session .put (
1632
- url , headers = {"content-type" : "application/json" }, data = json .dumps (data )
1650
+ url ,
1651
+ headers = {"content-type" : "application/json" },
1652
+ data = json .dumps (data ),
1633
1653
)
1634
1654
1635
1655
raw_filter_json = json .loads (r .text )
@@ -1689,12 +1709,14 @@ def group_members(self, group: str) -> OrderedDict:
1689
1709
Args:
1690
1710
group (str): Name of the group.
1691
1711
"""
1712
+ users = {}
1713
+
1692
1714
if self ._version < (6 , 0 , 0 ):
1693
1715
raise NotImplementedError (
1694
1716
"Group members is not implemented in Jira before version 6.0, upgrade the instance, if possible."
1695
1717
)
1696
1718
1697
- if self ._version < (10 , 0 , 0 ):
1719
+ elif self ._version < (10 , 0 , 0 ):
1698
1720
params = {"groupname" : group , "expand" : "users" }
1699
1721
r = self ._get_json ("group" , params = params )
1700
1722
size = r ["users" ]["size" ]
@@ -1711,31 +1733,7 @@ def group_members(self, group: str) -> OrderedDict:
1711
1733
end_index = r2 ["users" ]["end-index" ]
1712
1734
size = r ["users" ]["size" ]
1713
1735
1714
- result = {}
1715
- for user in r ["users" ]["items" ]:
1716
- # 'id' is likely available only in older JIRA Server,
1717
- # it's not available on newer JIRA Server.
1718
- # 'name' is not available in JIRA Cloud.
1719
- hasId = user .get ("id" ) is not None and user .get ("id" ) != ""
1720
- hasName = user .get ("name" ) is not None and user .get ("name" ) != ""
1721
- result [
1722
- (
1723
- user ["id" ]
1724
- if hasId
1725
- else user .get ("name" )
1726
- if hasName
1727
- else user .get ("accountId" )
1728
- )
1729
- ] = {
1730
- "name" : user .get ("name" ),
1731
- "id" : user .get ("id" ),
1732
- "accountId" : user .get ("accountId" ),
1733
- "fullname" : user .get ("displayName" ),
1734
- "email" : user .get ("emailAddress" , "hidden" ),
1735
- "active" : user .get ("active" ),
1736
- "timezone" : user .get ("timezone" ),
1737
- }
1738
- return OrderedDict (sorted (result .items (), key = lambda t : t [0 ]))
1736
+ users = r ["users" ]["items" ]
1739
1737
1740
1738
else :
1741
1739
params = {"groupname" : group }
@@ -1755,31 +1753,33 @@ def group_members(self, group: str) -> OrderedDict:
1755
1753
r ["values" ].append (user )
1756
1754
end_index += r2 ["maxResults" ]
1757
1755
1758
- result = {}
1759
- for user in r ["values" ]:
1760
- # 'id' is likely available only in older JIRA Server,
1761
- # it's not available on newer JIRA Server.
1762
- # 'name' is not available in JIRA Cloud.
1763
- hasId = user .get ("id" ) is not None and user .get ("id" ) != ""
1764
- hasName = user .get ("name" ) is not None and user .get ("name" ) != ""
1765
- result [
1766
- (
1767
- user ["id" ]
1768
- if hasId
1769
- else user .get ("name" )
1770
- if hasName
1771
- else user .get ("accountId" )
1772
- )
1773
- ] = {
1774
- "name" : user .get ("name" ),
1775
- "id" : user .get ("id" ),
1776
- "accountId" : user .get ("accountId" ),
1777
- "fullname" : user .get ("displayName" ),
1778
- "email" : user .get ("emailAddress" , "hidden" ),
1779
- "active" : user .get ("active" ),
1780
- "timezone" : user .get ("timezone" ),
1781
- }
1782
- return OrderedDict (sorted (result .items (), key = lambda t : t [0 ]))
1756
+ users = r ["values" ]
1757
+
1758
+ result = {}
1759
+ for user in users :
1760
+ # 'id' is likely available only in older JIRA Server,
1761
+ # it's not available on newer JIRA Server.
1762
+ # 'name' is not available in JIRA Cloud.
1763
+ hasId = user .get ("id" ) is not None and user .get ("id" ) != ""
1764
+ hasName = user .get ("name" ) is not None and user .get ("name" ) != ""
1765
+ result [
1766
+ (
1767
+ user ["id" ]
1768
+ if hasId
1769
+ else user .get ("name" )
1770
+ if hasName
1771
+ else user .get ("accountId" )
1772
+ )
1773
+ ] = {
1774
+ "name" : user .get ("name" ),
1775
+ "id" : user .get ("id" ),
1776
+ "accountId" : user .get ("accountId" ),
1777
+ "fullname" : user .get ("displayName" ),
1778
+ "email" : user .get ("emailAddress" , "hidden" ),
1779
+ "active" : user .get ("active" ),
1780
+ "timezone" : user .get ("timezone" ),
1781
+ }
1782
+ return OrderedDict (sorted (result .items (), key = lambda t : t [0 ]))
1783
1783
1784
1784
def add_group (self , groupname : str ) -> bool :
1785
1785
"""Create a new group in Jira.
@@ -1905,7 +1905,10 @@ def create_issue(
1905
1905
raw_issue_json = json_loads (r )
1906
1906
if "key" not in raw_issue_json :
1907
1907
raise JIRAError (
1908
- status_code = r .status_code , response = r , url = url , text = json .dumps (data )
1908
+ status_code = r .status_code ,
1909
+ response = r ,
1910
+ url = url ,
1911
+ text = json .dumps (data ),
1909
1912
)
1910
1913
if prefetch :
1911
1914
return self .issue (raw_issue_json ["key" ])
@@ -2483,7 +2486,10 @@ def add_remote_link(
2483
2486
2484
2487
data : dict [str , Any ] = {}
2485
2488
if isinstance (destination , Issue ) and destination .raw :
2486
- data ["object" ] = {"title" : str (destination ), "url" : destination .permalink ()}
2489
+ data ["object" ] = {
2490
+ "title" : str (destination ),
2491
+ "url" : destination .permalink (),
2492
+ }
2487
2493
for x in applicationlinks :
2488
2494
if x ["application" ]["displayUrl" ] == destination ._options ["server" ]:
2489
2495
data ["globalId" ] = "appId={}&issueId={}" .format (
@@ -4222,7 +4228,11 @@ def _create_oauth_session(self, oauth: dict[str, Any]):
4222
4228
FALLBACK_SHA = DEFAULT_SHA
4223
4229
_logging .debug ("Fallback SHA 'SIGNATURE_RSA_SHA1' could not be imported." )
4224
4230
4225
- for sha_type in (oauth .get ("signature_method" ), DEFAULT_SHA , FALLBACK_SHA ):
4231
+ for sha_type in (
4232
+ oauth .get ("signature_method" ),
4233
+ DEFAULT_SHA ,
4234
+ FALLBACK_SHA ,
4235
+ ):
4226
4236
if sha_type is None :
4227
4237
continue
4228
4238
oauth_instance = OAuth1 (
@@ -4342,7 +4352,11 @@ def _get_internal_url(self, path: str, base: str = JIRA_BASE_URL) -> str:
4342
4352
"""
4343
4353
options = self ._options .copy ()
4344
4354
options .update (
4345
- {"path" : path , "rest_api_version" : "latest" , "rest_path" : "internal" }
4355
+ {
4356
+ "path" : path ,
4357
+ "rest_api_version" : "latest" ,
4358
+ "rest_path" : "internal" ,
4359
+ }
4346
4360
)
4347
4361
return base .format (** options )
4348
4362
@@ -4496,7 +4510,7 @@ def rename_user(self, old_user: str, new_user: str):
4496
4510
self ._session .put (url , params = params , data = json .dumps (payload ))
4497
4511
else :
4498
4512
raise NotImplementedError (
4499
- "Support for renaming users in Jira " " < 6.0.0 has been removed."
4513
+ "Support for renaming users in Jira < 6.0.0 has been removed."
4500
4514
)
4501
4515
4502
4516
def delete_user (self , username : str ) -> bool :
@@ -4625,7 +4639,10 @@ def reindex(self, force: bool = False, background: bool = True) -> bool:
4625
4639
r = self ._session .post (
4626
4640
url ,
4627
4641
headers = self ._options ["headers" ],
4628
- params = {"indexingStrategy" : indexingStrategy , "reindex" : "Re-Index" },
4642
+ params = {
4643
+ "indexingStrategy" : indexingStrategy ,
4644
+ "reindex" : "Re-Index" ,
4645
+ },
4629
4646
)
4630
4647
if r .text .find ("All issues are being re-indexed" ) != - 1 :
4631
4648
return True
@@ -5574,7 +5591,10 @@ def add_issues_to_sprint(self, sprint_id: int, issue_keys: list[str]) -> Respons
5574
5591
return self ._session .post (url , data = json .dumps (payload ))
5575
5592
5576
5593
def add_issues_to_epic (
5577
- self , epic_id : str , issue_keys : str | list [str ], ignore_epics : bool = None
5594
+ self ,
5595
+ epic_id : str ,
5596
+ issue_keys : str | list [str ],
5597
+ ignore_epics : bool = None ,
5578
5598
) -> Response :
5579
5599
"""Add the issues in ``issue_keys`` to the ``epic_id``.
5580
5600
0 commit comments