Crash on Ruff config
acdha opened this issue · 2 comments
acdha commented
I have a pyproject.toml file which had one arguably out of order block:
[tool.ruff.isort]
known-first-party = ["myapp"]
[tool.ruff]
line-length = 88
target-version = "py310"
select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"E",
"ERA", # flake8-eradicate
"EXE", # flake8-executable
"F",
"G", # flake8-logging-format
"I", # isort
"PIE", # flake8-pie
"RUF", # Ruff
"TRY", # tryceratops
"UP", # pyupgrade
"W",
]
ignore = [
"TRY003",
"RUF001", # See https://github.com/charliermarsh/ruff/issues/3947
]
This caused pyproject-fmt 0.10.0
to crash:
Traceback (most recent call last):
File "/Users/cadams/.local/bin/pyproject-fmt", line 8, in <module>
sys.exit(run())
^^^^^
File "/Users/cadams/.local/pipx/venvs/pyproject-fmt/lib/python3.11/site-packages/pyproject_fmt/__main__.py", line 55, in run
results = [_handle_one(config, opts) for config in opts.configs]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cadams/.local/pipx/venvs/pyproject-fmt/lib/python3.11/site-packages/pyproject_fmt/__main__.py", line 55, in <listcomp>
results = [_handle_one(config, opts) for config in opts.configs]
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cadams/.local/pipx/venvs/pyproject-fmt/lib/python3.11/site-packages/pyproject_fmt/__main__.py", line 28, in _handle_one
formatted = format_pyproject(config)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cadams/.local/pipx/venvs/pyproject-fmt/lib/python3.11/site-packages/pyproject_fmt/formatter/__init__.py", line 26, in format_pyproject
_perform(parsed, conf)
File "/Users/cadams/.local/pipx/venvs/pyproject-fmt/lib/python3.11/site-packages/pyproject_fmt/formatter/__init__.py", line 15, in _perform
fmt_tools(parsed, conf)
File "/Users/cadams/.local/pipx/venvs/pyproject-fmt/lib/python3.11/site-packages/pyproject_fmt/formatter/tools.py", line 18, in fmt_tools
ensure_newline_at_end(cast(Table, table))
File "/Users/cadams/.local/pipx/venvs/pyproject-fmt/lib/python3.11/site-packages/pyproject_fmt/formatter/util.py", line 139, in ensure_newline_at_end
insert_body = content.value.body
^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'body'
(at that point content.value
is the ruff
tool block)
If I move the tool.ruff.isort
section below tool.ruff
, it runs successfully.
gaborbernat commented
PR welcome 👍
gaborbernat commented
Please check with https://github.com/tox-dev/pyproject-fmt/releases/tag/2.0.0 and report if still a problem.