Skip to content

Commit

Permalink
fix(pdm): avoid deprecation warning for PDM 2.17+ (#35)
Browse files Browse the repository at this point in the history
PDM commit changing lock behaviour: pdm-project/pdm@c190e14
MR: pdm-project/pdm#2995
  • Loading branch information
GabDug committed Aug 1, 2024
1 parent fe3faac commit 895cced
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/sync_pre_commit_lock/pdm_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from pdm.cli.hooks import HookManager
from pdm.core import Core
from pdm.models.candidates import Candidate
from pdm.models.repositories.lock import LockedRepository
from pdm.project import Project
from pdm.termui import UI

Expand Down Expand Up @@ -164,6 +165,12 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
dry_run_option.add_to_parser(parser)

def handle(self, project: Project, options: argparse.Namespace) -> None:
candidates = project.locked_repository.all_candidates
candidates = self._get_locked_repository(project).all_candidates

on_pdm_lock_check_pre_commit(project, resolution=candidates, dry_run=options.dry_run, with_prefix=False)

def _get_locked_repository(self, project: Project) -> LockedRepository:
# `locked_repository` was deprecated in PDM 2.17 favour of `get_locked_repository`, try to use it first to avoid warning
if hasattr(project, "get_locked_repository"):
return project.get_locked_repository()
return project.locked_repository

0 comments on commit 895cced

Please sign in to comment.