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

TOML parse error: Invalid table header: Duplicate key version #1894

Closed
hugovk opened this issue Jan 15, 2023 · 6 comments · Fixed by #2040, #2058 or #2116
Closed

TOML parse error: Invalid table header: Duplicate key version #1894

hugovk opened this issue Jan 15, 2023 · 6 comments · Fixed by #2040, #2058 or #2116

Comments

@hugovk
Copy link
Contributor

hugovk commented Jan 15, 2023

Run ruff . with this pyproject.toml in an empty directory:

# pyproject.toml

[tool.hatch]
version.source = "vcs"

[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

Outputs error only without --isolated in newest 0.0.222:

$ ruff --version
ruff 0.0.222
$  ruff .
error TOML parse error at line 6, column 1
  |
6 | [tool.hatch.version.raw-options]
  | ^
Invalid table header
Duplicate key `version`

$ ruff . --isolated
warning: No Python files found under the given path(s)

This file is parsed fine by other tools, such as Hatchling, python-build, Black, isort etc. Fuller version at https://github.com/hugovk/norwegianblue/

Error both with and without --isolated in 0.0.219:

$ ruff --version
ruff 0.0.219
$ ruff .
error TOML parse error at line 6, column 1
  |
6 | [tool.hatch.version.raw-options]
  | ^
Invalid table header
Duplicate key `version`

$ ruff . --isolated
error TOML parse error at line 6, column 1
  |
6 | [tool.hatch.version.raw-options]
  | ^
Invalid table header
Duplicate key `version`

Error only without --isolated in 0.0.220:

$ ruff --version
ruff 0.0.220
$ ruff .
error TOML parse error at line 6, column 1
  |
6 | [tool.hatch.version.raw-options]
  | ^
Invalid table header
Duplicate key `version`

$ ruff . --isolated
warning: No Python files found under the given path(s)
@messense
Copy link
Contributor

messense commented Jan 15, 2023

Looks like both toml and toml_edit fail to parse the toml content, see https://www.rustexplorer.com/b/vthrz3

$ ./playground
Err(
    Error {
        inner: ErrorInner {
            kind: Custom,
            line: Some(
                5,
            ),
            col: 0,
            at: Some(
                55,
            ),
            message: "duplicate key: `version`",
            key: [
                "tool",
                "hatch",
            ],
        },
    },
)
Err(
    TomlError {
        message: "TOML parse error at line 6, column 1\n  |\n6 | [tool.hatch.version.raw-options]\n  | ^\nInvalid table header\nDuplicate key `version`\n",
        line_col: Some(
            (
                5,
                0,
            ),
        ),
    },
)

@henryiii
Copy link
Contributor

I'm not familiar with the Rust release process, will this be closed when toml-rs/toml#439 is available in Ruff, so I can just watch this issue? :)

@charliermarsh
Copy link
Member

Yeah it should be! I'll try upgrading. It looks like they just cut a release.

@charliermarsh
Copy link
Member

Looks like #2040 should close this out.

charliermarsh added a commit that referenced this issue Jan 20, 2023
In #1680, we moved over to `toml_edit`. But it looks like `toml` now uses `toml_edit`, and has implemented some improvements (e.g., this closes #1894).
@charliermarsh charliermarsh reopened this Jan 21, 2023
@charliermarsh
Copy link
Member

Sorry, a little confusion with respect to the toml crate -- the upgrade I performed did solve this problem, but it had the potential to introduce some other incompatibilities with TOML 1. So I want to revert for now, just to minimize churn. I expect this to be closed out soon-ish, but we do need a new release. (See: #2058.)

charliermarsh added a commit that referenced this issue Jan 21, 2023
This _did_ fix #1894, but was a little premature. `toml` doesn't actually depend on `toml-edit` yet, and `v0.5.11` was mostly about deprecations AFAICT. So upgrading might solve that issue, but could introduce other incompatibilities, and I'd like to minimize churn. I expect that `toml` will have a new release soon, so we can revert this revert.

Reverts #2040.
@charliermarsh charliermarsh reopened this Jan 21, 2023
charliermarsh added a commit that referenced this issue Jan 24, 2023
@hugovk
Copy link
Contributor Author

hugovk commented Jan 24, 2023

Thank you for the fix, I can confirm this is fixed in 0.0.231.

I'm impressed it only took 9 days for: report to Ruff, report upstream to Rust TOML library, report upstream to the language-agnostic TOML test suite, then the test suite updated and released, then the TOML library updated and released, and then Ruff updated and released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants