Skip to content

[BUG] --pretty=false doesn't have any effect on TOML #457

@n-badtke-cg

Description

@n-badtke-cg

Describe the bug
I want to use the flag --pretty=false to get the same output from dasel as the input TOML is but the flag has no effect.

To Reproduce
Steps to reproduce the behavior:

  1. (Example) Input file pyproject.toml:
    [build-system]
    requires = [
        "setuptools",
        "wheel"
    ]
    build-backend = "setuptools.build_meta"
    
    [project]
    name = "project_name"
    authors = [
        { name = "Dummy Dude", email = "[email protected]" }
    ]
    license = { text = "Apache License 2.0" }
    description = "A Python project"
    dynamic = [
        "version"
    ]
    requires-python = "~=3.13"
    
    # required by poetry but unused due to usage of setuptools
    [tool.poetry]
    version = "0"
    
    [project.readme]
    file = "README.md"
    content-type = "text/markdown"
    
    [project.entry-points.project_name]
    provider_info = "package_name.__init__:get_package_info"
    
    [tool.setuptools]
    include-package-data = false
    
    [tool.setuptools.dynamic]
    version = { attr = "package_name.__version__" }
    
    [tool.setuptools.packages.find]
    exclude = [
        "*tests.*",
        "*tests"
    ]
  2. Commands:
    dasel -r toml --pretty=false -f pyproject.toml
    and also
    dasel put -r toml --pretty=false -f pyproject.toml -v '0.1.0' .tool.poetry.version
  3. See different outputs than input contents:
    [build-system]
      build-backend = 'setuptools.build_meta'
      requires = ['setuptools', 'wheel']
    
    [project]
      description = 'A Python project'
      dynamic = ['version']
      name = 'project_name'
      requires-python = '~=3.13'
    
      [[project.authors]]
        email = '[email protected]'
        name = 'Dummy Dude'
    
      [project.entry-points]
        [project.entry-points.project_name]
          provider_info = 'package_name.__init__:get_package_info'
    
      [project.license]
        text = 'Apache License 2.0'
    
      [project.readme]
        content-type = 'text/markdown'
        file = 'README.md'
    
    [tool]
      [tool.poetry]
        version = '0'
    
      [tool.setuptools]
        include-package-data = false
    
        [tool.setuptools.dynamic]
          [tool.setuptools.dynamic.version]
            attr = 'package_name.__version__'
    
        [tool.setuptools.packages]
          [tool.setuptools.packages.find]
            exclude = ['*tests.*', '*tests']

Expected behavior
The content of the output is matching the input content.

Screenshots

Image

Desktop

  • OS:
    > lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 24.04.2 LTS
    Release:        24.04
    Codename:       noble
    
  • Version: v2.8.1

Additional context
The pyproject.toml may get smaller and also more efficient but in automated CI/CD pipelines it is crucial to have the option to leave the contents as provided.

PS
Love the tool <3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions