Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove flatten to improve deserialization error messages #7598

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Sep 20, 2024

Summary

#[serde(flatten)] has a disastrous effect on error messages: serde no longer tells you which field errored, nor does it show it to you in the diagnostic output.

Before:

warning: Failed to parse `pyproject.toml` during settings discovery:
  TOML parse error at line 9, column 1
    |
  9 | [tool.uv]
    | ^^^^^^^^^
  invalid type: string "foo", expected a sequence

After:

warning: Failed to parse `pyproject.toml` during settings discovery:
  TOML parse error at line 10, column 19
     |
  10 | extra-index-url = "foo"
     |                   ^^^^^
  invalid type: string "foo", expected a sequence

Closes #7113.

@charliermarsh charliermarsh added the error messages Messaging when something goes wrong label Sep 20, 2024
@zanieb
Copy link
Member

zanieb commented Sep 20, 2024

Wow...

@@ -33,13 +33,15 @@ pub(crate) struct Tools {
/// A `[tool.uv]` section.
#[allow(dead_code)]
#[derive(Debug, Clone, Default, Deserialize, CombineOptions, OptionsMetadata)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
#[serde(from = "OptionsWire", rename_all = "kebab-case")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct Options {
#[serde(flatten)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left these here because schemars uses them for the JSON schema.

#[derive(Debug, Clone, Default, Deserialize)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
pub struct OptionsWire {
// #[serde(flatten)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be commented?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to indicate where the various sections start and end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's sort of confusing, but okay.

@charliermarsh charliermarsh merged commit 86ff740 into main Sep 20, 2024
58 checks passed
@charliermarsh charliermarsh deleted the charlie/flat branch September 20, 2024 18:54
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Sep 23, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.4.13` -> `0.4.15` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.4.15`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0415)

[Compare Source](astral-sh/uv@0.4.14...0.4.15)

##### Bug fixes

-   Revert "Treat invalid platform as more compatible than invalid Python ([#&#8203;7556](astral-sh/uv#7556))" ([#&#8203;7608](astral-sh/uv#7608))

##### Documentation

-   Add the execution policy to powershell installs for single versions ([#&#8203;7602](astral-sh/uv#7602))

### [`v0.4.14`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0414)

[Compare Source](astral-sh/uv@0.4.13...0.4.14)

##### Breaking

-   Move uvx shell completion to `uvx --generate-shell-completion` ([#&#8203;7511](astral-sh/uv#7511))

##### Enhancements

-   Adjust messaging for frozen hint on resolution failure during `uv add` ([#&#8203;7597](astral-sh/uv#7597))
-   Provide resolution hints in case of possible local name conflicts ([#&#8203;7505](astral-sh/uv#7505))
-   Improve Docker image release tagging order and display on `ghcr.io` ([#&#8203;7568](astral-sh/uv#7568))
-   Improve deserialization error messages ([#&#8203;7598](astral-sh/uv#7598))

##### Bug fixes

-   Allow system environments during project environment validity check ([#&#8203;7585](astral-sh/uv#7585))
-   Avoid validating workspace members when `--no-sources` is provided ([#&#8203;7599](astral-sh/uv#7599))
-   Fix handling of `sys.base_prefix` collision in interpreter identity check during tool installs ([#&#8203;7596](astral-sh/uv#7596))
-   Make `uv cache prune` robust to unreadable rkyv entries ([#&#8203;7561](astral-sh/uv#7561))
-   Revert "Remove duplicate warning for settings discovery errors ([#&#8203;7384](astral-sh/uv#7384))" ([#&#8203;7594](astral-sh/uv#7594))

##### Documentation

-   Fix `-` to `_` in packaged applications document ([#&#8203;7571](astral-sh/uv#7571))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong
Projects
None yet
Development

Successfully merging this pull request may close these issues.

absent directory in find-links causes TOML parse errors: "relative URL without a base"
2 participants