Skip to content

expand_table setting doesn’t work. #146

@flying-sheep

Description

@flying-sheep

See scverse/scanpy#3964:

reproducer:

# /// script
# dependencies = [ "pyproject-fmt==2.12.0" ]
# ///

import sys
import difflib
from pyproject_fmt._lib import Settings, format_toml

settings = Settings(
    column_width=120,
    indent=4,
    keep_full_version=True,
    max_supported_python=(3, 14),
    min_supported_python=(3, 14),
    generate_python_version_classifiers=False,
    table_format="short",
    expand_tables=["project.optional-dependencies"],
    collapse_tables=[],
)

content = """\
[project]
name = "test"

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

sys.stdout.writelines(difflib.unified_diff(
    content.splitlines(keepends=True),
    format_toml(content, settings).splitlines(keepends=True),
    fromfile="input",
    tofile="output",
))

prints

--- input
+++ output
@@ -1,5 +1,4 @@
 [project]
 name = "test"
 
-[project.optional-dependencies]
-a = [ "b", "c" ]
+optional-dependencies.a = [ "b", "c" ]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions