Skip to content

Conversation

@icemac
Copy link

@icemac icemac commented Dec 4, 2020

I have long lines of text in an array and want to keep it human readable by putting each entry on an new line. Currently I have the following possibilities:

>>> import toml
>>> foo = dict(bar=['a long long line of test', 'another long long line of text'])
>>> print(toml.dumps(foo))
bar = [ "a long long line of test", "another long long line of text",]

>>> print(toml.dumps(foo, toml.TomlArraySeparatorEncoder()))
bar = [ "a long long line of test", "another long long line of text",]

>>> print(toml.dumps(foo, toml.TomlArraySeparatorEncoder(separator=",\n   ")))
bar = [ "a long long line of test",
    "another long long line of text",
    ]

The last variant looks best but still does not have all entries alined. My PR adds this ability:

>>> print(toml.dumps(foo, toml.TomlArraySeparatorEncoder(separator=",\n   ", indent_first_line=True)))
bar = [
    "a long long line of test",
    "another long long line of text",
    ]

Additionally the last entry in the array gets an extra space to the opening and closing brackets are equally surrounded by spaces in the default version (This was necessary to fit my use case as otherwise the closing bracket would be indented a space character too little.):

>>> print(toml.dumps(foo, toml.TomlArraySeparatorEncoder()))
bar = [ "a long long line of test", "another long long line of text", ]

Is there a chance to get this PR landed in the project?
Are the suggestions to improve it?

@codecov-io
Copy link

codecov-io commented Dec 4, 2020

Codecov Report

Merging #343 (ba55d7f) into master (3f637db) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #343      +/-   ##
==========================================
+ Coverage   89.74%   89.77%   +0.02%     
==========================================
  Files           5        5              
  Lines        1063     1066       +3     
==========================================
+ Hits          954      957       +3     
  Misses        109      109              
Impacted Files Coverage Δ
toml/encoder.py 88.50% <100.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f637db...ba55d7f. Read the comment docs.

@icemac
Copy link
Author

icemac commented Jan 15, 2021

Is there anything I can do to get this PR merged?

@icemac
Copy link
Author

icemac commented Nov 28, 2022

Lost hope that this will get merged, so closing it.

@icemac icemac closed this Nov 28, 2022
@icemac icemac deleted the indent_first_line branch November 28, 2022 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants