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

better error messages while loading configuration extends #15658

Merged

Conversation

purajit
Copy link
Contributor

@purajit purajit commented Jan 21, 2025

Improves error messages during errors caused while extending a configuration using extend.

In the case of circular dependencies, it actually fixes the error too!

Old error messages:

# circular dependency - without even using pyproject.toml!
ruff failed
  Cause: Circular dependency detected in pyproject.toml

# file in "extends" doesn't exist
ruff failed
  Cause: Failed to read <path>/ruff4.toml
  Cause: No such file or directory (os error 2)

Now:

# circular dependency
ruff failed
  Cause: Circular dependency detected: <path>/ruff.toml -> <path>/ruff2.toml -> <path>/ruff3.toml -> <path>/ruff.toml

# circular dependency with a single file!
ruff failed
  Cause: Circular dependency detected: <path>/ruff.toml -> <path>/ruff.toml

# file in "extends" doesn't exist
ruff failed
  Cause: Failed to load last configuration in chain: <path>/ruff.toml -> <path>/ruff2.toml -> <path>/ruff3.toml -> <path>/ruff4.toml
  Cause: Failed to read <path>/ruff4.toml
  Cause: No such file or directory (os error 2)

Copy link
Contributor

github-actions bot commented Jan 21, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@purajit purajit force-pushed the 20250121-inheritance-failure-err-msg branch from b8c2fbe to 730bae4 Compare January 21, 2025 22:52
@purajit purajit marked this pull request as ready for review January 21, 2025 22:53
@MichaReiser MichaReiser added the cli Related to the command-line interface label Jan 22, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Nice, this is a great improvement. I've some suggestions on how we can improve the message further. It would probably also be good to add a CLI test for it, similar to what we have here

@purajit purajit force-pushed the 20250121-inheritance-failure-err-msg branch 3 times, most recently from 0531622 to 93d45b2 Compare February 16, 2025 09:33
@purajit purajit changed the title better error message when an inherited config path doesn't exist better error messages while loading configuration extends Feb 16, 2025
@MichaReiser MichaReiser force-pushed the 20250121-inheritance-failure-err-msg branch from 06beb84 to bc67b84 Compare February 17, 2025 09:27
@MichaReiser MichaReiser merged commit 9304fdf into astral-sh:main Feb 17, 2025
21 checks passed
dcreager added a commit that referenced this pull request Feb 18, 2025
* main: (60 commits)
  [`refurb`] Manual timezone monkeypatching (`FURB162`) (#16113)
  [`pyupgrade`] Do not upgrade functional TypedDicts with private field names to the class-based syntax (`UP013`) (#16219)
  Improve docs for PYI019 (#16229)
  Refactor `CallOutcome` to `Result` (#16161)
  Fix minor punctuation errors (#16228)
  Include document specific debug info (#16215)
  Update server to return the debug info as string (#16214)
  [`airflow`] Group `ImportPathMoved` and `ProviderName` to avoid misusing (`AIR303`) (#16157)
  Fix unstable formatting of trailing end-of-line comments of parenthesized attribute values (#16187)
  Ignore source code actions for a notebook cell (#16154)
  Add FAQ entry for `source.*` code actions in Notebook (#16212)
  red-knot: move symbol lookups in `symbol.rs` (#16152)
  better error messages while loading configuration `extend`s (#15658)
  Format `index.css` (#16207)
  Improve API exposed on `ExprStringLiteral` nodes (#16192)
  Update Rust crate tempfile to v3.17.0 (#16202)
  Update cloudflare/wrangler-action action to v3.14.0 (#16203)
  Update NPM Development dependencies (#16199)
  Update Rust crate smallvec to v1.14.0 (#16201)
  Update Rust crate codspeed-criterion-compat to v2.8.0 (#16200)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command-line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants