Skip to main content

forformat

forformat formats free-form Fortran source files. It provides findent-compatible indentation, plus an optional full-format mode for selected lexical normalization and wrapping.

The package installs the forformat command and an importable in-memory API. It requires Python 3.9 or newer.

Install

python -m pip install forformat

Use

Format one or more Fortran files in place:

forformat src/module.f90
forformat src/*.f90

Use standard input and output in a pipeline:

forformat --stdin < src/module.f90 > /tmp/module.f90
forformat --stdout src/module.f90 > /tmp/module.f90

Or format a Python string or byte buffer directly:

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.

Use --check in CI to fail when files need formatting, or --diff to print unified diffs:

forformat --check src/*.f90
forformat --diff src/*.f90

Project context

When you pass explicit paths, forformat scans the current Git checkout for free-form Fortran sources and uses declarations from those files to resolve names while formatting. Only the paths you pass are changed. This project-aware behavior is useful when a declaration in one module controls the spelling or formatting of code in another file.

For independent file processing, use --isolated with explicit paths:

forformat --isolated src/module.f90
forformat --isolated --stdout src/module.f90 > /tmp/module.f90

Input from standard input is also processed without a repository scan:

forformat --stdin < src/module.f90 > /tmp/module.f90

Use --project-context PATH with --stdin when an editor buffer needs declarations from a Git checkout without selecting a file to format. Pass the buffer's source path to replace that file's stale on-disk contents with stdin in project analysis; pass a directory only when the buffer has no corresponding file.

Project settings can be kept in a top-level .forformat.toml, or in [tool.forformat] in a Python project's pyproject.toml. Keys use the same names as the long command-line options:

[tool.forformat]
indent = 4
line-length = 100
align-paren = true
exclude = ["vendor/"]
extend-exclude = ["**/generated-*.f90"]

--exclude=<glob> is repeatable and applies to automatic --all targets and tracked project context. Explicit paths are always formatted. The default exclusion set is empty. exclude selects the set, so --exclude on the command line replaces the configured exclude; --extend-exclude=<glob> and the extend-exclude key add to whatever is already in force. Patterns use * within one path component, ** across components, ? for one non-separator character, and a trailing / for a directory prefix. A leading / anchors at the repository root; otherwise the pattern is unanchored at path-component boundaries. Paths are matched with / separators.

Command-line options override project settings. --config PATH selects a specific file and --no-config disables configuration discovery.

Example profile

This profile demonstrates an explicit four-space indentation configuration. The final --indent-contains=restart setting is intentional; options may be written with hyphens or underscores.

forformat \
	--indent=4 \
	--indent-module=0 \
	--indent-procedure=0 \
	--start-indent=4 \
	--indent-contains=0 \
	--openmp=0 \
	--indent-contains=restart \
	--indent-select=4 \
	--indent-case=4 \
	--indent-interface=0 \
	--indent-continuation=4 \
	--indent-ampersand \
	src/*.f90

The default is --full. Use --indent-only for findent-compatible indentation and trailing whitespace handling. Run forformat --help for all options. Fixed-form Fortran and automatic format detection are not supported.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

forformat-0.1.3-py3-none-win_amd64.whl (544.7 kB view details)

Uploaded Python 3Windows x86-64

forformat-0.1.3-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl (686.4 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64musllinux: musl 1.2+ x86-64

forformat-0.1.3-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl (637.9 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64musllinux: musl 1.2+ ARM64

forformat-0.1.3-py3-none-macosx_11_0_arm64.whl (551.8 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

forformat-0.1.3-py3-none-macosx_10_12_x86_64.whl (600.2 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file forformat-0.1.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: forformat-0.1.3-py3-none-win_amd64.whl
  • Upload date:
  • Size: 544.7 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for forformat-0.1.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 27c4810155e03925e68879085fbcb7948fbc39df8843c42d5c5596d81acd325b
MD5 57dafb242586a3a030d536442af4dbe2
BLAKE2b-256 9fa26ed59dcbbf944246d6846ee07e4c7ff072edf230ac83de6ca8d10e287104

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.3-py3-none-win_amd64.whl:

Publisher: pypi.yml on cmbant/forformat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file forformat-0.1.3-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for forformat-0.1.3-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 efe65160261f4071400b71d97f3a7f2de3fb3c1dac349c05e07941f3593936ed
MD5 632ac27f120485d593056e9502f4f949
BLAKE2b-256 e60ab90ce6442c463f975b396b2ecdccaad69f946e7fc692eb71f1784863c051

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.3-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl:

Publisher: pypi.yml on cmbant/forformat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file forformat-0.1.3-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for forformat-0.1.3-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 160025ac807f2eb56cd0c70cd42fe4c331774382783c2afa4330c6e10e770ad8
MD5 5c16c079e6d24eb9acbb56bda180a484
BLAKE2b-256 9fbda85413ee738ce36a7b0e6a46ee8951b8347c860941f53fc750db66c2a12e

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.3-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl:

Publisher: pypi.yml on cmbant/forformat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file forformat-0.1.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for forformat-0.1.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9df2f69eef0e35ddee745bab8bba51c7d12440ae07b6ca3ccc11fae585c12665
MD5 2d675d97662c2f96db24580436d9cbdb
BLAKE2b-256 302ac916f50a90c4ef92ff03e11b44413eb0e47d06d7a38ff4fd0ffbebd09615

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.3-py3-none-macosx_11_0_arm64.whl:

Publisher: pypi.yml on cmbant/forformat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file forformat-0.1.3-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for forformat-0.1.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 02d364082558bc01c0a143beed79576270843f2ea637580dcb5a47a4eb595509
MD5 9552348656bae4b27edcf7e246cd7e3e
BLAKE2b-256 8019a00414c12f569b4dc882904a748de62f348c39aab10bb9f31db0956a0504

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.3-py3-none-macosx_10_12_x86_64.whl:

Publisher: pypi.yml on cmbant/forformat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page