Skip to content

Commit

Permalink
fix: clippy and resolvo
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Sep 25, 2023
1 parent 28e4fcf commit 0493b2d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 42 deletions.
27 changes: 14 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/rattler_installs_packages/src/package_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
artifact_name::InnerAsArtifactName,
html,
http::{CacheMode, Http},
package_name::PackageName,
project_info::{ArtifactInfo, ProjectInfo},
FileStore, NormalizedPackageName,
};
Expand Down
4 changes: 2 additions & 2 deletions crates/rip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ indicatif = "0.17.6"
itertools = "0.11.0"
miette = { version = "5.10.0", features = ["fancy"] }
rattler_installs_packages = { path = "../rattler_installs_packages" }
rattler_libsolv_rs = { git = "https://github.com/baszalmstra/rattler", branch = "refactor/lazy_solver" }
resolvo = "0.1.0"
reqwest = "0.11.19"
tabwriter = { version = "1.2.1", features = ["ansi_formatting"] }
tokio = { version = "1.29.1", features = ["rt", "macros", "rt-multi-thread"] }
Expand All @@ -31,4 +31,4 @@ rand = "0.8.4"
serde = "1.0.188"
serde_with = "3.0.0"
serde_json = "1.0.107"
rusqlite = { version = "0.29.0", features = ["bundled"] }
rusqlite = { version = "0.29.0", features = ["bundled"] }
20 changes: 11 additions & 9 deletions crates/rip/src/bin/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::util::SubscriberInitExt;
use url::Url;

use rattler_installs_packages::{Extra, NormalizedPackageName, PackageName, PackageRequirement, Wheel};
use rattler_installs_packages::{Extra, PackageName, PackageRequirement, Wheel};
use rip::writer::{global_multi_progress, IndicatifWriter};

#[derive(Parser)]
Expand Down Expand Up @@ -74,8 +74,10 @@ pub async fn index(index_url: Url) -> Result<(), miette::Error> {
for n in names {
bar.inc(1);
let package_name = PackageName::from_str(&n)?;
let mut artifacts_per_version =
package_db.available_artifacts(package_name.clone()).await?.clone();
let mut artifacts_per_version = package_db
.available_artifacts(package_name.clone())
.await?
.clone();
artifacts_per_version.sort_keys();

let (chosen_version, available_artifacts) =
Expand All @@ -86,7 +88,7 @@ pub async fn index(index_url: Url) -> Result<(), miette::Error> {
};

let mut rows = request
.query(&[package_name.as_str(), chosen_version.to_string().as_str()])
.query([package_name.as_str(), chosen_version.to_string().as_str()])
.into_diagnostic()?;
if rows.next().into_diagnostic()?.is_some() {
// Skip if we have it in the database
Expand All @@ -102,7 +104,7 @@ pub async fn index(index_url: Url) -> Result<(), miette::Error> {
.filter(|a| !a.yanked.yanked)
.collect::<Vec<_>>();

if available_artifacts.len() == 0 {
if available_artifacts.is_empty() {
continue;
}

Expand All @@ -119,16 +121,16 @@ pub async fn index(index_url: Url) -> Result<(), miette::Error> {
};

insert_stmt
.insert(&[
.insert([
package_name.as_str(),
chosen_version.to_string().as_str(),
serde_json::to_string(&metadata.requires_dist)
.into_diagnostic()?
.as_str(),
&serde_json::to_string(&metadata.requires_python)
serde_json::to_string(&metadata.requires_python)
.into_diagnostic()?
.as_str(),
&serde_json::to_string(&metadata.extras)
serde_json::to_string(&metadata.extras)
.into_diagnostic()?
.as_str(),
])
Expand Down Expand Up @@ -181,7 +183,7 @@ pub fn query_extras() -> Result<(), miette::Error> {
.into_diagnostic()?;
total += requires_dist.len();
for req in requires_dist {
if req.extras.len() > 0 {
if !req.extras.is_empty() {
println!(
"{}: {}",
req.name.as_str(),
Expand Down
26 changes: 11 additions & 15 deletions crates/rip/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
use std::fmt::{Debug, Display};
use std::io::Write;

use clap::Parser;
use miette::IntoDiagnostic;
use rattler_libsolv_rs::{DefaultSolvableDisplay, DependencyProvider, Solver, VersionSet};
use tracing::Level;
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::util::SubscriberInitExt;
use resolvo::{DefaultSolvableDisplay, DependencyProvider, Solver};
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
use url::Url;

use rattler_installs_packages::requirement::Requirement;
use rattler_installs_packages::{NormalizedPackageName, PackageRequirement};
use rip::pypi_provider::{PypiDependencyProvider, PypiPackageName};
use rip::writer::{global_multi_progress, IndicatifWriter};
use rattler_installs_packages::{requirement::Requirement, PackageRequirement};
use rip::{
pypi_provider::{PypiDependencyProvider, PypiPackageName},
writer::{global_multi_progress, IndicatifWriter},
};

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
Expand All @@ -30,11 +28,9 @@ async fn actual_main() -> miette::Result<()> {
let args = Args::parse();

// Setup tracing subscriber
tracing_subscriber::fmt()
.with_max_level(Level::INFO)
.with_span_events(FmtSpan::ENTER)
.with_writer(IndicatifWriter::new(global_multi_progress()))
.finish()
tracing_subscriber::registry()
.with(fmt::layer().with_writer(IndicatifWriter::new(global_multi_progress())))
.with(EnvFilter::from_default_env())
.init();

// Determine cache directory
Expand All @@ -47,7 +43,7 @@ async fn actual_main() -> miette::Result<()> {
let package_db = rattler_installs_packages::PackageDb::new(
Default::default(),
&[normalize_index_url(args.index_url)],
cache_dir.clone(),
cache_dir,
)
.into_diagnostic()?;

Expand Down
3 changes: 1 addition & 2 deletions crates/rip/src/pypi_provider.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use clap::builder::Str;
use rattler_installs_packages::requirement::Requirement;
use rattler_installs_packages::{
CompareOp, Extra, NormalizedPackageName, PackageDb, Specifier, Specifiers, Version, Wheel,
};
use rattler_libsolv_rs::{
use resolvo::{
Candidates, Dependencies, DependencyProvider, NameId, Pool, SolvableId, SolverCache, VersionSet,
};
use std::collections::HashMap;
Expand Down

0 comments on commit 0493b2d

Please sign in to comment.