Skip to content

Commit

Permalink
Fix typos & add pre-commit configuration (astral-sh#1487)
Browse files Browse the repository at this point in the history
Co-authored-by: Zanie Blue <[email protected]>
  • Loading branch information
akx and zanieb authored Feb 17, 2024
1 parent e4389e5 commit bc14ed1
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 13 deletions.
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
12 changes: 12 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions crates/pep440-rs/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PreRelease> {
match *self.inner {
Expand Down Expand Up @@ -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 <u8::MAX) is
/// "has dev-release." The dev-release value (constrained to be <u8::MAX) is
/// stored in byte 0 as-is.
///
/// The order of the encoding above is significant. For example, the
Expand Down
2 changes: 1 addition & 1 deletion crates/platform-tags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl Tags {
false
}

/// Returns the [`TagCompatiblity`] of the given tags.
/// Returns the [`TagCompatibility`] of the given tags.
///
/// If compatible, includes the score of the most-compatible platform tag.
/// If incompatible, includes the tag part which was a closest match.
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-client/src/flat_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl<'a> 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
}
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-client/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ mod tests {
<a href="https://storage.googleapis.com/jax-releases/cuda100/jaxlib-0.1.52+cuda100-cp36-none-manylinux2010_x86_64.whl">cuda100/jaxlib-0.1.52+cuda100-cp36-none-manylinux2010_x86_64.whl</a><br>
<a href="https://storage.googleapis.com/jax-releases/cuda100/jaxlib-0.1.52+cuda100-cp37-none-manylinux2010_x86_64.whl">cuda100/jaxlib-0.1.52+cuda100-cp37-none-manylinux2010_x86_64.whl</a><br>
</body>
</hmtl>
</html>
"#;
let base = Url::parse("https://storage.googleapis.com/jax-releases/jax_cuda_releases.html")
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-client/src/httpcache/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl FromIterator<CacheControlDirective> 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
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-client/src/httpcache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-client/src/registry_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions crates/uv/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/pip_install_scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit bc14ed1

Please sign in to comment.