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

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

Example profile

This profile mirrors the indentation settings used by CAMB. 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.1-py3-none-win_amd64.whl (487.5 kB view details)

Uploaded Python 3Windows x86-64

forformat-0.1.1-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl (624.3 kB view details)

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

forformat-0.1.1-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl (582.6 kB view details)

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

forformat-0.1.1-py3-none-macosx_11_0_arm64.whl (500.6 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

forformat-0.1.1-py3-none-macosx_10_12_x86_64.whl (540.2 kB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: forformat-0.1.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 487.5 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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1999ddf89aa573501764d89ce0163c8b12ed950254c3b953b780ef8a7f424e96
MD5 70a11f2f51c88dce8f3bd18cf9e1177e
BLAKE2b-256 ef27f503ab2f67675f4bfccfc834b54b0be9d91b263e26c58987186f67c4e144

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for forformat-0.1.1-py3-none-manylinux_2_17_x86_64.musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 28eaf28f129307a4f07db356f496cdf2530c44b0373789276263523a1e961987
MD5 2b08cf21fbad9eaa0eb827ddaf8c1c42
BLAKE2b-256 29a1057801ff28e1c489fc8955449e759fcbe47b6e9e86652c824869280152bd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for forformat-0.1.1-py3-none-manylinux_2_17_aarch64.musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 fbc2093a92ecb52f6f5e4c8cea71e24903d62a68ba21ffff81142a3944a53d31
MD5 01a4fecab9c4408834ce53004f624637
BLAKE2b-256 fa02ea7d00b0a91feec21dd9cf4074ac7a07ba7346a22806a3ac9674073aa2ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for forformat-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c693e21f50576abf69afddef687ddb7edf404faf349db8bdd8ea8a4fa8292be
MD5 a882566a1b3b471562a6e6d01c1741c2
BLAKE2b-256 ae546270d7407eb3582cb2e3f86b85b2dc31cb64e8f8f7f1201f5139e8abb6d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for forformat-0.1.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8b1f0e0d5f1e0d2a532e36a58ddb76901a7f91e7237300acf245aca4c0527eaa
MD5 1b90dad574eeeebac6744f5dcbf97319
BLAKE2b-256 a27c8d42ca89cb378b668f5b99f2875df5466cb0f2a980fd1a4657b168865f7d

See more details on using hashes here.

Provenance

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