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

Support for multi-line tables in pyproject.toml #961

Closed
patrick91 opened this issue Nov 29, 2022 · 3 comments
Closed

Support for multi-line tables in pyproject.toml #961

patrick91 opened this issue Nov 29, 2022 · 3 comments

Comments

@patrick91
Copy link

I do have a few per-file ignores in my project[1]. Do you think it is possible to add support for multi-line tables?

This works:

[tool.ruff]
line-length = 89
per-file-ignores = {"tests/federation/printer/*" = ["E501"], "tests/test_printer/test_basic.py" = ["E501"], "tests/pyright/test_federation.py" = ["E501"], "tests/test_printer/test_schema_directives.py" = ["E501"]}

This does not:

[tool.ruff]
line-length = 89
per-file-ignores = {
  "tests/federation/printer/*" = ["E501"], 
  "tests/test_printer/test_basic.py" = ["E501"], 
  "tests/pyright/test_federation.py" = ["E501"], 
  "tests/test_printer/test_schema_directives.py" = ["E501"]
}

Error:

error expected a table key, found a newline at line 196 column 21

I get the same error in VS Code:

CleanShot 2022-11-29 at 12 54 13@2x

My understanding is that multi-line tables are supported by TOML: toml-lang/toml#904

but it's a relatively new feature :)

Anyway, I'm fine with having the ignores on one line, it's not a big deal, I opened the issue just in case it is easy to implement and for others that might stumble on the same problem :)

[1] https://github.com/strawberry-graphql/strawberry/pull/2367/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711R196

@sondr3
Copy link

sondr3 commented Nov 29, 2022

I'm not an expert in TOML and how tables work, but I ran into this problem in a project too. You can use the following syntax for this at the moment:

[tool.ruff.per-file-ignores]
"tests/federation/printer/*" = ["E501"]
"tests/test_printer/test_basic.py" = ["E501"]
"tests/pyright/test_federation.py" = ["E501"]
"tests/test_printer/test_schema_directives.py" = ["E501"]

It doesn't look to me like the PR your linked has been published under a new TOML version, so for now the spec doesn't allow these kinds of tables.

@patrick91
Copy link
Author

I'm not an expert in TOML and how tables work, but I ran into this problem in a project too. You can use the following syntax for this at the moment:

[tool.ruff.per-file-ignores]
"tests/federation/printer/*" = ["E501"]
"tests/test_printer/test_basic.py" = ["E501"]
"tests/pyright/test_federation.py" = ["E501"]
"tests/test_printer/test_schema_directives.py" = ["E501"]

ah! great suggestion!

It doesn't look to me like the PR your linked has been published under a new TOML version, so for now the spec doesn't allow these kinds of tables.

didn't notice that! thanks for checking 😊

I'll close the issue for now then!

@paddyroddy
Copy link

It ain't pretty, but I like one section per tool. The following works, which is good enough for me.

[tool.ruff]
per-file-ignores = {"btrack/models.py" = [
    "UP006",
    "UP007",
], "btrack/config.py" = [
    "UP006",
    "UP007",
]}

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

No branches or pull requests

3 participants