python-poetry / python-poetry/tomlkit
Emitting underscores in integers
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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