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.2-py3-none-win_amd64.whl (507.3 kB view details)

Uploaded Python 3Windows x86-64

forformat-0.1.2-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl (645.1 kB view details)

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

forformat-0.1.2-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl (600.4 kB view details)

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

forformat-0.1.2-py3-none-macosx_11_0_arm64.whl (517.4 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

forformat-0.1.2-py3-none-macosx_10_12_x86_64.whl (561.2 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: forformat-0.1.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 507.3 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.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 99a744c23571830295d481e10ee23b366d7770afa64175a099cb287fddf8d561
MD5 daa21c6591c6e187612c12188affcd5b
BLAKE2b-256 35d719f0c2e767ddf29a78d7db36c4cb6a6c1f84ec5cf3c16d10b42e8c895737

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.2-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.2-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for forformat-0.1.2-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 bfcdd0d9d3d590eeac8678783691302e42f734070c3e6cab1868d45c4b9e6595
MD5 c047ef9f23505be17ca21c8500e5ef06
BLAKE2b-256 0b6c6e7082e6f1a187a208dbb8c355e6bb5fbb67630ce9b95b3191a3041117a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.2-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.2-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for forformat-0.1.2-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 40f84c51192573f4df3938d405ccd0dab77f56f3b60736ac6a2c7fcee0f4d18d
MD5 19224bb3df8c673983c4c0a7bc923494
BLAKE2b-256 4ef9786e3f32a576dab34d4580eb40677d3ab9badb6b3eebacab50a13c8f5d0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.2-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.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for forformat-0.1.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ff00c010edcdbd32733231f0119766e8f86d8e3e555e79db50ca26a712d59db
MD5 e26327b69594cc79ad1c833e0127edb8
BLAKE2b-256 ab1c2fe4bdb93d08110e2b06f8ec1ff1f369b2d354283e7625a2e8b9b8ff7590

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.2-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.2-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for forformat-0.1.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fe5df27c1763a60715d2961375084b366f971f57fe3e6c510a0f33e21c0c2324
MD5 ec2ddacba31df2663f99e26e9be513e4
BLAKE2b-256 287939760c31d9160696543c5d811b879b4ca9465e3e858bdd4e8af011c00c1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for forformat-0.1.2-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