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

KeyAlreadyPresent exception does not strip whitespace from key #185

Closed
ThatOtherAndrew opened this issue Mar 29, 2022 · 0 comments
Closed

Comments

@ThatOtherAndrew
Copy link

Issue

If you have a TOML file containing something like the following:

my_key = 5
my_key = 10

Then the exception message will show the following:

tomlkit.exceptions.KeyAlreadyPresent: Key "my_key " already exists.

If you pad the equals sign with even more spaces, then the additional whitespace also shows up in the exception message. It's a minor detail, but it's been bugging me slightly.

Proposed solution

Substitute L197 in tomlkit.exceptions with the following:

message = f'Key "{key.rstrip()}" already exists.'

Additional notes

I'm not sure if this affects any other exceptions, but if it does, it may be worth using .rstrip() somewhere else. I'm not too familiar with the codebase, so I'm avoiding making a pull request as of now.

capuanob pushed a commit to capuanob/tomlkit that referenced this issue Mar 1, 2023
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

No branches or pull requests

1 participant