python-lsp-ruff: `per-file-ignores` doesn't seem to be working

This works in both ruff via CLI and with python-lsp-ruff; none of the listed errors are visible in __init__.py files:

Edit: No it doesn’t, please see comment below.

[tool.ruff]
ignore = [
	"E501", # line length violations
	"E722", # bare except
]
per-file-ignores = {
	# Ignore import violations in all `__init__.py` files
	"__init__.py" = ["E402", "F401", "F403"]
}

This works when invoking ruff via CLI, but not in python-lsp-ruff; the per-file-ignores are visible in the editor but not in the command line (the global ignored errors are still invisible in both):

[tool.ruff]
ignore = [
	"E501", # line length violations
	"E722", # bare except
]

# Ignore import violations in all `__init__.py` files
[tool.ruff.per-file-ignores]
"__init__.py" = ["E402", "F401", "F403"]

It seems like python-lsp-ruff doesn’t parse sub-tables specified via headers somehow?

Thank you for this project!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18 (8 by maintainers)

Most upvoted comments

Arch package for ruff was updated since my last comment, I can confirm it’s fixed now. Thanks again!

That was it. This package is evolving so fast that it’s hard to keep track to all the changes. Awesome work @charliermarsh!

Right, that was just from that one time above where I already realized the config was invalid (see the first message in this thread). I’ve since fixed it (see the second message) and that error hasn’t come up since (please note the date in that invalid toml error message).

Anyway, here’s the entire thing:

[tool.poetry]
name = "..."
version = ".."
description = "..."
authors = ["..."]

[tool.poe.tasks]
demo = { script = 'demos:main' }
test = "pytest"
check = "pyright"
lint = "pylint src/"
ruff = "ruff src/"
format = "black src/"

[tool.poetry.dependencies]
(snip)

[tool.poetry.group.dev.dependencies]
(snip)

[tool.poetry.group.test.dependencies]
(snip)

[tool.pyright]
exclude = [
	"**/node_modules",
	"**/__pycache__",
]

[tool.ruff]
ignore = [
	"E501", # line length violations
	"E722", # bare except
]

# Ignore import violations in all `__init__.py` files
[tool.ruff.per-file-ignores]
"__init__.py" = ["E402", "F401", "F403"]

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