Repository: astral-sh/uv
File: crates/uv-resolver/src/lock/mod.rs (Rust)

Code before:
                    writeln!(
                        f,
                        "{}{} You're on {}, but {} only has wheels for the following platform{s}: {}; consider adding your platform to `{}` to ensure uv resolves to a version with compatible wheels",
                        "hint".bold().cyan(),
                        ":".bold(),
                        best,
                        package_ref,
                        tags.iter()
                            .map(|tag| format!("`{}`", tag.cyan()))
                            .join(", "),
                        "tool.uv.required-environments".green()
                    )?;
                    writeln!(
                        f,
                        "{}",
                        "For example, add this to your pyproject.toml:".dimmed()
                    )?;
                    writeln!(f, "    {}", "[tool.uv]".dimmed())?;
                    writeln!(f, "    {} = [", "required-environments".green())?;
                    writeln!(
                        f,
                        "        \"{}\",  {}",
                        example_marker.cyan().dimmed(),
                        "# Adjust the platform/architecture as needed".dimmed()
                    )?;
                    writeln!(f, "    {}", "]".dimmed())
                } else {
                    if let Some(version) = version {
                        write!(
                            f,
                            "{}{} Wheels are available for `{}` ({}) on the following platform{s}: {}",
                            "hint".bold().cyan(),
                            ":".bold(),
                            package.cyan(),
                            format!("v{version}").cyan(),
                            tags.iter()
                                .map(|tag| format!("`{}`", tag.cyan()))
                                .join(", "),
                        )
                    } else {
                        write!(
                            f,
                            "{}{} Wheels are available for `{}` on the following platform{s}: {}",
                            "hint".bold().cyan(),
                            ":".bold(),
                            package.cyan(),
                            tags.iter()
                                .map(|tag| format!("`{}`", tag.cyan()))
                                .join(", "),
                        )
                    }

Review comment (suggestion):
Showing multiline code blocks in the terminal is hard, and we currently don't have a good general diagnostic system (like showing diffs for sections we want to change). For example, with the current layout, you'd get extra indentation when copying, while triple backticks look out-of-place in terminal output, etc. What about rolling this into a single line to avoid the formatting question?
> consider adding `"sys_platform == '[PLATFORM]' and platform_machine == '[MACHINE]'"` to `tool.uv.required-environments` to ensure uv resolves to a version with compatible wheels`

Code after:
                    write!(
                        f,
                        "{}{} You're on {}, but {} only has wheels for the following platform{s}: {}; consider adding {} to `{}` to ensure uv resolves to a version with compatible wheels",
                        "hint".bold().cyan(),
                        ":".bold(),
                        best,
                        package_ref,
                        tags.iter()
                            .map(|tag| format!("`{}`", tag.cyan()))
                            .join(", "),
                        format!("\"{example_marker}\"").cyan(),
                        "tool.uv.required-environments".green()
                    )
                } else {
                    if let Some(version) = version {
                        write!(
                            f,
                            "{}{} Wheels are available for `{}` ({}) on the following platform{s}: {}",
                            "hint".bold().cyan(),
                            ":".bold(),
                            package.cyan(),
                            format!("v{version}").cyan(),
                            tags.iter()
                                .map(|tag| format!("`{}`", tag.cyan()))
                                .join(", "),
                        )
                    } else {
                        write!(
                            f,
                            "{}{} Wheels are available for `{}` on the following platform{s}: {}",
                            "hint".bold().cyan(),
                            ":".bold(),
                            package.cyan(),
                            tags.iter()
                                .map(|tag| format!("`{}`", tag.cyan()))
                                .join(", "),
                        )
                    }
                }
            }
        }
    }
}

/// An error that occurs when generating a `Lock` data structure.
///
/// These errors are sometimes the result of possible programming bugs.
/// For example, if there are two or more duplicative distributions given
/// to `Lock::new`, then an error is returned. It's likely that the fault
/// is with the caller somewhere in such cases.
#[derive(Debug, thiserror::Error)]