Repository: astral-sh/uv
File: crates/uv/src/commands/publish.rs (Rust)

Code before:
        let size = fs_err::metadata(&group.file)?.len();
        let (bytes, unit) = human_readable_bytes(size);
        if dry_run {
            writeln!(
                printer.stderr(),
                "{} {} {}",
                "Checking".bold().cyan(),
                group.filename,
                format!("({bytes:.1}{unit})").dimmed()
            )?;
        } else {
            writeln!(
                printer.stderr(),
                "{} {} {}",
                "Uploading".bold().green(),
                group.filename,
                format!("({bytes:.1}{unit})").dimmed()
            )?;
        }

        // Collect the metadata for the file.
        let form_metadata = match FormMetadata::read_from_file(&group.file, &group.filename).await {
            Ok(metadata) => metadata,
            Err(err) => {
                let err: anyhow::Error =
                    PublishError::PublishPrepare(group.file.clone(), Box::new(err)).into();
                if dry_run {
                    write_error_chain(err.as_ref(), printer.stderr(), "error", AnsiColors::Red)?;
                    error_count += 1;
                    continue;
                }
                return Err(err);
            }
        };

        let uploaded = if direct {
            if dry_run {
                // For dry run, call validate since we won't call reserve.
                match uv_publish::validate(
                    &group.file,
                    &form_metadata,
                    &group.raw_filename,
                    &publish_url,
                    &token_store,
                    &upload_client,
                    &credentials,
                )
                .await
                {
                    Ok(should_upload) => {
                        if !should_upload {

Review comment (suggestion):
I don't see why we took this out of the `map_err`, I guess it's consistent with the later case? I don't feel strongly about it.

Code after:
            writeln!(
                printer.stderr(),
                "{} {} {}",
                "Checking".bold().cyan(),
                group.filename,
                format!("({bytes:.1}{unit})").dimmed()
            )?;
        } else {
            writeln!(
                printer.stderr(),
                "{} {} {}",
                "Uploading".bold().green(),
                group.filename,
                format!("({bytes:.1}{unit})").dimmed()
            )?;
        }

        // Collect the metadata for the file.
        let form_metadata = match FormMetadata::read_from_file(&group.file, &group.filename)
            .await
            .map_err(|err| PublishError::PublishPrepare(group.file.clone(), Box::new(err)))
        {
            Ok(metadata) => metadata,
            Err(err) => {
                if dry_run {
                    write_error_chain(&err, printer.stderr(), "error", AnsiColors::Red)?;
                    error_count += 1;
                    continue;
                }
                return Err(err.into());
            }
        };

        let uploaded = if direct {
            if dry_run {
                // For dry run, call validate since we won't call reserve.
                match uv_publish::validate(
                    &group.file,
                    &form_metadata,
                    &group.raw_filename,
                    &publish_url,
                    &token_store,
                    &upload_client,
                    &credentials,
                )
                .await
                {
                    Ok(should_upload) => {
                        if !should_upload {
                            writeln!(
                                printer.stderr(),