未验证 提交 6a4d78a9 编写于 作者: F Frost Ming

fix: override the unnamed requirements

Fix #1287
上级 fc647649
Fix a bug that unnamed requirements can't override the old ones in either `add` or `update` command.
......@@ -284,7 +284,7 @@ def do_add(
if not dry_run:
project.add_dependencies(deps_to_update, group, dev)
project.write_lockfile(project.lockfile, False)
_populate_requirement_names(group_deps)
if sync:
do_sync(
project,
......@@ -298,6 +298,14 @@ def do_add(
)
def _populate_requirement_names(req_mapping: dict[str, Requirement]) -> None:
# Update the requirement key if the name changed.
for key, req in list(req_mapping.items()):
if key and key.startswith(":empty:"):
req_mapping[req.identify()] = req
del req_mapping[key]
def do_update(
project: Project,
*,
......@@ -373,6 +381,8 @@ def do_update(
dry_run=dry_run,
hooks=hooks,
)
for deps in updated_deps.values():
_populate_requirement_names(deps)
if sync or dry_run:
do_sync(
project,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册