Pin lock futures (#16643)

These futures are quite large (~16,000 bytes) and adding new fields to
the `ResolverOptions` in another pull request caused a lint error from
Clippy.
This commit is contained in:
Zanie Blue 2025-11-09 10:37:16 -06:00 committed by GitHub
parent caf49f845f
commit 2d9fe7ca70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 176 additions and 154 deletions

View File

@ -990,7 +990,8 @@ async fn lock_and_sync(
printer: Printer,
preview: Preview,
) -> Result<(), ProjectError> {
let mut lock = project::lock::LockOperation::new(
let mut lock = Box::pin(
project::lock::LockOperation::new(
if let LockCheck::Enabled(lock_check) = lock_check {
LockMode::Locked(target.interpreter(), lock_check)
} else {
@ -1007,7 +1008,8 @@ async fn lock_and_sync(
preview,
)
.with_constraints(constraints)
.execute((&target).into())
.execute((&target).into()),
)
.await?
.into_lock();
@ -1112,7 +1114,8 @@ async fn lock_and_sync(
// If the file was modified, we have to lock again, though the only expected change is
// the addition of the minimum version specifiers.
lock = project::lock::LockOperation::new(
lock = Box::pin(
project::lock::LockOperation::new(
if let LockCheck::Enabled(lock_check) = lock_check {
LockMode::Locked(target.interpreter(), lock_check)
} else {
@ -1128,7 +1131,8 @@ async fn lock_and_sync(
printer,
preview,
)
.execute((&target).into())
.execute((&target).into()),
)
.await?
.into_lock();
}

View File

@ -199,7 +199,8 @@ pub(crate) async fn export(
let state = UniversalState::default();
// Lock the project.
let lock = match LockOperation::new(
let lock = match Box::pin(
LockOperation::new(
mode,
&settings,
&client_builder,
@ -211,7 +212,8 @@ pub(crate) async fn export(
printer,
preview,
)
.execute((&target).into())
.execute((&target).into()),
)
.await
{
Ok(result) => result.into_lock(),

View File

@ -190,7 +190,8 @@ pub(crate) async fn lock(
let state = UniversalState::default();
// Perform the lock operation.
match LockOperation::new(
match Box::pin(
LockOperation::new(
mode,
&settings,
&client_builder,
@ -203,7 +204,8 @@ pub(crate) async fn lock(
preview,
)
.with_refresh(&refresh)
.execute(target)
.execute(target),
)
.await
{
Ok(lock) => {
@ -355,7 +357,7 @@ impl<'env> LockOperation<'env> {
.ok_or_else(|| ProjectError::MissingLockfile)?;
// Perform the lock operation, but don't write the lockfile to disk.
let result = do_lock(
let result = Box::pin(do_lock(
target,
interpreter,
Some(existing),
@ -370,7 +372,7 @@ impl<'env> LockOperation<'env> {
self.workspace_cache,
self.printer,
self.preview,
)
))
.await?;
// If the lockfile changed, return an error.
@ -399,7 +401,7 @@ impl<'env> LockOperation<'env> {
};
// Perform the lock operation.
let result = do_lock(
let result = Box::pin(do_lock(
target,
interpreter,
existing,
@ -414,7 +416,7 @@ impl<'env> LockOperation<'env> {
self.workspace_cache,
self.printer,
self.preview,
)
))
.await?;
// If the lockfile changed, write it to disk.

View File

@ -301,7 +301,8 @@ pub(crate) async fn remove(
let state = UniversalState::default();
// Lock and sync the environment, if necessary.
let lock = match project::lock::LockOperation::new(
let lock = match Box::pin(
project::lock::LockOperation::new(
mode,
&settings.resolver,
&client_builder,
@ -313,7 +314,8 @@ pub(crate) async fn remove(
printer,
preview,
)
.execute((&target).into())
.execute((&target).into()),
)
.await
{
Ok(result) => result.into_lock(),

View File

@ -271,7 +271,8 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
};
// Generate a lockfile.
let lock = match project::lock::LockOperation::new(
let lock = match Box::pin(
project::lock::LockOperation::new(
mode,
&settings.resolver,
&client_builder,
@ -287,7 +288,8 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
printer,
preview,
)
.execute(target)
.execute(target),
)
.await
{
Ok(result) => result.into_lock(),
@ -748,7 +750,8 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
LockMode::Write(venv.interpreter())
};
let result = match project::lock::LockOperation::new(
let result = match Box::pin(
project::lock::LockOperation::new(
mode,
&settings.resolver,
&client_builder,
@ -764,7 +767,8 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
printer,
preview,
)
.execute(project.workspace().into())
.execute(project.workspace().into()),
)
.await
{
Ok(result) => result,

View File

@ -331,7 +331,8 @@ pub(crate) async fn sync(
SyncTarget::Script(script) => LockTarget::from(script),
};
let outcome = match LockOperation::new(
let outcome = match Box::pin(
LockOperation::new(
mode,
&settings.resolver,
&client_builder,
@ -343,7 +344,8 @@ pub(crate) async fn sync(
printer,
preview,
)
.execute(lock_target)
.execute(lock_target),
)
.await
{
Ok(result) => Outcome::Success(result),

View File

@ -139,7 +139,8 @@ pub(crate) async fn tree(
let state = UniversalState::default();
// Update the lockfile, if necessary.
let lock = match LockOperation::new(
let lock = match Box::pin(
LockOperation::new(
mode,
&settings,
client_builder,
@ -151,7 +152,8 @@ pub(crate) async fn tree(
printer,
preview,
)
.execute(target)
.execute(target),
)
.await
{
Ok(result) => result.into_lock(),

View File

@ -450,7 +450,8 @@ async fn print_frozen_version(
let state = UniversalState::default();
// Lock and sync the environment, if necessary.
let lock = match project::lock::LockOperation::new(
let lock = match Box::pin(
project::lock::LockOperation::new(
LockMode::Frozen,
&settings.resolver,
&client_builder,
@ -462,7 +463,8 @@ async fn print_frozen_version(
printer,
preview,
)
.execute((&target).into())
.execute((&target).into()),
)
.await
{
Ok(result) => result.into_lock(),
@ -590,7 +592,8 @@ async fn lock_and_sync(
let workspace_cache = WorkspaceCache::default();
// Lock and sync the environment, if necessary.
let lock = match project::lock::LockOperation::new(
let lock = match Box::pin(
project::lock::LockOperation::new(
mode,
&settings.resolver,
&client_builder,
@ -602,7 +605,8 @@ async fn lock_and_sync(
printer,
preview,
)
.execute((&target).into())
.execute((&target).into()),
)
.await
{
Ok(result) => result.into_lock(),