Skip to content

[Bitbucket] keep only 6 digits when using %f in datetime format #1511

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 4 commits into from
Mar 24, 2025
Merged
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
27 changes: 15 additions & 12 deletions atlassian/bitbucket/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def __init__(self, url, *args, **kwargs):
url = self.get_link("self")
if isinstance(url, list): # Server has a list of links
url = url[0]
self.timeformat_lambda = kwargs.pop("timeformat_lambda", lambda x: self._default_timeformat_lambda(x))
self.timeformat_lambda = kwargs.pop("timeformat_lambda", self._default_timeformat_lambda)
self._check_timeformat_lambda()
super(BitbucketBase, self).__init__(url, *args, **kwargs)
super().__init__(url, *args, **kwargs)

def __str__(self):
return PrettyPrinter(indent=4).pformat(self.__data if self.__data else self)
Expand Down Expand Up @@ -74,8 +74,7 @@ def _get_paged(
if "values" not in response:
return

for value in response.get("values", []):
yield value
yield from response.get("values", [])

if self.cloud:
url = response.get("next")
Expand Down Expand Up @@ -165,9 +164,13 @@ def get_time(self, id):
if sys.version_info <= (3, 7):
value_str = RE_TIMEZONE.sub(r"\1\2", value_str)
try:
value_str = value_str[:26] + "Z"
value = datetime.strptime(value_str, self.CONF_TIMEFORMAT)
except ValueError:
value = datetime.strptime(value_str, "%Y-%m-%dT%H:%M:%S.%fZ", tzinfo="UTC")
value = datetime.strptime(
value_str,
"%Y-%m-%dT%H:%M:%S.%fZ",
)
else:
value = value_str

Expand All @@ -192,10 +195,10 @@ def _new_session_args(self):

:return: A dict with the kwargs for new objects
"""
return dict(
session=self._session,
cloud=self.cloud,
api_root=self.api_root,
api_version=self.api_version,
timeformat_lambda=self.timeformat_lambda,
)
return {
"session": self._session,
"cloud": self.cloud,
"api_root": self.api_root,
"api_version": self.api_version,
"timeformat_lambda": self.timeformat_lambda,
}