fguess
Like https://pym.dev/format but in your terminal.
Given an example of formatted output, fguess guesses the f-string format specification that would produce it.
Installation
Installing with uv tool:
uv tool install fguess
Installing with pipx:
pipx install fguess
You can also install fguess globally with pip, but I usually recommend installing command-line tools in their own separate environment.
Usage
Run fguess with an example of formatted output to see the format specification that would produce it:
$ fguess '$1,234.56'
Input: '$1,234.56'
----------------------------------------
float → f"${variable:,.2f}"
(e.g., variable = 1234.56)
str → f"${variable}"
(e.g., variable = '1,234.56')
Padded strings and datetimes are recognized too:
$ fguess "2030-01-24 05:45"
Input: '2030-01-24 05:45'
----------------------------------------
datetime → f"{variable:%Y-%m-%d %H:%M}"
(e.g., variable = datetime.datetime(2030, 1, 24, 5, 45))
Remember to quote the string you pass in, since format specifications often include characters your shell would otherwise interpret.
Run fguess with no arguments to analyze one string after another until you type quit.
Development
This project uses uv and just.
Run just to see every available task.
$ just test # run the test suite
$ just check # format, lint, and test
No setup step is needed: uv creates the virtual environment and installs dependencies on the first uv run.
To run the tests on every supported Python version:
just test-all
To see code coverage:
just test-cov
open htmlcov/index.html
If you would rather not install just, every task is a short uv command that you can run directly (check the justfile for the commands):
uv run pytest
Releasing
Releases are published to PyPI by GitHub Actions whenever a v* tag is pushed.
From an up-to-date main:
$ just bump minor # or patch, or major
$ git commit -am "Version 0.1.0"
$ just release
The release task refuses to run unless the checks pass, the working tree is clean, and you are on main.
It then tags the current version and pushes, which triggers the release workflow.
License
fguess is distributed under the terms of the MIT license.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fguess-0.1.0.tar.gz.
File metadata
- Download URL: fguess-0.1.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8151976e8f873a2b113f322a5d0c156ed110d1e9dbcf5bb90e86d7dd9a5cc98
|
|
| MD5 |
fa1c4d39b36cb04838b45f0e09bc9ca3
|
|
| BLAKE2b-256 |
8c067bfe435b4f820cc90baad5a5a68d7a8fbccbf683baf8f6d3390cd307c7f3
|
File details
Details for the file fguess-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fguess-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
878eaad2ceb9faaa5a23fd17aaa746e20cb4cc7ac860eba8e5ec00b9dd6087e0
|
|
| MD5 |
a3b365c5a995d00c5a7b2d0aea1ea3cd
|
|
| BLAKE2b-256 |
1e5c963c09780a4461877be228b8288b78619fe9f29c2e179b723b2dc12a5c3e
|