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

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

Total release size: 4.4 MB

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

Download URL forformat-0.1.7-py3-none-win_arm64.whl
Size 636.7 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
b3132277ac99ab35e795df7fbaecaab3fe997284f5dee56a4844dea324d8a963
BLAKE2b-256 checksum
How to use checksums
6e386e3c6a6e5349d7530dfddc00dd01020507aa4893d8d7407680d677c21330
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 Nov 1, 2026.

Transparency log

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

Download URL forformat-0.1.7-py3-none-win_amd64.whl
Size 702.7 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
5880fa21118d0df216a2921df9c480fa91ac916fe5d6b9a856ed6a6fabdacbb8
BLAKE2b-256 checksum
How to use checksums
bb3baed55cd07a19e58aef85f93ffab5d47861d85a7d46ae3da13052865e73a9
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 Nov 1, 2026.

Transparency log

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

Download URL forformat-0.1.7-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl
Size 837.4 kB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f04acbceee86454b6ab6e07140c6f9207986ad83d38c7be06713983512302c02
BLAKE2b-256 checksum
How to use checksums
18ba7bd4e0fc6837f7d665280e6e86410ed74e0ae030f925c4f47bb5c1796a3e
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 Nov 1, 2026.

Transparency log

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

Download URL forformat-0.1.7-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl
Size 762.2 kB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
1ef58abefc41a9a7b8ae4f1360e3759d123c9bab29abecea586a1aa929b10550
BLAKE2b-256 checksum
How to use checksums
e743e2570ebd2501971dc38c12cf1a7447b4539639e1308c3bda3684fe1f03f2
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 Nov 1, 2026.

Transparency log

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

Download URL forformat-0.1.7-py3-none-macosx_11_0_arm64.whl
Size 674.4 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3ee163ae86ea12017f86196a1a54b180a9e6c415ea66b33349fd50e6b4336e4d
BLAKE2b-256 checksum
How to use checksums
97873a49fea084bef2e153b1d3af2556fb3c1708b1b42249c775ede9f33006a4
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 Nov 1, 2026.

Transparency log

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

Download URL forformat-0.1.7-py3-none-macosx_10_12_x86_64.whl
Size 745.8 kB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
513a1c115a6ed14549c38bd07a30fbb70d38f09cc76c9e59b4bc50cd2d7e4383
BLAKE2b-256 checksum
How to use checksums
24d877dff130dd7f046676a73a4b475265c18441034fd573d5ce60bfc343807b
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 Nov 1, 2026.

Transparency log

Security for forformat 0.1.7

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.7-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 Nov 1, 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