diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..a6714a287 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,39 @@ +fail_fast: true + +exclude: | + (?x)^( + .*/(snapshots)/.*| + )$ + +repos: + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.16 + hooks: + - id: validate-pyproject + + - repo: https://github.com/crate-ci/typos + rev: v1.18.2 + hooks: + - id: typos + + - repo: local + hooks: + - id: cargo-fmt + name: cargo fmt + entry: cargo fmt -- + language: system + types: [rust] + pass_filenames: false # This makes it a lot faster + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + types: [yaml] + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.1 + hooks: + - id: ruff-format + - id: ruff + args: [--fix, --exit-non-zero-on-fix] \ No newline at end of file diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 000000000..635ccbbe9 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,12 @@ +[files] +extend-exclude = [ + "**/resources/**/*", + "**/snapshots/**/*", + "scripts/**/*.in", +] + +[default.extend-words] +BA = "BA" # acronym for "Bad Allowed", used in testing. +Nd = "Nd" # secret codeword used by friendly bards +borken = "borken" # the word is borken :( +seeked = "seeked" # special term used for streams diff --git a/crates/pep440-rs/src/version.rs b/crates/pep440-rs/src/version.rs index a3255cd30..480eeaed7 100644 --- a/crates/pep440-rs/src/version.rs +++ b/crates/pep440-rs/src/version.rs @@ -349,7 +349,7 @@ impl Version { } } - /// Returns the pre-relase part of this version, if it exists. + /// Returns the pre-release part of this version, if it exists. #[inline] pub fn pre(&self) -> Option { match *self.inner { @@ -755,7 +755,7 @@ impl FromStr for Version { /// pre-release numeric value. /// * Byte 0 corresponds to the dev-release segment. If there is no dev-release /// segment, then byte 0 is set to 0xFF. This makes "no dev-release" sort after -/// "has dev-release." The dev-release value (constrainted to be FlatIndexClient<'a> { match File::try_from(file, base.as_url().as_str()) { Ok(file) => Some(file), Err(err) => { - // Ignore files with unparseable version specifiers. + // Ignore files with unparsable version specifiers. warn!("Skipping file in {url}: {err}"); None } diff --git a/crates/uv-client/src/html.rs b/crates/uv-client/src/html.rs index d641b01c9..0dc9c07b9 100644 --- a/crates/uv-client/src/html.rs +++ b/crates/uv-client/src/html.rs @@ -685,7 +685,7 @@ mod tests { cuda100/jaxlib-0.1.52+cuda100-cp36-none-manylinux2010_x86_64.whl
cuda100/jaxlib-0.1.52+cuda100-cp37-none-manylinux2010_x86_64.whl
- + "#; let base = Url::parse("https://storage.googleapis.com/jax-releases/jax_cuda_releases.html") .unwrap(); diff --git a/crates/uv-client/src/httpcache/control.rs b/crates/uv-client/src/httpcache/control.rs index 43b032dde..c50856179 100644 --- a/crates/uv-client/src/httpcache/control.rs +++ b/crates/uv-client/src/httpcache/control.rs @@ -146,7 +146,7 @@ impl FromIterator for CacheControl { /// The parser is mostly defined across multiple parts of multiple RFCs. /// Namely, [RFC 9110 S5.6.2] says how to parse the names (or "keys") of each /// directive (whose format is a "token"). [RFC 9110 S5.6.4] says how to parse -/// quoted values. And finally, [RFC 9111 Appendex A] gives the ABNF for the +/// quoted values. And finally, [RFC 9111 Appendix A] gives the ABNF for the /// overall header value. /// /// This parser accepts an iterator of anything that can be cheaply converted diff --git a/crates/uv-client/src/httpcache/mod.rs b/crates/uv-client/src/httpcache/mod.rs index 65dcc02ce..90fc86738 100644 --- a/crates/uv-client/src/httpcache/mod.rs +++ b/crates/uv-client/src/httpcache/mod.rs @@ -21,7 +21,7 @@ think we can do a quick overview here. Let's start with the obvious. HTTP caching exists to avoid network requests, and, if a request is unavoidable, bandwidth. The central actor in HTTP caching is the `Cache-Control` header, which can exist on *both* requests and -resonses. The value of this header is a list of directives that control caching +responses. The value of this header is a list of directives that control caching behavior. They can outright disable it (`no-store`), force cache invalidation (`no-cache`) or even permit the cache to return responses that are explicitly stale (`max-stale`). diff --git a/crates/uv-client/src/registry_client.rs b/crates/uv-client/src/registry_client.rs index 68318a68f..514e7ea77 100644 --- a/crates/uv-client/src/registry_client.rs +++ b/crates/uv-client/src/registry_client.rs @@ -625,7 +625,7 @@ impl SimpleMetadata { let file = match File::try_from(file, base) { Ok(file) => file, Err(err) => { - // Ignore files with unparseable version specifiers. + // Ignore files with unparsable version specifiers. warn!("Skipping file for {package_name}: {err}"); continue; } diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index ea153fdc3..596a0e5e7 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -686,7 +686,7 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { let dist = match candidate.dist() { CandidateDist::Compatible(dist) => dist, CandidateDist::ExcludeNewer => { - // If the version is incomatible because of `exclude_newer`, pretend the versions do not exist + // If the version is incompatible because of `exclude_newer`, pretend the versions do not exist return Ok(None); } CandidateDist::Incompatible(incompatibility) => { diff --git a/crates/uv/src/logging.rs b/crates/uv/src/logging.rs index 6c8316610..51ab11115 100644 --- a/crates/uv/src/logging.rs +++ b/crates/uv/src/logging.rs @@ -11,10 +11,10 @@ use tracing_tree::HierarchicalLayer; #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] pub(crate) enum Level { - /// Suppress all tracing output by default (overrideable by `RUST_LOG`). + /// Suppress all tracing output by default (overridable by `RUST_LOG`). #[default] Default, - /// Show debug messages by default (overrideable by `RUST_LOG`). + /// Show debug messages by default (overridable by `RUST_LOG`). Verbose, } diff --git a/crates/uv/tests/pip_install_scenarios.rs b/crates/uv/tests/pip_install_scenarios.rs index f15cf804a..38ef94193 100644 --- a/crates/uv/tests/pip_install_scenarios.rs +++ b/crates/uv/tests/pip_install_scenarios.rs @@ -477,7 +477,7 @@ fn dependency_excludes_range_of_compatible_versions() { /// There is a non-contiguous range of compatible versions for the requested package /// `a`, but another dependency `c` excludes the range. This is the same as /// `dependency-excludes-range-of-compatible-versions` but some of the versions of -/// `a` are incompatible for another reason e.g. dependency on non-existant package +/// `a` are incompatible for another reason e.g. dependency on non-existent package /// `d`. /// /// ```text diff --git a/ruff.toml b/ruff.toml index 85398f3ad..1b85a1c8f 100644 --- a/ruff.toml +++ b/ruff.toml @@ -2,5 +2,5 @@ exclude = [ "crates/gourgeist/src/activator/activate_this.py", "crates/gourgeist/src/_virtualenv.py" ] -[per-file-ignores] +[lint.per-file-ignores] "__init__.py" = ["F403", "F405"]