Skip to content

Commit cc7c5cb

Browse files
committed
f-stringify
1 parent f7c5955 commit cc7c5cb

File tree

76 files changed

+827
-854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+827
-854
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.41.21
1+
4.0.0

atlassian/bamboo.py

Lines changed: 72 additions & 71 deletions
Large diffs are not rendered by default.

atlassian/bitbucket/__init__.py

Lines changed: 78 additions & 105 deletions
Large diffs are not rendered by default.

atlassian/bitbucket/cloud/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ def __init__(self, url="https://api.bitbucket.org/", *args, **kwargs):
1010
kwargs["cloud"] = True
1111
kwargs["api_root"] = None
1212
kwargs["api_version"] = "2.0"
13-
url = url.strip("/") + "/{}".format(kwargs["api_version"])
13+
url = url.strip("/") + f"/{kwargs['api_version']}"
1414
super(Cloud, self).__init__(url, *args, **kwargs)
15-
self.__workspaces = Workspaces("{}/workspaces".format(self.url), **self._new_session_args)
16-
self.__repositories = Repositories("{}/repositories".format(self.url), **self._new_session_args)
15+
self.__workspaces = Workspaces(f"{self.url}/workspaces", **self._new_session_args)
16+
self.__repositories = Repositories(f"{self.url}/repositories", **self._new_session_args)
1717

1818
@property
1919
def workspaces(self):

atlassian/bitbucket/cloud/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, url, *args, **kwargs):
2222
expected_type = kwargs.pop("expected_type", None)
2323
super(BitbucketCloudBase, self).__init__(url, *args, **kwargs)
2424
if expected_type is not None and not expected_type == self.get_data("type"):
25-
raise ValueError("Expected type of data is [{}], got [{}].".format(expected_type, self.get_data("type")))
25+
raise ValueError(f"Expected type of data is [{expected_type}], got [{self.get_data('type')}].")
2626

2727
def get_link(self, link):
2828
"""
@@ -115,7 +115,7 @@ def raise_for_status(self, response):
115115
if e.get("detail"):
116116
# It uses interpolation instead of concatenation because of
117117
# https://github.com/atlassian-api/atlassian-python-api/issues/1481
118-
error_msg = "{}\n{}".format(error_msg, str(e["detail"]))
118+
error_msg = f"{error_msg}\n{str(e['detail'])}"
119119
except Exception as e:
120120
log.error(e)
121121
response.raise_for_status()

atlassian/bitbucket/cloud/common/builds.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def refname(self):
8080
def update(self, **kwargs):
8181
"""Update build status.
8282
83-
See https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-put
83+
See
84+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-put
8485
"""
8586
return self._update_data(self.put(None, data=kwargs))

atlassian/bitbucket/cloud/repositories/__init__.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def get(self, workspace, repo_slug):
8787
API docs:
8888
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-get
8989
"""
90-
return self._get_object(super(Repositories, self).get("{}/{}".format(workspace, repo_slug)))
90+
return self._get_object(super(Repositories, self).get(f"{workspace}/{repo_slug}"))
9191

9292

9393
class WorkspaceRepositories(RepositoriesBase):
@@ -127,7 +127,7 @@ def create(self, repo_slug, project_key=None, is_private=None, fork_policy=None)
127127
data["is_private"] = is_private
128128
if fork_policy is not None:
129129
if fork_policy not in self.FORK_POLICIES:
130-
raise ValueError("fork_policy must be one of {}".format(self.FORK_POLICIES))
130+
raise ValueError(f"fork_policy must be one of {self.FORK_POLICIES}")
131131
data["fork_policy"] = fork_policy
132132
return self._get_object(self.post(repo_slug, data=data))
133133

@@ -179,9 +179,9 @@ def get(self, repository, by="slug"):
179179
if r.name == repository:
180180
return r
181181
else:
182-
ValueError("Unknown value '{}' for argument [by], expected 'key' or 'name'".format(by))
182+
ValueError(f"Unknown value '{by}' for argument [by], expected 'key' or 'name'")
183183

184-
raise Exception("Unknown repository {} '{}'".format(by, repository))
184+
raise Exception(f"Unknown repository {by} '{repository}'")
185185

186186
def exists(self, repository, by="slug"):
187187
"""
@@ -203,7 +203,7 @@ def exists(self, repository, by="slug"):
203203
if e.response.status_code in (401, 404):
204204
pass
205205
except Exception as e:
206-
if not str(e) == "Unknown project {} '{}'".format(by, repository):
206+
if not str(e) == f"Unknown project {by} '{repository}'":
207207
raise e
208208
return exists
209209

@@ -243,46 +243,46 @@ def get(self, repository, by="slug"):
243243
https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D/projects/%7Bproject_key%7D#get
244244
"""
245245
if by not in ("slug", "name"):
246-
ValueError("Unknown value '{}' for argument [by], expected 'slug' or 'name'".format(by))
246+
ValueError(f"Unknown value '{by}' for argument [by], expected 'slug' or 'name'")
247247

248248
for r in self.each():
249249
if ((by == "slug") and (r.slug == repository)) or ((by == "name") and (r.name == repository)):
250250
return r
251251

252-
raise Exception("Unknown repository {} '{}'".format(by, repository))
252+
raise Exception(f"Unknown repository {by} '{repository}'")
253253

254254

255255
class Repository(BitbucketCloudBase):
256256
def __init__(self, data, *args, **kwargs):
257257
super(Repository, self).__init__(None, *args, data=data, expected_type="repository", **kwargs)
258258
self.__branch_restrictions = BranchRestrictions(
259-
"{}/branch-restrictions".format(self.url), **self._new_session_args
259+
f"{self.url}/branch-restrictions", **self._new_session_args
260260
)
261-
self.__branches = Branches("{}/refs/branches".format(self.url), **self._new_session_args)
261+
self.__branches = Branches(f"{self.url}/refs/branches", **self._new_session_args)
262262
self.__commits = Commits(
263-
"{}/commits".format(self.url),
264-
data={"links": {"commit": {"href": "{}/commit".format(self.url)}}},
263+
f"{self.url}/commits",
264+
data={"links": {"commit": {"href": f"{self.url}/commit"}}},
265265
**self._new_session_args
266266
) # fmt: skip
267267
self.__hooks = Hooks(
268-
"{}/hooks".format(self.url),
269-
data={"links": {"hooks": {"href": "{}/hooks".format(self.url)}}},
268+
f"{self.url}/hooks",
269+
data={"links": {"hooks": {"href": f"{self.url}/hooks"}}},
270270
**self._new_session_args
271271
) # fmt: skip
272-
self.__default_reviewers = DefaultReviewers("{}/default-reviewers".format(self.url), **self._new_session_args)
272+
self.__default_reviewers = DefaultReviewers(f"{self.url}/default-reviewers", **self._new_session_args)
273273
self.__deployment_environments = DeploymentEnvironments(
274-
"{}/environments".format(self.url), **self._new_session_args
274+
f"{self.url}/environments", **self._new_session_args
275275
)
276276
self.__group_permissions = GroupPermissions(
277-
"{}/permissions-config/groups".format(self.url), **self._new_session_args
277+
f"{self.url}/permissions-config/groups", **self._new_session_args
278278
)
279-
self.__issues = Issues("{}/issues".format(self.url), **self._new_session_args)
280-
self.__pipelines = Pipelines("{}/pipelines".format(self.url), **self._new_session_args)
281-
self.__pullrequests = PullRequests("{}/pullrequests".format(self.url), **self._new_session_args)
279+
self.__issues = Issues(f"{self.url}/issues", **self._new_session_args)
280+
self.__pipelines = Pipelines(f"{self.url}/pipelines", **self._new_session_args)
281+
self.__pullrequests = PullRequests(f"{self.url}/pullrequests", **self._new_session_args)
282282
self.__repository_variables = RepositoryVariables(
283-
"{}/pipelines_config/variables".format(self.url), **self._new_session_args
283+
f"{self.url}/pipelines_config/variables", **self._new_session_args
284284
)
285-
self.__tags = Tags("{}/refs/tags".format(self.url), **self._new_session_args)
285+
self.__tags = Tags(f"{self.url}/refs/tags", **self._new_session_args)
286286

287287
def update(self, **kwargs):
288288
"""

atlassian/bitbucket/cloud/repositories/branchRestrictions.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def create(
4141
4242
:return: The created BranchRestriction object
4343
44-
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions#post
44+
API docs:
45+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions#post
4546
"""
4647
if branch_match_kind == "branching_model":
4748
branch_pattern = ""
@@ -103,7 +104,8 @@ def get(self, id):
103104
104105
:return: The requested BranchRestriction objects
105106
106-
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#get
107+
API docs:
108+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#get
107109
"""
108110
return self.__get_object(super(BranchRestrictions, self).get(id))
109111

@@ -120,7 +122,8 @@ def update(self, **kwargs):
120122
121123
:return: The updated branch restriction
122124
123-
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#put
125+
API docs:
126+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#put
124127
"""
125128
return self._update_data(self.put(None, data=kwargs))
126129

@@ -130,7 +133,8 @@ def delete(self):
130133
131134
:return: The response on success
132135
133-
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#delete
136+
API docs:
137+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#delete
134138
"""
135139
return super(BranchRestriction, self).delete(None)
136140

atlassian/bitbucket/cloud/repositories/commits.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def each(self, top=None, q=None, sort=None):
2727
2828
:return: A generator for the Commit objects
2929
30-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commits-get
30+
API docs:
31+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commits-get
3132
"""
3233
params = {}
3334
if sort is not None:
@@ -48,7 +49,8 @@ def get(self, commit_hash):
4849
4950
:return: The requested Commit object
5051
51-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get
52+
API docs:
53+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get
5254
"""
5355
return self.__get_object(
5456
super(Commits, self).get(
@@ -62,7 +64,8 @@ class Commit(BitbucketCloudBase):
6264
"""
6365
Bitbucket Cloud commit endpoint.
6466
65-
See https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get
67+
See
68+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get
6669
"""
6770

6871
def __init__(self, data, *args, **kwargs):
@@ -96,7 +99,8 @@ def parents(self):
9699
def statuses(self):
97100
"""
98101
Return generator object of the status's endpoint.
99-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-get
102+
API docs:
103+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-get
100104
"""
101105
return self._get_paged("statuses")
102106

@@ -122,7 +126,8 @@ def add_build(
122126
"""
123127
Add new build status to commit.
124128
125-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-post
129+
API docs:
130+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-post
126131
"""
127132
data = {
128133
"key": key,
@@ -138,7 +143,8 @@ def get_build(self, key):
138143
"""
139144
Return a specific build for the commit.
140145
141-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-get
146+
API docs:
147+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-get
142148
"""
143149
return Build(
144150
super(Commit, self).get(self.url_joiner("statuses/build", key)),
@@ -148,7 +154,8 @@ def get_build(self, key):
148154
def comments(self):
149155
"""
150156
Return generator object endpoint of the comment.
151-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-comments-get
157+
API docs:
158+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-comments-get
152159
"""
153160
for comment in self._get_paged("comments"):
154161
yield Comment(comment, **self._new_session_args)
@@ -157,7 +164,8 @@ def comment(self, raw_message):
157164
"""
158165
Add a comment to the pull request in raw format.
159166
160-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-comments-post
167+
API docs:
168+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-comments-post
161169
"""
162170
if not raw_message:
163171
raise ValueError("No message set")
@@ -174,7 +182,8 @@ def approve(self):
174182
"""
175183
Approve a commit.
176184
177-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-post
185+
API docs:
186+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-post
178187
"""
179188
data = {"approved": True}
180189
return self.post("approve", data)
@@ -183,7 +192,8 @@ def unapprove(self):
183192
"""
184193
Unapprove a commit.
185194
186-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-delete
195+
API docs:
196+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-delete
187197
"""
188198
return super(BitbucketCloudBase, self).delete("approve")
189199

@@ -195,7 +205,8 @@ def get_pull_requests(self, start=0, pagelen=0):
195205
installation automatically occurs when 'Go to pull request' is clicked
196206
from the web interface for a commit's details.
197207
198-
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get
208+
API docs:
209+
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get
199210
200211
:param start: int, OPTIONAL: The starting page of pull requests to retrieve. Defaults to 0.
201212
:param pagelen: int, OPTIONAL: The number of pull requests to retrieve per page. Defaults to 0.

atlassian/bitbucket/cloud/repositories/defaultReviewers.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def add(self, user):
2727
2828
:return: The added DefaultReviewer object
2929
30-
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#put
30+
API docs:
31+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#put
3132
"""
3233
# the mention_id parameter is undocumented but if missed, leads to 400 statuses
3334
return self.__get_object(self.put(user, data={"mention_id": user}))
@@ -45,7 +46,8 @@ def each(self, q=None, sort=None):
4546
4647
:return: A generator for the DefaultReviewer objects
4748
48-
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers#get
49+
API docs:
50+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers#get
4951
"""
5052
params = {}
5153
if sort is not None:
@@ -65,7 +67,8 @@ def get(self, user):
6567
6668
:return: The requested DefaultReviewer object, None if not a default reviewer
6769
68-
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#get
70+
API docs:
71+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#get
6972
"""
7073
default_reviewer = None
7174
try:
@@ -89,6 +92,7 @@ def delete(self):
8992
9093
:return: The response on success
9194
92-
API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#delete
95+
API docs:
96+
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#delete
9397
"""
9498
return super(DefaultReviewer, self).delete(None)

0 commit comments

Comments
 (0)