Skip to content

python2 removal #1515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.11', '3.12', '3.13' ]
python-version: [ '3.9', '3.11', '3.12', '3.13' ]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version: 2
build:
os: ubuntu-lts-latest
tools:
python: "3.8"
python: "3.9"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Run `make` or `make help` to see a list of tasks.
# Based on GCOVR project (https://github.com/gcovr/gcovr).

PYTHON_VERSION ?= 3.7
PYTHON_VERSION ?= 3.9

ATLASSIAN_SDK ?= atlassian-sdk
QA_CONTAINER ?= atlassian-python-api-qa-$(PYTHON_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion atlassian/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.41.21
4.0.0
143 changes: 72 additions & 71 deletions atlassian/bamboo.py

Large diffs are not rendered by default.

183 changes: 78 additions & 105 deletions atlassian/bitbucket/__init__.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions atlassian/bitbucket/cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def __init__(self, url="https://api.bitbucket.org/", *args, **kwargs):
kwargs["cloud"] = True
kwargs["api_root"] = None
kwargs["api_version"] = "2.0"
url = url.strip("/") + "/{}".format(kwargs["api_version"])
url = url.strip("/") + f"/{kwargs['api_version']}"
super(Cloud, self).__init__(url, *args, **kwargs)
self.__workspaces = Workspaces("{}/workspaces".format(self.url), **self._new_session_args)
self.__repositories = Repositories("{}/repositories".format(self.url), **self._new_session_args)
self.__workspaces = Workspaces(f"{self.url}/workspaces", **self._new_session_args)
self.__repositories = Repositories(f"{self.url}/repositories", **self._new_session_args)

@property
def workspaces(self):
Expand Down
4 changes: 2 additions & 2 deletions atlassian/bitbucket/cloud/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
expected_type = kwargs.pop("expected_type", None)
super(BitbucketCloudBase, self).__init__(url, *args, **kwargs)
if expected_type is not None and not expected_type == self.get_data("type"):
raise ValueError("Expected type of data is [{}], got [{}].".format(expected_type, self.get_data("type")))
raise ValueError(f"Expected type of data is [{expected_type}], got [{self.get_data('type')}].")

Check warning on line 25 in atlassian/bitbucket/cloud/base.py

View check run for this annotation

Codecov / codecov/patch

atlassian/bitbucket/cloud/base.py#L25

Added line #L25 was not covered by tests

def get_link(self, link):
"""
Expand Down Expand Up @@ -115,7 +115,7 @@
if e.get("detail"):
# It uses interpolation instead of concatenation because of
# https://github.com/atlassian-api/atlassian-python-api/issues/1481
error_msg = "{}\n{}".format(error_msg, str(e["detail"]))
error_msg = f"{error_msg}\n{str(e['detail'])}"

Check warning on line 118 in atlassian/bitbucket/cloud/base.py

View check run for this annotation

Codecov / codecov/patch

atlassian/bitbucket/cloud/base.py#L118

Added line #L118 was not covered by tests
except Exception as e:
log.error(e)
response.raise_for_status()
Expand Down
3 changes: 2 additions & 1 deletion atlassian/bitbucket/cloud/common/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def refname(self):
def update(self, **kwargs):
"""Update build status.

See https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-put
See
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-put
"""
return self._update_data(self.put(None, data=kwargs))
48 changes: 21 additions & 27 deletions atlassian/bitbucket/cloud/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-get
"""
return self._get_object(super(Repositories, self).get("{}/{}".format(workspace, repo_slug)))
return self._get_object(super(Repositories, self).get(f"{workspace}/{repo_slug}"))

Check warning on line 90 in atlassian/bitbucket/cloud/repositories/__init__.py

View check run for this annotation

Codecov / codecov/patch

atlassian/bitbucket/cloud/repositories/__init__.py#L90

Added line #L90 was not covered by tests


class WorkspaceRepositories(RepositoriesBase):
Expand Down Expand Up @@ -127,7 +127,7 @@
data["is_private"] = is_private
if fork_policy is not None:
if fork_policy not in self.FORK_POLICIES:
raise ValueError("fork_policy must be one of {}".format(self.FORK_POLICIES))
raise ValueError(f"fork_policy must be one of {self.FORK_POLICIES}")

Check warning on line 130 in atlassian/bitbucket/cloud/repositories/__init__.py

View check run for this annotation

Codecov / codecov/patch

atlassian/bitbucket/cloud/repositories/__init__.py#L130

Added line #L130 was not covered by tests
data["fork_policy"] = fork_policy
return self._get_object(self.post(repo_slug, data=data))

Expand Down Expand Up @@ -179,9 +179,9 @@
if r.name == repository:
return r
else:
ValueError("Unknown value '{}' for argument [by], expected 'key' or 'name'".format(by))
ValueError(f"Unknown value '{by}' for argument [by], expected 'key' or 'name'")

Check warning on line 182 in atlassian/bitbucket/cloud/repositories/__init__.py

View check run for this annotation

Codecov / codecov/patch

atlassian/bitbucket/cloud/repositories/__init__.py#L182

Added line #L182 was not covered by tests

raise Exception("Unknown repository {} '{}'".format(by, repository))
raise Exception(f"Unknown repository {by} '{repository}'")

Check warning on line 184 in atlassian/bitbucket/cloud/repositories/__init__.py

View check run for this annotation

Codecov / codecov/patch

atlassian/bitbucket/cloud/repositories/__init__.py#L184

Added line #L184 was not covered by tests

def exists(self, repository, by="slug"):
"""
Expand All @@ -203,7 +203,7 @@
if e.response.status_code in (401, 404):
pass
except Exception as e:
if not str(e) == "Unknown project {} '{}'".format(by, repository):
if not str(e) == f"Unknown project {by} '{repository}'":
raise e
return exists

Expand Down Expand Up @@ -243,46 +243,40 @@
https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D/projects/%7Bproject_key%7D#get
"""
if by not in ("slug", "name"):
ValueError("Unknown value '{}' for argument [by], expected 'slug' or 'name'".format(by))
ValueError(f"Unknown value '{by}' for argument [by], expected 'slug' or 'name'")

Check warning on line 246 in atlassian/bitbucket/cloud/repositories/__init__.py

View check run for this annotation

Codecov / codecov/patch

atlassian/bitbucket/cloud/repositories/__init__.py#L246

Added line #L246 was not covered by tests

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

raise Exception("Unknown repository {} '{}'".format(by, repository))
raise Exception(f"Unknown repository {by} '{repository}'")

Check warning on line 252 in atlassian/bitbucket/cloud/repositories/__init__.py

View check run for this annotation

Codecov / codecov/patch

atlassian/bitbucket/cloud/repositories/__init__.py#L252

Added line #L252 was not covered by tests


class Repository(BitbucketCloudBase):
def __init__(self, data, *args, **kwargs):
super(Repository, self).__init__(None, *args, data=data, expected_type="repository", **kwargs)
self.__branch_restrictions = BranchRestrictions(
"{}/branch-restrictions".format(self.url), **self._new_session_args
)
self.__branches = Branches("{}/refs/branches".format(self.url), **self._new_session_args)
self.__branch_restrictions = BranchRestrictions(f"{self.url}/branch-restrictions", **self._new_session_args)
self.__branches = Branches(f"{self.url}/refs/branches", **self._new_session_args)
self.__commits = Commits(
"{}/commits".format(self.url),
data={"links": {"commit": {"href": "{}/commit".format(self.url)}}},
f"{self.url}/commits",
data={"links": {"commit": {"href": f"{self.url}/commit"}}},
**self._new_session_args
) # fmt: skip
self.__hooks = Hooks(
"{}/hooks".format(self.url),
data={"links": {"hooks": {"href": "{}/hooks".format(self.url)}}},
f"{self.url}/hooks",
data={"links": {"hooks": {"href": f"{self.url}/hooks"}}},
**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
)
self.__group_permissions = GroupPermissions(
"{}/permissions-config/groups".format(self.url), **self._new_session_args
)
self.__issues = Issues("{}/issues".format(self.url), **self._new_session_args)
self.__pipelines = Pipelines("{}/pipelines".format(self.url), **self._new_session_args)
self.__pullrequests = PullRequests("{}/pullrequests".format(self.url), **self._new_session_args)
self.__default_reviewers = DefaultReviewers(f"{self.url}/default-reviewers", **self._new_session_args)
self.__deployment_environments = DeploymentEnvironments(f"{self.url}/environments", **self._new_session_args)
self.__group_permissions = GroupPermissions(f"{self.url}/permissions-config/groups", **self._new_session_args)
self.__issues = Issues(f"{self.url}/issues", **self._new_session_args)
self.__pipelines = Pipelines(f"{self.url}/pipelines", **self._new_session_args)
self.__pullrequests = PullRequests(f"{self.url}/pullrequests", **self._new_session_args)
self.__repository_variables = RepositoryVariables(
"{}/pipelines_config/variables".format(self.url), **self._new_session_args
f"{self.url}/pipelines_config/variables", **self._new_session_args
)
self.__tags = Tags("{}/refs/tags".format(self.url), **self._new_session_args)
self.__tags = Tags(f"{self.url}/refs/tags", **self._new_session_args)

def update(self, **kwargs):
"""
Expand Down
12 changes: 8 additions & 4 deletions atlassian/bitbucket/cloud/repositories/branchRestrictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def create(

:return: The created BranchRestriction object

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions#post
API docs:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions#post
"""
if branch_match_kind == "branching_model":
branch_pattern = ""
Expand Down Expand Up @@ -103,7 +104,8 @@ def get(self, id):

:return: The requested BranchRestriction objects

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#get
API docs:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#get
"""
return self.__get_object(super(BranchRestrictions, self).get(id))

Expand All @@ -120,7 +122,8 @@ def update(self, **kwargs):

:return: The updated branch restriction

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#put
API docs:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#put
"""
return self._update_data(self.put(None, data=kwargs))

Expand All @@ -130,7 +133,8 @@ def delete(self):

:return: The response on success

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#delete
API docs:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions/%7Bid%7D#delete
"""
return super(BranchRestriction, self).delete(None)

Expand Down
33 changes: 22 additions & 11 deletions atlassian/bitbucket/cloud/repositories/commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def each(self, top=None, q=None, sort=None):

:return: A generator for the Commit objects

API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commits-get
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commits-get
"""
params = {}
if sort is not None:
Expand All @@ -48,7 +49,8 @@ def get(self, commit_hash):

:return: The requested Commit object

API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get
"""
return self.__get_object(
super(Commits, self).get(
Expand All @@ -62,7 +64,8 @@ class Commit(BitbucketCloudBase):
"""
Bitbucket Cloud commit endpoint.

See https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get
See
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-get
"""

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

Expand All @@ -122,7 +126,8 @@ def add_build(
"""
Add new build status to commit.

API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-post
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-post
"""
data = {
"key": key,
Expand All @@ -138,7 +143,8 @@ def get_build(self, key):
"""
Return a specific build for the commit.

API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-get
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-key-get
"""
return Build(
super(Commit, self).get(self.url_joiner("statuses/build", key)),
Expand All @@ -148,7 +154,8 @@ def get_build(self, key):
def comments(self):
"""
Return generator object endpoint of the comment.
API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-comments-get
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-comments-get
"""
for comment in self._get_paged("comments"):
yield Comment(comment, **self._new_session_args)
Expand All @@ -157,7 +164,8 @@ def comment(self, raw_message):
"""
Add a comment to the pull request in raw format.

API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-comments-post
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-comments-post
"""
if not raw_message:
raise ValueError("No message set")
Expand All @@ -174,7 +182,8 @@ def approve(self):
"""
Approve a commit.

API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-post
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-post
"""
data = {"approved": True}
return self.post("approve", data)
Expand All @@ -183,7 +192,8 @@ def unapprove(self):
"""
Unapprove a commit.

API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-delete
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commits/#api-repositories-workspace-repo-slug-commit-commit-approve-delete
"""
return super(BitbucketCloudBase, self).delete("approve")

Expand All @@ -195,7 +205,8 @@ def get_pull_requests(self, start=0, pagelen=0):
installation automatically occurs when 'Go to pull request' is clicked
from the web interface for a commit's details.

API docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get
API docs:
https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get

:param start: int, OPTIONAL: The starting page of pull requests to retrieve. Defaults to 0.
:param pagelen: int, OPTIONAL: The number of pull requests to retrieve per page. Defaults to 0.
Expand Down
12 changes: 8 additions & 4 deletions atlassian/bitbucket/cloud/repositories/defaultReviewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def add(self, user):

:return: The added DefaultReviewer object

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#put
API docs:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#put
"""
# the mention_id parameter is undocumented but if missed, leads to 400 statuses
return self.__get_object(self.put(user, data={"mention_id": user}))
Expand All @@ -45,7 +46,8 @@ def each(self, q=None, sort=None):

:return: A generator for the DefaultReviewer objects

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers#get
API docs:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers#get
"""
params = {}
if sort is not None:
Expand All @@ -65,7 +67,8 @@ def get(self, user):

:return: The requested DefaultReviewer object, None if not a default reviewer

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#get
API docs:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#get
"""
default_reviewer = None
try:
Expand All @@ -89,6 +92,7 @@ def delete(self):

:return: The response on success

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#delete
API docs:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/default-reviewers/%7Btarget_username%7D#delete
"""
return super(DefaultReviewer, self).delete(None)
Loading