Skip to main content

An uncompromising Fortran formatter, inspired by Black

Project description

Sable logo

An uncompromising Fortran formatter, inspired by Black.

"So it goes." — Kurt Vonnegut, Slaughterhouse-Five

Sable enforces one consistent style for modern free-form Fortran, so you can focus on code instead of formatting. It also supports code checks beyond formatting to identify code issues.

Installation

pip install sable-fortran

Quick Start

# Format in place (default command)
sable src/

# Equivalent explicit form
sable format src/

# Check formatting only (no writes)
sable format --check src/

# Preview formatting diff
sable format --diff src/

# Safer migration pass (layout-focused)
sable format --safe src/

Recommended CI formatting gate:

sable format --check src/

Formatting

format rewrites source into Sable's canonical style. This includes:

  • Relational operator normalization (.EQ. -> ==, etc.)
  • END keyword normalization (endif -> end if, configurable)
  • Declaration normalization (integer x -> integer :: x)
  • Deterministic spacing, indentation, wrapping, and trailing newline handling

Example:

! Before
IF(A .EQ. B)THEN
CALL compute(argument_alpha,argument_beta,argument_gamma)
ENDIF

! After
if (A == B) then

   call compute(argument_alpha, &
                argument_beta, &
                argument_gamma)

end if

Checking

check reports rule diagnostics and can apply rule fixes.

# Run all rules (style + lint)
sable check src/

# Focus on policy/lint only
sable check --rule-set lint src/

# Formatter-adjacent style rules only
sable check --rule-set style src/

# Apply safe fixes, then re-check
sable check --fix src/

# Allow unsafe fixes too
sable check --fix --unsafe-fixes src/

Rule-set notes:

  • --rule-set all (default): style + lint
  • --select takes precedence over --rule-set
  • --fix applies safe fixes
  • --unsafe-fixes enables unsafe fixes (only with --fix)

Current lint rules:

  • SBL101: Program/module is missing implicit none
  • SBL102: Procedure is missing implicit none
  • SBL103: Dummy argument is missing intent(in|out|inout)

Suppressions

Inline:

if (a .eq. b) then ! sable: ignore SBL001
end if

File-wide:

! sable: ignore-file SBL001,SBL004

Configuration

Example pyproject.toml:

[tool.sable.check]
rule_set = "all"  # style | lint | all
select = []
ignore = []
output_format = "text"   # text | json | sarif | gitlab-codequality
baseline = ".sable-baseline.json"
fix = false
unsafe_fixes = false
generate_baseline = false

CLI flags override pyproject.toml defaults.

License

MIT

Project details


Download files

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

Source Distribution

sable_fortran-0.3.3.tar.gz (70.1 kB view details)

Uploaded Source

Built Distribution

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

sable_fortran-0.3.3-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file sable_fortran-0.3.3.tar.gz.

File metadata

  • Download URL: sable_fortran-0.3.3.tar.gz
  • Upload date:
  • Size: 70.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sable_fortran-0.3.3.tar.gz
Algorithm Hash digest
SHA256 75722d40a2910f98bfdb0fece6fffd5f34c8a94c397243368b8831eacbf778b4
MD5 69007fb85bc9592975c2e7186d85b71f
BLAKE2b-256 45e229640e89c01e0df1daecb0b1d0ecdbad9084345fd8c9510603ab654c2a00

See more details on using hashes here.

Provenance

The following attestation bundles were made for sable_fortran-0.3.3.tar.gz:

Publisher: publish.yml on eirik-kjonstad/sable

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

File details

Details for the file sable_fortran-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: sable_fortran-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 53.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sable_fortran-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1257910f6cc7276603f985a4839afda1fa3fccb6e15533862e7c070dde44c959
MD5 b5469ad20e5eafa59cbc5363fdb57116
BLAKE2b-256 a02d7339a8613432ac7cf51d6e97e0c6229b210f1b6acd82f07f5c3c8f02bb52

See more details on using hashes here.

Provenance

The following attestation bundles were made for sable_fortran-0.3.3-py3-none-any.whl:

Publisher: publish.yml on eirik-kjonstad/sable

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 Pingdom Monitoring Sentry Error logging StatusPage Status page