Skip to content

Commit

Permalink
Correct a few piece sonar flagged
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanFauble committed Dec 20, 2023
1 parent d797276 commit d43273f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
20 changes: 16 additions & 4 deletions synapseclient/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,22 @@ def from_unix_epoch_time(ms) -> datetime.datetime:
return from_unix_epoch_time_secs(ms / 1000.0)


def datetime_to_iso(dt, sep="T", include_milliseconds=True) -> str:
# Round microseconds to milliseconds (as expected by older clients)
# and add back the "Z" at the end.
# see: http://stackoverflow.com/questions/30266188/how-to-convert-date-string-to-iso8601-standard
def datetime_to_iso(
dt: datetime.datetime, sep: str = "T", include_milliseconds: bool = True
) -> str:
"""
Round microseconds to milliseconds (as expected by older clients) and add back
the "Z" at the end.
See: http://stackoverflow.com/questions/30266188/how-to-convert-date-string-to-iso8601-standard
Args:
dt: The datetime to convert
sep: Seperator character to use.
include_milliseconds: Whether or not to include millseconds in this result.
Returns:
The formatted string.
"""
fmt = (
"{time.year:04}-{time.month:02}-{time.day:02}"
"{sep}{time.hour:02}:{time.minute:02}:{time.second:02}.{millisecond:03}{tz}"
Expand Down
2 changes: 1 addition & 1 deletion synapseutils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ def _convert_manifest_data_items_to_string_list(
return items_to_write


def _convert_manifest_data_row_to_dict(row: dict, keys: typing.List[str]) -> str:
def _convert_manifest_data_row_to_dict(row: dict, keys: typing.List[str]) -> dict:
"""
Convert a row of data to a dict that can be written to a manifest file.
Expand Down
1 change: 0 additions & 1 deletion tests/unit/synapseutils/unit_test_synapseutils_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,6 @@ def test_abort(self):
future_3.cancel.assert_called_once_with()

@pytest.mark.flaky(reruns=3, only_rerun=["AssertionError"])
@pytest.mark.skip # TODO: Remove me. Just for local
def test_upload_error(self, syn):
"""Verify that if an item upload fails the error is raised in the main thread
and any running Futures are cancelled"""
Expand Down

0 comments on commit d43273f

Please sign in to comment.