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

View File

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

View File

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

View File

@ -301,7 +301,8 @@ pub(crate) async fn remove(
let state = UniversalState::default(); let state = UniversalState::default();
// Lock and sync the environment, if necessary. // Lock and sync the environment, if necessary.
let lock = match project::lock::LockOperation::new( let lock = match Box::pin(
project::lock::LockOperation::new(
mode, mode,
&settings.resolver, &settings.resolver,
&client_builder, &client_builder,
@ -313,7 +314,8 @@ pub(crate) async fn remove(
printer, printer,
preview, preview,
) )
.execute((&target).into()) .execute((&target).into()),
)
.await .await
{ {
Ok(result) => result.into_lock(), 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. // Generate a lockfile.
let lock = match project::lock::LockOperation::new( let lock = match Box::pin(
project::lock::LockOperation::new(
mode, mode,
&settings.resolver, &settings.resolver,
&client_builder, &client_builder,
@ -287,7 +288,8 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
printer, printer,
preview, preview,
) )
.execute(target) .execute(target),
)
.await .await
{ {
Ok(result) => result.into_lock(), 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()) LockMode::Write(venv.interpreter())
}; };
let result = match project::lock::LockOperation::new( let result = match Box::pin(
project::lock::LockOperation::new(
mode, mode,
&settings.resolver, &settings.resolver,
&client_builder, &client_builder,
@ -764,7 +767,8 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
printer, printer,
preview, preview,
) )
.execute(project.workspace().into()) .execute(project.workspace().into()),
)
.await .await
{ {
Ok(result) => result, Ok(result) => result,

View File

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

View File

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

View File

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