mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 21:02:37 +00:00
Add an experimental uv format command (#15017)
As a frontend to Ruff's formatter. There are some interesting choices here, some of which may just be temporary: 1. We pin a default version of Ruff, so `uv format` is stable for a given uv version 2. We install Ruff from GitHub instead of PyPI, which means we don't need a Python interpreter or environment 3. We do not read the Ruff version from the dependency tree See https://github.com/astral-sh/ruff/pull/19665 for a prototype of the LSP integration.
This commit is contained in:
parent
8d6ea3f2ea
commit
e31f000da7
22 changed files with 1110 additions and 5 deletions
|
|
@ -17,6 +17,7 @@ bitflags::bitflags! {
|
|||
const PACKAGE_CONFLICTS = 1 << 5;
|
||||
const EXTRA_BUILD_DEPENDENCIES = 1 << 6;
|
||||
const DETECT_MODULE_CONFLICTS = 1 << 7;
|
||||
const FORMAT = 1 << 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ impl PreviewFeatures {
|
|||
Self::PACKAGE_CONFLICTS => "package-conflicts",
|
||||
Self::EXTRA_BUILD_DEPENDENCIES => "extra-build-dependencies",
|
||||
Self::DETECT_MODULE_CONFLICTS => "detect-module-conflicts",
|
||||
Self::FORMAT => "format",
|
||||
_ => panic!("`flag_as_str` can only be used for exactly one feature flag"),
|
||||
}
|
||||
}
|
||||
|
|
@ -79,6 +81,7 @@ impl FromStr for PreviewFeatures {
|
|||
"package-conflicts" => Self::PACKAGE_CONFLICTS,
|
||||
"extra-build-dependencies" => Self::EXTRA_BUILD_DEPENDENCIES,
|
||||
"detect-module-conflicts" => Self::DETECT_MODULE_CONFLICTS,
|
||||
"format" => Self::FORMAT,
|
||||
_ => {
|
||||
warn_user_once!("Unknown preview feature: `{part}`");
|
||||
continue;
|
||||
|
|
@ -253,6 +256,7 @@ mod tests {
|
|||
PreviewFeatures::DETECT_MODULE_CONFLICTS.flag_as_str(),
|
||||
"detect-module-conflicts"
|
||||
);
|
||||
assert_eq!(PreviewFeatures::FORMAT.flag_as_str(), "format");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue