Skip to main content

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 bundle the native Rust executable, so they do not require Rust or a Fortran compiler; Rust is only needed when building from source.

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.4
    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

The default input mode automatically detects fixed versus free form. 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, preserving the existing behavior that can modernize (/ ... /) array constructors to [ ... ]. 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.

For example:

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

If authored internal spacing must be preserved while both canonical spelling and structural indentation are wanted, use the combined mode:

forformat --canonicalize-and-indent src/module.f90

It is defined as canonicalize-only followed by indent-only with the same settings, so it preserves authored interior spacing, does not wrap statements, and does not run full-mode alignment passes.

If all spelling must also be preserved, use the indentation-only mode:

forformat --indent-only src/module.f90

This changes indentation and trailing whitespace but deliberately does not apply keyword casing or full-mode normalization.

The main option reference, including defaults, project settings, and file-selection options, is in the project documentation.

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. For an editor buffer on stdin, identify its source file so the buffer shadows the stale on-disk copy during analysis:

forformat --stdin --project-context=src/module.f90 < src/module.f90

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,
    options=("--config=/absolute/path/to/.forformat.toml",),
    repo_context_path="/path/to/checkout/src/module.f90",
)

The return type matches the input type. Configuration discovery is disabled for this API unless options explicitly supplies --config.

Metadata

Release files for forformat 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for forformat 0.1.4
File
forformat-0.1.4-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
forformat-0.1.4-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
forformat-0.1.4-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.4-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux musl 1.2+ ARM64 Details
forformat-0.1.4-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
forformat-0.1.4-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.4-py3-none-win_arm64.whl

Download URL forformat-0.1.4-py3-none-win_arm64.whl
Size 622.0 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
dca37176256461e7775ba8a25b78000ea4c957ce699615306a6fc8ea345b4e15
BLAKE2b-256 checksum
How to use checksums
4018ee6245cf6c41250d1a4839e821be081131038ca5c87af8376bbd4d8ac7c3
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 25, 2026.

Transparency log

Release files / forformat-0.1.4-py3-none-win_amd64.whl

Download URL forformat-0.1.4-py3-none-win_amd64.whl
Size 685.8 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
eb0121fc397ee707d6166d02987eff2a17c0bc4b406d06863ce0294b84fdef68
BLAKE2b-256 checksum
How to use checksums
e6058d0b2b6b64b6cf8a1369dbc02b935094c8fa51efc9f4c5192be9153797b7
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 25, 2026.

Transparency log

Release files / forformat-0.1.4-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl

Download URL forformat-0.1.4-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl
Size 822.5 kB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b16c1012c1f851c833cb6cde672ef19db0baf45bb239e16ce55c88ed5e623176
BLAKE2b-256 checksum
How to use checksums
a31a9e52022ec8de417ccd0c5e9763a735f8e7dbe40a609897cbd1c532ace66b
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 25, 2026.

Transparency log

Release files / forformat-0.1.4-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl

Download URL forformat-0.1.4-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl
Size 745.7 kB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
d210a94407269ef8247b5824b998b47ea544055be0364818d4acf8501e415393
BLAKE2b-256 checksum
How to use checksums
07d76a071e9086621feb32606faae9175c4d03a057e3581c974d77bd5fe106f9
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 25, 2026.

Transparency log

Release files / forformat-0.1.4-py3-none-macosx_11_0_arm64.whl

Download URL forformat-0.1.4-py3-none-macosx_11_0_arm64.whl
Size 656.4 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4eda298b7331b9c8c25b5ea4ddcbe7c646dfcd5f5a1ade3a726d6cd3edfe7d39
BLAKE2b-256 checksum
How to use checksums
3ba70310889115293e1c22770a46f27b24e81392f1d8e7b0d525e633a19d17c2
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 25, 2026.

Transparency log

Release files / forformat-0.1.4-py3-none-macosx_10_12_x86_64.whl

Download URL forformat-0.1.4-py3-none-macosx_10_12_x86_64.whl
Size 728.1 kB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
af6be4ac3a300995a507dd8f21b0556da4cba968e17bc226a61b902a6202f22e
BLAKE2b-256 checksum
How to use checksums
2c08c00ed973fddf4a244ba4c3d489295cf2a309fdca2b1caedefd42087574b9
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 25, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.5

6 release files

This release

0.1.4 This release

6 release files

0.1.3

5 release files

0.1.2

5 release files

0.1.1

5 release files

0.1.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page