python-poetry / python-poetry/tomlkit

Emitting underscores in integers

Open
#336 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
850
Forks
162
Avg merge
13m
Merged PRs (30d)
2

Description

TOML allows an underscore anywhere in an integer, as long as there is a digit each side of it:

For large numbers, you may use underscores between digits to enhance readability. Each underscore must be surrounded by at least one digit on each side.

int5 = 1_000
int6 = 5_349_221
int7 = 53_49_221  # Indian number system grouping
int8 = 1_2_3_4_5  # VALID but discouraged

I'd like to be able to emit an underscore-formatted integer when dump/sing a TOML file.

This is probably quite hard to implement with full flexibility, but it would be good to either be able to indicate some level of customisation, e.g. "use an underscore to indicate 100s" or "use an underscore to indicate 1000s", or alternatively to be able to supply a _-formatted integer as a string, and have tomlkit render it as a number, without quotation marks.

Happy to discuss if there's interest. Otherwise I can try a PR, but I'd rather get some consensus first.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named in the issue. Start by resolving whether customization or a preformatted-string API is wanted, then define acceptance around emitting valid underscore-formatted TOML integers without quotation marks.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.