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

Error parsing TOML on 1.1.386 if using comments in Arrays #9296

Closed
pavel-naumenko opened this issue Oct 23, 2024 · 8 comments
Closed

Error parsing TOML on 1.1.386 if using comments in Arrays #9296

pavel-naumenko opened this issue Oct 23, 2024 · 8 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working regression

Comments

@pavel-naumenko
Copy link

Description

After upgrading from 1.1.385 to 1.1.386 pyright raises errors "Pyproject file parse attempt 1 error:"

Issue is raised if pyproject.toml has comments in arrays

E.g. error in 1.1.386 (while OK in 1.1.385

[project]
name = "test"
version = "1.0.0"
dependencies = [
    "lib_a==1.1.1", # comment
    "lib_b==1.1.2"
]

If removing comments, parsing is OK in new version also

[project]
name = "test"
version = "1.0.0"
dependencies = [
    "lib_a==1.1.1", 
    "lib_b==1.1.2"
]
@pavel-naumenko pavel-naumenko added the bug Something isn't working label Oct 23, 2024
@InSyncWithFoo
Copy link
Contributor

See #9297 for an explanation. Both @iarna/toml and iarna-toml-esm seem to be abandoned; it's probably better to use a maintained library, like smol-toml.

@erictraut
Copy link
Collaborator

Looks like I'll need to back out the change for #9286.

@InSyncWithFoo, I looked at smol-toml, but it unfortunately distributed as an ES Module rather than a CommonJS package. That means there's no straightforward way to use it in pyright.

I'll investigate other options.

@linde12
Copy link

linde12 commented Oct 25, 2024

Can confirm. Even comments above a list is failing for me

@erictraut
Copy link
Collaborator

I switched to a different toml parser library — one that claims to support the toml 1.0 standard. Let's see if this addresses all of the issues.

@erictraut erictraut added addressed in next version Issue is fixed and will appear in next published version and removed needs investigation Requires additional investigation to determine course of action labels Oct 25, 2024
@Dr-Irv
Copy link

Dr-Irv commented Oct 25, 2024

@erictraut I'm having the same issue with pandas-stubs, so if you use that as a test, you can see if the new TOML library handles it. Our pyproject.toml file has lots of comments in it.

@erictraut
Copy link
Collaborator

@Dr-Irv, good idea. I confirmed that the new toml parser works fine with pandas-stubs.

@plu-bgl
Copy link

plu-bgl commented Oct 28, 2024

I saw this one too late, but I created #9339 and I think the same issue was introduced in v1.1.285: #4367. It's all about using CRLF vs LF or CR.

@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.387.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working regression
Projects
None yet
Development

No branches or pull requests

6 participants