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

Suport inline tables #36

Closed
kianmeng opened this issue Aug 13, 2022 · 5 comments
Closed

Suport inline tables #36

kianmeng opened this issue Aug 13, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kianmeng
Copy link

kianmeng commented Aug 13, 2022

I've tried with other Python projects and it worked, but not for pyproject-fmt itself.

Running on:

$ python --version
Python 3.7.13

Steps to reproduce the error:

pipx install pyproject-fmt
git clone https://github.com/tox-dev/pyproject-fmt.git
cd pyproject-fmt
pyproject-fmt pyproject.toml 
Traceback (most recent call last):
  File "/home/foobar/.local/bin/pyproject-fmt", line 8, in <module>
    sys.exit(run())
  File "/home/foobar/.local/pipx/venvs/pyproject-fmt/lib/python3.7/site-packages/pyproject_fmt/__main__.py", line 29, in run
    formatted = format_pyproject(config)
  File "/home/foobar/.local/pipx/venvs/pyproject-fmt/lib/python3.7/site-packages/pyproject_fmt/formatter/__init__.py", line 24, in format_pyproject
    _perform(parsed, conf)
  File "/home/foobar/.local/pipx/venvs/pyproject-fmt/lib/python3.7/site-packages/pyproject_fmt/formatter/__init__.py", line 13, in _perform
    fmt_project(parsed, conf)
  File "/home/foobar/.local/pipx/venvs/pyproject-fmt/lib/python3.7/site-packages/pyproject_fmt/formatter/project.py", line 33, in fmt_project
    order_keys(opt_deps, (), sort_key=lambda k: k[0])
  File "/home/foobar/.local/pipx/venvs/pyproject-fmt/lib/python3.7/site-packages/pyproject_fmt/formatter/util.py", line 41, in order_keys
    body = table.value.body
AttributeError: 'dict' object has no attribute 'body'
@gaborbernat
Copy link
Member

What version are you using? We released a fix just last night, https://pypi.org/project/pyproject-fmt/

@gaborbernat gaborbernat reopened this Aug 13, 2022
@gaborbernat gaborbernat changed the title AttributeError: 'dict' object has no attribute 'body' Suport inline tables Aug 13, 2022
@gaborbernat
Copy link
Member

gaborbernat commented Aug 13, 2022

Simple reproducible:

[project]
optional-dependencies.test = [
  "a",
]
optional-dependencies.doc = [
  "b",
]

Note this format will work:

[project.optional-dependencies]
doc = [
  "b",
]
test = [
  "a",
]

Supporting the inline format is something I want to add at some point, but is non-trivial and likely will defer after I release tox 4.

@gaborbernat gaborbernat added the help wanted Extra attention is needed label Aug 13, 2022
@RonnyPfannschmidt
Copy link
Contributor

@gaborbernat ever since the update for sorting the tools section, im seeing this in general

@RonnyPfannschmidt
Copy link
Contributor

nm, its actually #70

@gaborbernat gaborbernat added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Oct 25, 2023
@kianmeng
Copy link
Author

LGTM.

$ python -V
Python 3.7.17

$ pipx install pyproject-fmt
git clone https://github.com/tox-dev/pyproject-fmt.git
cd pyproject-fmt
pyproject-fmt pyproject.toml 
...
no change for pyproject.toml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants