WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit d954e79

Browse files
authored
fix: inherit_metadata would be written in lock file if the file is not pdm.lock even strategy config is true (#3236)
Fixes #3232 Signed-off-by: Frost Ming <[email protected]>
1 parent efaccb8 commit d954e79

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

news/3232.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug that `strategy.inherit_metadata` config is not honored when using `--lockfile` option.

src/pdm/project/core.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,16 @@ def pyproject(self) -> PyProject:
202202
@property
203203
def lockfile(self) -> Lockfile:
204204
if self._lockfile is None:
205-
self._lockfile = Lockfile(self.root / self.LOCKFILE_FILENAME, ui=self.core.ui)
206-
if self.config.get("use_uv"):
207-
self._lockfile.default_strategies.discard(FLAG_INHERIT_METADATA)
208-
if not self.config["strategy.inherit_metadata"]:
209-
self._lockfile.default_strategies.discard(FLAG_INHERIT_METADATA)
205+
self.set_lockfile(self.root / self.LOCKFILE_FILENAME)
206+
assert self._lockfile is not None
210207
return self._lockfile
211208

212209
def set_lockfile(self, path: str | Path) -> None:
213210
self._lockfile = Lockfile(path, ui=self.core.ui)
211+
if self.config.get("use_uv"):
212+
self._lockfile.default_strategies.discard(FLAG_INHERIT_METADATA)
213+
if not self.config["strategy.inherit_metadata"]:
214+
self._lockfile.default_strategies.discard(FLAG_INHERIT_METADATA)
214215

215216
@cached_property
216217
def config(self) -> Mapping[str, Any]:

0 commit comments

Comments
 (0)