Skip to content

improve pyproject.toml validation error messages by replacing data with tool.poetry #10471

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

Merged

Conversation

Aearsears
Copy link
Contributor

@Aearsears Aearsears commented Jul 24, 2025

Pull Request Check List

Resolves: #9900

Replaces the data prefix in the validation error messages with tool.poetry to better report toml structure errors

  • Added tests for changed code.
  • Updated documentation for changed code.

Summary by Sourcery

Replace 'data.' prefix in pyproject.toml validation error messages with 'tool.poetry.' and adjust tests accordingly

Enhancements:

  • Prefix validation error paths with 'tool.poetry.' instead of 'data.' in pyproject.toml errors

Tests:

  • Update test_validate_fails to expect the new 'tool.poetry.' error messages and flattened error list

Summary by Sourcery

Replace the "data." prefix in pyproject.toml validation error messages with "tool.poetry." and adjust tests accordingly

Enhancements:

  • Prefix TOML validation error paths with "tool.poetry." instead of "data."

Tests:

  • Update tests to expect the new "tool.poetry." error messages and flatter error list structure

Copy link

sourcery-ai bot commented Jul 24, 2025

Reviewer's Guide

This PR updates the validation logic to prefix error paths with 'tool.poetry.' instead of 'data.' and adjusts existing tests to expect the new message format.

Class diagram for updated validation error message handling

classDiagram
    class Factory {
        +validate(toml_data, strict)
    }
    Factory : validate() now replaces 'data.' with 'tool.poetry.' in error messages
Loading

File-Level Changes

Change Details Files
Replace 'data.' prefix with 'tool.poetry.' in validation errors
  • wrap validate_object results in a list comprehension
  • apply .replace("data.", "tool.poetry.") to each error message
src/poetry/factory.py
Adapt test_validate_fails to new error format
  • convert expected errors from a tuple to a flat list
  • update assertion to compare the flat 'errors' list directly
tests/test_factory.py
Update schema-based tests to use 'tool.poetry.' prefix
  • replace 'data.' prefix with 'tool.poetry.' in expected error strings
tests/json/test_schema.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Aearsears Aearsears marked this pull request as ready for review July 24, 2025 22:09
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Aearsears - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@radoering radoering changed the title feature: replace data by tool.poetry in pyproject.toml validation error messages improve pyproject.toml validation error messages by replacing data with tool.poetry Jul 27, 2025
@radoering radoering merged commit b580e8a into python-poetry:main Jul 27, 2025
53 checks passed
radoering pushed a commit that referenced this pull request Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request for clearer error message parsing pyproject.toml
2 participants