forformat
forformat formats free-form Fortran. Full formatting is the default: it combines
findent-compatible indentation with lexical normalization, project-aware identifier casing, and
statement wrapping. --indent-only provides the findent-compatible indentation contract.
The package installs the forformat command and an importable in-memory API. It requires Python
3.9 or newer. Published wheels include the formatter, so normal installation does not require Rust
or a Fortran compiler.
Install
python -m pip install forformat
forformat --version
For pre-commit, use the separate hook repository:
repos:
- repo: https://github.com/cmbant/forformat-pre-commit
rev: v0.1.5
hooks:
- id: forformat
# - id: forformat-check # check only; do not rewrite
Quick start
Format files in place:
forformat src/module.f90
forformat src/*.f90
forformat src/
Check or preview changes without rewriting files:
forformat --check src/*.f90
forformat --diff src/*.f90
Format every tracked free-form source in the current checkout, or check the whole checkout:
forformat --all-files
forformat --all-files --check
Use stdin/stdout in a pipeline:
forformat --stdin < src/module.f90 > /tmp/module.f90
forformat --stdout src/module.f90 > /tmp/module.f90
For an editor buffer, give stdin the filename it represents:
forformat --stdin-filename=src/module.f90 < src/module.f90
The filename supplies configuration and project discovery, source-form detection, relative
INCLUDE resolution, and diagnostics. It may name a new file whose parent already exists. Use
--project-context=/path/to/other/checkout only when semantic project context should come from a
different Git checkout.
Automatic fixed/free input detection is enabled by default. A source detected as fixed form is
skipped unchanged. Use -ifree or --input-format=free to force free-form handling, and
--query-format to print the detected form. Fixed-form output is unsupported.
Modes and common options
--full— normalization, wrapping, and structural layout; this is the default.--indent-only— findent-compatible indentation and trailing-whitespace handling.--normalize-only— normalization without structural layout or wrapping.--canonicalize-only— canonical transformations without whitespace or layout normalization.--canonicalize-and-indent— canonical transformations followed by findent-compatible indentation, without wrapping or full-mode post-layout alignment.
Normalizing modes target Fortran 2003 output by default. Use --target-standard=f95 (or
target_standard = "f95" in configuration) to prevent the formatter from introducing syntax newer
than Fortran 95. The target constrains formatter-generated syntax; it does not validate or downgrade
syntax already present in the input.
Common examples:
forformat --indent=4 --indent-module=0 --indent-procedure=0 src/module.f90
forformat --keyword-case=upper --line-length=100 src/module.f90
forformat --canonicalize-and-indent src/module.f90
forformat --indent-only src/module.f90
The main option reference, including defaults, project settings, and file-selection options, is in the project documentation.
For setup instructions for using forformat with VS Code, see the VS Code setup guide.
Project context and configuration
Explicit file paths use declarations from the surrounding Git checkout for project-aware case
resolution. Use --isolated when each file should be processed independently. A named stdin buffer
uses --stdin-filename=FILE to derive the same project context and to shadow FILE's stale on-disk
copy when it is tracked. --project-context=DIRECTORY can override only the Git project used for
analysis.
Project settings can live in .forformat.toml, the compatibility spelling .findent.toml, or
[tool.forformat] in pyproject.toml:
[tool.forformat]
mode = "full"
target_standard = "f2003"
indent = 4
line_length = 100
keyword_case = "lower"
context_paths = ["src", "modules"]
exclude = ["vendor/"]
extend_exclude = ["**/generated-*.f90"]
Hyphens and underscores are equivalent in configuration keys. Command-line scalar options override
project settings. --exclude replaces the configured exclusion set; --extend-exclude adds to it.
Python API
from forformat import format_source
formatted = format_source(
source,
filename="/path/to/checkout/src/module.f90",
options=("--config=/absolute/path/to/.forformat.toml",),
)
The return type matches the input type. filename supplies file identity and default project
context; repo_context_path can override that project with a directory. Configuration discovery is
disabled for this API unless options explicitly supplies --config.
Metadata
Release files for forformat 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| forformat-0.1.5-py3-none-win_arm64.whl | Python 3 | none | Windows ARM64 | Details |
| forformat-0.1.5-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| forformat-0.1.5-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64, Linux glibc 2.17+ x86-64 | Details |
| forformat-0.1.5-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl | Python 3 | none | Linux musl 1.2+ ARM64, Linux glibc 2.17+ ARM64 | Details |
| forformat-0.1.5-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| forformat-0.1.5-py3-none-macosx_10_12_x86_64.whl | Python 3 | none | macOS 10.12+ x86-64 | Details |
Total release size: 4.3 MB
Release files / forformat-0.1.5-py3-none-win_arm64.whl
| Download URL | forformat-0.1.5-py3-none-win_arm64.whl |
|---|---|
| Size | 626.5 kB |
| Tags | Python 3 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
3331ecc10ecde3acb3dae0b202b32e9bb4821f9dd0aa8c5d8e8a8c30c5e398f9
|
|
BLAKE2b-256 checksum How to use checksums |
c6fc514b3929c5774065fe61bd633c2163c31af5daff7a9825fec983cefee1cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / forformat-0.1.5-py3-none-win_amd64.whl
| Download URL | forformat-0.1.5-py3-none-win_amd64.whl |
|---|---|
| Size | 690.6 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a61f5b2d11e90b4f62cc8c019a4ef2de1b76d93dc8d6d0ff33d57215b8cdd079
|
|
BLAKE2b-256 checksum How to use checksums |
2b4e165c3a38c4825ca7b7703c098375bdd0e9c28fbc931bcc29729479a5bbff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / forformat-0.1.5-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl
| Download URL | forformat-0.1.5-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl |
|---|---|
| Size | 828.4 kB |
| Tags | Linux glibc 2.17+ x86-64 Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
0069fe88aee12b3d96efc41acce163d317aefe171e31852fcbf73308a12f6942
|
|
BLAKE2b-256 checksum How to use checksums |
8c49a49de5cb1984d7d61798779d017c708971c558ce75f193c01a574c6b1759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / forformat-0.1.5-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl
| Download URL | forformat-0.1.5-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl |
|---|---|
| Size | 752.3 kB |
| Tags | Linux glibc 2.17+ ARM64 Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
a4f7b8e94d014839c22a5249c2c8716f1b9065ca8fb0e148470fd046731f4011
|
|
BLAKE2b-256 checksum How to use checksums |
d10b1e39bab42e93ad4214eba587195e6fc101befa09cf7ec80347ae98b96cee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / forformat-0.1.5-py3-none-macosx_11_0_arm64.whl
| Download URL | forformat-0.1.5-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 663.4 kB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4c750e5322054c22f9df6a74392b9d5a85ad9f3e313039d6d42d0e59e07b41ad
|
|
BLAKE2b-256 checksum How to use checksums |
7a0f2cb3ee2fc83df540e9670d282090c69a28044ef7a9ab90cd02aae3ff552e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency logRelease files / forformat-0.1.5-py3-none-macosx_10_12_x86_64.whl
| Download URL | forformat-0.1.5-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 734.5 kB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
d13d811574752a9c43c43bc95cf1ab9555d21fa49ec7a5c10613fa6e65696f68
|
|
BLAKE2b-256 checksum How to use checksums |
ca17e8b6b3d69b9d7b6caae71930f4bdd5a49faaba0aa68a5d68a241625ebbb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.
Transparency log