Skip to content

Commit

Permalink
Cleanup usage of unwrap() in re_dev_tools (rerun-io#6337)
Browse files Browse the repository at this point in the history
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

Part of rerun-io#6330
Removes or explicitly allows unwrap() where it makes sense.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6337?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6337?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6337)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.

---------

Co-authored-by: Andreas Reich <[email protected]>
Co-authored-by: Andreas Reich <[email protected]>
  • Loading branch information
3 people authored May 17, 2024
1 parent c68ea30 commit 3ecef5a
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 11 deletions.
7 changes: 3 additions & 4 deletions crates/re_dev_tools/src/build_examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,9 @@ impl Frontmatter {

let frontmatter: Frontmatter =
toml::from_str(content[start..end].trim()).map_err(|err| {
anyhow::anyhow!(
"Failed to parse TOML metadata of {:?}: {err}",
path.parent().unwrap().file_name().unwrap()
)
#[allow(clippy::unwrap_used)]
let p = path.parent().unwrap().file_name().unwrap();
anyhow::anyhow!("Failed to parse TOML metadata of {p:?}: {err}")
})?;

Ok(Some((
Expand Down
1 change: 1 addition & 0 deletions crates/re_dev_tools/src/build_examples/snippets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fn collect_snippets_recursively(
) -> anyhow::Result<Vec<Snippet>> {
let mut snippets = vec![];

#[allow(clippy::unwrap_used)] // we just use unwrap for string <-> path conversion here
for snippet in dir.read_dir()? {
let snippet = snippet?;
let meta = snippet.metadata()?;
Expand Down
2 changes: 2 additions & 0 deletions crates/re_dev_tools/src/build_search_index/ingest.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used)] // build tool, so okay here

/// Docs read from `/docs`
mod docs;

Expand Down
2 changes: 2 additions & 0 deletions crates/re_dev_tools/src/build_search_index/ingest/cpp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used)] // build tool, so okay here

use super::Context;
use super::DocumentData;
use super::DocumentKind;
Expand Down
2 changes: 2 additions & 0 deletions crates/re_dev_tools/src/build_search_index/ingest/docs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used)] // build tool, so okay here

use super::{Context, DocumentData, DocumentKind};
use crate::build_search_index::util::ProgressBarExt as _;
use std::path::Path;
Expand Down
2 changes: 2 additions & 0 deletions crates/re_dev_tools/src/build_search_index/ingest/rust.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used)] // build tool, so okay here

use super::{Context, DocumentData, DocumentKind};
use crate::build_search_index::util::ProgressBarExt as _;
use anyhow::Context as _;
Expand Down
4 changes: 3 additions & 1 deletion crates/re_dev_tools/src/build_search_index/meili.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ impl Task {
TaskStatus::Succeeded => Ok(ControlFlow::Break(())),

TaskStatus::Failed => {
anyhow::bail!("task failed: {}", self.error.as_ref().unwrap().message)
#[allow(clippy::unwrap_used)]
let msg = self.error.as_ref().unwrap().message.as_str();
anyhow::bail!("task failed: {}", msg)
}
TaskStatus::Canceled => anyhow::bail!("task was canceled"),
}
Expand Down
4 changes: 2 additions & 2 deletions crates/re_dev_tools/src/build_search_index/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ impl Repl {

let mut lines = stdin().lines();
loop {
stdout().write_all(b"\n> ").unwrap();
stdout().flush().unwrap();
stdout().write_all(b"\n> ")?;
stdout().flush()?;

match lines.next().transpose()? {
Some(line) => match self.handle_line(&client, &line)? {
Expand Down
4 changes: 0 additions & 4 deletions crates/re_dev_tools/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
//! Crate that combines several development utilities.
//!
//! To get an overview over all tools run `pixi run dev-tools --help`.
// TODO(#3408): remove unwrap()
#![allow(clippy::unwrap_used)]

use argh::FromArgs;

mod build_examples;
Expand Down

0 comments on commit 3ecef5a

Please sign in to comment.