Skip to content

vendored toml parser cannot handle inline comment following multiline string #1796

Closed
@Jasha10

Description

@Jasha10

My pyproject.toml file looks like this:

xyz = ''' pdq
''' # heres an inline comment after a multiline string

[tool.isort]
profile = "black"
multi_line_output = 3

It seems that isort is not able to handle this toml file. In particular, the use of an inline comment after a multi-line string makes isort incompatible with black. I assume that it is not parsing the toml file properly:

$ black . && isort .
reformatted dtcio.py
All done! ✨ 🍰 ✨
1 file reformatted.
Fixing /home/jasha10/tmp/dtcio.py
Skipped 1 files
$ black . && isort .
reformatted dtcio.py
All done! ✨ 🍰 ✨
1 file reformatted.
Fixing /home/jasha10/tmp/dtcio.py
Skipped 1 files

The problem goes away if I do one of the following:

  • remove the inline comment in the toml file
  • use a single-line string instead of a multi-line string
black version: 21.7b0
isort version: 5.9.2

Both inline comments and multi-line strings are officially supported by the toml spec.
The use of inline comments after a multi-line string is not explicitly mentioned in the toml spec :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestupstreamNot a bug in isort but in an upstream repository

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions