Skip to content

Commit

Permalink
Use Path.hardlink_to to avoid warnings about link_to deprecation
Browse files Browse the repository at this point in the history
    src/strava_offline/gpx.py:38: DeprecationWarning: pathlib.Path.link_to() is deprecated and is scheduled for removal in Python 3.12. Use pathlib.Path.hardlink_to() instead.
  • Loading branch information
liskin committed Nov 2, 2023
1 parent 25f22a9 commit b1ce67c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/strava_offline/gpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def link_backup_activities(
backup = find_gpx(dir_activities_backup, activity_id) or find_gpx(dir_activities_backup, upload_id)
if backup:
link = Path(dir_activities, str(activity_id) + "".join(backup.suffixes))
if hasattr(backup, 'link_to'):
backup.link_to(link) # type: ignore [attr-defined]
if hasattr(backup, 'hardlink_to'):
link.hardlink_to(backup) # type: ignore [attr-defined]
else:
os.link(backup, link) # python 3.7 compat
os.link(backup, link) # python 3.9 compat


def download_gpx(strava: StravaWeb, activity_id: int, path: Path) -> None:
Expand Down

0 comments on commit b1ce67c

Please sign in to comment.