Skip to content

fix: support implicit table syntax in pyproject.toml parsing#5580

Merged
baszalmstra merged 3 commits intoprefix-dev:mainfrom
suleman1412:fix/5577-toml-implicit-table-parsing
Mar 5, 2026
Merged

fix: support implicit table syntax in pyproject.toml parsing#5580
baszalmstra merged 3 commits intoprefix-dev:mainfrom
suleman1412:fix/5577-toml-implicit-table-parsing

Conversation

@suleman1412
Copy link
Contributor

@suleman1412 suleman1412 commented Feb 28, 2026

Description

Allow pixi to recognize TOML implicit table syntax like:
[tool.pixi]
workspace.channels = ["conda-forge"]

Previously only explicit syntax was supported:
[tool.pixi.workspace]
channels = ["conda-forge"]

Both are valid TOML and should be treated equally.

Fixes #5577

How Has This Been Tested?

  • Added a new test case in discovery.rs with test data at tests/data/workspace-discovery/implicit-tables-pyproject/pyproject.toml
  • Ran cargo test -p pixi_manifest - all 279 tests passed including the new test case

AI Disclosure

  • This PR contains AI-generated content.
  • I have tested any AI-generated content in my PR.
  • I take responsibility for any AI-generated content in my PR.
    Tools: Claude

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

@suleman1412
Copy link
Contributor Author

@baszalmstra this fixes #5577, please have a look at it and let me know what you think.

Copilot AI review requested due to automatic review settings March 4, 2026 20:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates pixi’s workspace discovery logic so pyproject.toml manifests using TOML implicit-table (dotted key) syntax under [tool.pixi] are treated equivalently to explicit table syntax, fixing workspace discovery failures reported in #5577.

Changes:

  • Adjusted the “required sections” pre-check for pyproject.toml to recognize dotted keys like workspace.channels = ....
  • Added a new workspace-discovery fixture using implicit table syntax.
  • Added/recorded a new insta snapshot for the implicit-table discovery case.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/pixi_manifest/src/discovery.rs Updates the cheap pre-parse check to treat implicit-table syntax as satisfying required pixi sections; adds a new explicit discovery test case.
tests/data/workspace-discovery/implicit-tables-pyproject/pyproject.toml New fixture demonstrating [tool.pixi] + dotted workspace.* keys.
crates/pixi_manifest/src/snapshots/pixi_manifest__discovery__test__explicit_workspace_discoverer@implicit-tables-pyproject_pyproject.toml.snap New snapshot asserting discovery succeeds for the implicit-table fixture.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +338 to +339
source.contains(&format!("[tool.pixi.{section}]"))
|| source.contains(&format!("{section}."))
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The new implicit-table detection uses source.contains("{section}."), which is an unscoped substring match and can produce false positives (e.g. myworkspace.channels = ..., a comment/string containing workspace., or workspace.* keys outside [tool.pixi]). That would suppress the intended NoPixiTable diagnostic for explicit discovery. Consider tightening this to only match keys within the [tool.pixi] table and at the start of a key (e.g. line-based trim_start().starts_with("{section}.") within the [tool.pixi] table block), or preferably base the check on the already-parsed toml_span document (e.g. pointers under /tool/pixi/{section}) instead of raw string search.

Suggested change
source.contains(&format!("[tool.pixi.{section}]"))
|| source.contains(&format!("{section}."))
// Explicit table: [tool.pixi.{section}]
source.contains(&format!("[tool.pixi.{section}]"))
// Implicit table: keys like `{section}.something` inside `[tool.pixi]`
|| {
let mut in_pixi_table = false;
source.lines().any(|line| {
let trimmed = line.trim_start();
if trimmed.starts_with('[') {
// Enter the top-level [tool.pixi] table; any other
// table (including [tool.pixi.*]) ends it.
if trimmed.starts_with("[tool.pixi]") {
in_pixi_table = true;
} else {
in_pixi_table = false;
}
return false;
}
in_pixi_table
&& trimmed.starts_with(&format!("{section}."))
})
}

Copilot uses AI. Check for mistakes.
@baszalmstra baszalmstra merged commit f568374 into prefix-dev:main Mar 5, 2026
41 of 42 checks passed
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.

TOML parsing issue

3 participants