Skip to content

Commit

Permalink
Continue to support Python 2 (#1453)
Browse files Browse the repository at this point in the history
Avoid Python 3-only capabilities:
- Remove f-strings (jira.py, confluence.py)
- Remove type specifications (bitbucket)
- Remove trailing commas (bitbucket)
  • Loading branch information
madscientist authored Oct 20, 2024
1 parent bdf2ffc commit 014c1af
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions atlassian/bitbucket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2208,13 +2208,13 @@ def is_pull_request_can_be_merged(self, project_key, repository_slug, pr_id):

def merge_pull_request(
self,
project_key: str,
repository_slug: str,
pr_id: int,
merge_message: str,
close_source_branch: bool = False,
merge_strategy: Union[str, MergeStrategy] = MergeStrategy.MERGE_COMMIT,
pr_version: Optional[int] = None,
project_key,
repository_slug,
pr_id,
merge_message,
close_source_branch=False,
merge_strategy=MergeStrategy.MERGE_COMMIT,
pr_version=None,
):
"""
Merge pull request
Expand Down
4 changes: 2 additions & 2 deletions atlassian/bitbucket/cloud/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ def __init__(self, data, *args, **kwargs):
self.__hooks = Hooks(
"{}/hooks".format(self.url),
data={"links": {"hooks": {"href": "{}/hooks".format(self.url)}}},
**self._new_session_args,
)
**self._new_session_args
) # fmt: skip
self.__default_reviewers = DefaultReviewers("{}/default-reviewers".format(self.url), **self._new_session_args)
self.__deployment_environments = DeploymentEnvironments(
"{}/environments".format(self.url), **self._new_session_args
Expand Down
8 changes: 4 additions & 4 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50):
if not file_name:
file_name = attachment["id"] # if the attachment has no title, use attachment_id as a filename
download_link = self.url + attachment["_links"]["download"]
r = self._session.get(f"{download_link}")
r = self._session.get(download_link)
file_path = os.path.join(path, file_name)
with open(file_path, "wb") as f:
f.write(r.content)
Expand Down Expand Up @@ -3091,7 +3091,7 @@ def create_whiteboard(self, spaceId, title=None, parentId=None):

def get_whiteboard(self, whiteboard_id):
try:
url = f"/api/v2/whiteboards/{whiteboard_id}"
url = "/api/v2/whiteboards/%s" % (whiteboard_id)
return self.get(url)
except HTTPError as e:
# Default 404 error handling is ambiguous
Expand All @@ -3104,7 +3104,7 @@ def get_whiteboard(self, whiteboard_id):

def delete_whiteboard(self, whiteboard_id):
try:
url = f"/api/v2/whiteboards/{whiteboard_id}"
url = "/api/v2/whiteboards/%s" % (whiteboard_id)
return self.delete(url)
except HTTPError as e:
# # Default 404 error handling is ambiguous
Expand Down Expand Up @@ -3240,7 +3240,7 @@ def add_user_to_group(self, username, group_name):
:param group_name: str - name of group to add user to
:return: Current state of the group
"""
url = f"rest/api/user/{username}/group/{group_name}"
url = "rest/api/user/%s/group/%s" % (username, group_name)
return self.put(url)

def add_space_permissions(
Expand Down
6 changes: 3 additions & 3 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ def download_attachments_from_issue(self, issue, path=None, cloud=True):
path = os.getcwd()
issue_id = self.issue(issue, fields="id")["id"]
if cloud:
url = self.url + f"/secure/issueAttachments/{issue_id}.zip"
url = self.url + "/secure/issueAttachments/%s.zip" % (issue_id)
else:
url = self.url + f"/secure/attachmentzip/{issue_id}.zip"
url = self.url + "/secure/attachmentzip/%s.zip" % (issue_id)
response = self._session.get(url)
attachment_name = f"{issue_id}_attachments.zip"
attachment_name = "%s_attachments.zip" % (issue_id)
file_path = os.path.join(path, attachment_name)
# if Jira issue doesn't have any attachments _session.get request response will return 22 bytes of PKzip format
file_size = sum(len(chunk) for chunk in response.iter_content(8196))
Expand Down

0 comments on commit 014c1af

Please sign in to comment.