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

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.6
File Actions
forformat-0.1.6-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for forformat-0.1.6-py3-none-win_arm64.whl
forformat-0.1.6-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for forformat-0.1.6-py3-none-win_amd64.whl
forformat-0.1.6-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 for forformat-0.1.6-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl
forformat-0.1.6-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 for forformat-0.1.6-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl
forformat-0.1.6-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for forformat-0.1.6-py3-none-macosx_11_0_arm64.whl
forformat-0.1.6-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for forformat-0.1.6-py3-none-macosx_10_12_x86_64.whl

Total release size: 4.3 MB

Release files / forformat-0.1.6-py3-none-win_arm64.whl

Download URL forformat-0.1.6-py3-none-win_arm64.whl
Size 622.3 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
5172297fde29a16defebc32da0b657585cf82a990aa442f003ea64da1f248ffb
BLAKE2b-256 checksum
How to use checksums
330e31930d9b5e1e90b78ca95be741e7cdc07e270cd62f1e666dbd337ebadf2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL forformat-0.1.6-py3-none-win_amd64.whl
Size 686.3 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
e42a93995fac7b65a20be10fc65c72f058f391753ab42fa7443e5017de40c17d
BLAKE2b-256 checksum
How to use checksums
52b812b17539f55b15cba4e0a7dab8812ecdcaed140ec0dbd7419150898b5ef1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL forformat-0.1.6-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl
Size 820.4 kB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
8a93683d4a627b419edf3dbc38da60ac582a2eefb5e8c4110a0491e4344f11ca
BLAKE2b-256 checksum
How to use checksums
179a623f28614bd4d14deb82b2fdc104995cbd6b5daa41321d52c2c7d785cc05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL forformat-0.1.6-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl
Size 746.8 kB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3337cf618a718b59628ff2f81546ee33faade4234deea464190efa710808be63
BLAKE2b-256 checksum
How to use checksums
adc61bbb2472773422d351e9bce2b6476cc5772d076ff592f285d958104156b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL forformat-0.1.6-py3-none-macosx_11_0_arm64.whl
Size 660.1 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3e9376fc637efe32bf2b058cfeb65572e7b59230873897e8bf3f2cea82aaad87
BLAKE2b-256 checksum
How to use checksums
30db91d54adfb76fb54b90755b857b5904fb3616ab8ea80a6e1eed1b3fcf026d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL forformat-0.1.6-py3-none-macosx_10_12_x86_64.whl
Size 729.9 kB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e7083e0e8503481fbb38670f35aa2e55faff38a0b41760d10d5818c390e20900
BLAKE2b-256 checksum
How to use checksums
41a38b3e7f9c2b1b1a58ae937a8ddb9fe281c2eb879b908b09e994113e91794f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

Security for forformat 0.1.6

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for forformat-0.1.6-py3-none-win_arm64.whl

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 Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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