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

pyproject.toml some valid TOML syntax not accepted #7556

Closed
intgr opened this issue Oct 26, 2020 · 7 comments · Fixed by #7559
Closed

pyproject.toml some valid TOML syntax not accepted #7556

intgr opened this issue Oct 26, 2020 · 7 comments · Fixed by #7559
Assignees
Labels
manager:poetry Poetry package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)

Comments

@intgr
Copy link
Contributor

intgr commented Oct 26, 2020

What Renovate type, platform and version are you using?

Self-hosting using GitLab, with Python "poetry" package manager

Describe the bug

When I enable the "poetry" manager with Renovate, it attempts to read the pyproject.toml configuration file in my project.

Python tools are perfectly happy with pyproject.toml that contains the following:

[tool.coverage]
run.omit = ["*/tests_*.py"]
report.precision = 2

However, Renovate fails to parse this file ("Error parsing pyproject.toml file"; "SyntaxError").

Thankfully as a workaround I could rewrite the file using different syntax, that works with Renovate:

[tool.coverage.run]
omit = ["*/tests_*.py"]

[tool.coverage.report]
precision = 2

Relevant debug logs

DEBUG: Using file match: (^|/)pyproject\.toml$ for manager poetry (repository=xxxxx)
DEBUG: Matched 1 file(s) for manager poetry: pyproject.toml (repository=xxxxx)
DEBUG: Error parsing pyproject.toml file (repository=xxxxx)
       "err": {
         "message": "Expected \"=\", [ \\t] or [A-Za-z0-9_\\-] but \".\" found.",
         "expected": [
           {"type": "literal", "value": "=", "description": "\"=\""},
           {"type": "class", "value": "[ \\t]", "description": "[ \\t]"},
           {
             "type": "class",
             "value": "[A-Za-z0-9_\\-]",
             "description": "[A-Za-z0-9_\\-]"
           }
         ],
         "found": ".",
         "offset": 4439,
         "line": 169,
         "column": 4,
         "name": "SyntaxError"
       }
DEBUG: Found 0 package file(s) (repository=xxxxx)
 INFO: Dependency extraction complete (repository=xxxxx)

To Reproduce

Append the following fragment to a pyproject.toml file:

[tool.coverage]
run.omit = ["*/tests_*.py"]
report.precision = 2

Additional context

Does Renovate only support some older toml syntax?

@rarkins
Copy link
Collaborator

rarkins commented Oct 26, 2020

Could you give us a full file which fails? It can be as small/redacted as you want, as long as poetry accepts it and our parser rejects it. Then we'll need to work out if we file a bug upstream to our TOML parser

@intgr
Copy link
Contributor Author

intgr commented Oct 26, 2020

Complete failing pyproject.toml example:

[tool.poetry]
name = "app"
version = "1.0.0"
description = "   ᕕ( ᐛ )ᕗ   "
authors = ["MR <marti@juffo.org>"]

[tool.poetry.dependencies]
python = "^3.8"
"ruamel.yaml" = "0.16.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.coverage]
run.omit = ["*/tests_*.py"]

I can successfully run poetry lock on this file, but Renovate rejects it:

DEBUG: Error parsing pyproject.toml file (repository=xxxxx)
       "err": {
         "message": "Expected \"=\", [ \\t] or [A-Za-z0-9_\\-] but \".\" found.",
         "expected": [
           {"type": "literal", "value": "=", "description": "\"=\""},
           {"type": "class", "value": "[ \\t]", "description": "[ \\t]"},
           {
             "type": "class",
             "value": "[A-Za-z0-9_\\-]",
             "description": "[A-Za-z0-9_\\-]"
           }
         ],
         "found": ".",
         "offset": 290,
         "line": 16,
         "column": 4,
         "name": "SyntaxError"
       }

@viceice
Copy link
Member

viceice commented Oct 27, 2020

Maybe we need to switch our toml library, see https://github.com/toml-lang/toml/wiki#v100-rc1-compliant.

Our current lib only supports v0.4.0 and there is an open issue for v0.5.0 suport, see BinaryMuse/toml-node#50

@viceice viceice added type:feature Feature (new functionality) manager:poetry Poetry package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others labels Oct 27, 2020
@viceice viceice self-assigned this Oct 27, 2020
@rarkins
Copy link
Collaborator

rarkins commented Oct 27, 2020

Or maybe we don't need to formally parse the full toml to get the data we need?

@viceice
Copy link
Member

viceice commented Oct 27, 2020

That would be a more complex refactoring. Switching the parser to a more modern one is a far more easy fix. 🙃

@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 23.57.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@intgr
Copy link
Contributor Author

intgr commented Nov 6, 2020

Thank you for such a quick fix! :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
manager:poetry Poetry package manager priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants