Skip to main content

reef-il

Refill prose in Python source to the configured line length: full-line # comments, and with --docstrings the body paragraphs of docstrings. A pre-commit hook for the gap ruff leaves open: E501 flags lines that run past the limit, but nothing flags prose wrapped well short of it.

Install

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/teosibileau/reef-il
    rev: v0.1.0
    hooks:
      - id: reef-il

Place it before the ruff hooks so E501 sees the refilled result. The line length comes from [tool.ruff] line-length in the nearest pyproject.toml, then [tool.black], then 88. Pass args: [--line-length, "120"] to override.

The command also runs on its own:

reef-il src/**/*.py          # rewrite, exit 1 if anything changed
reef-il --check src/**/*.py  # report only

What it does

Consecutive full-line comments with the same indentation form a paragraph. Each paragraph is rewrapped to the line length, so a comment broken earlier than necessary is joined and one that runs past the limit is split.

Before, in a repo set to 120 columns:

# orig_iat was the original issue time at refresh; simplejwt has iat
# per token, but legacy consumers may look for orig_iat specifically.

After:

# orig_iat was the original issue time at refresh; simplejwt has iat per token, but legacy consumers may look
# for orig_iat specifically.

Two join rules

By default a line is joined to the next only when the break is mid-sentence: the line does not end in ., ! or ?, and the next line does not start with a capital letter or @. One-thought-per-line notes survive:

# Create the deactivated periodic task
# Activate locally/staging/prod as required and remove from crontab on server

The cost is a missed join where a sentence happens to end exactly at the old wrap. --greedy drops the sentence rules and joins every adjacent line that fits, the way fill-paragraph does in an editor.

What it never touches

  • Inline comments after code, and # inside strings. Comments are found with the tokenizer.
  • Shebangs, coding lines, #: attribute docs, and bare #.
  • Suppression directives: noqa, type:, fmt:, pragma, ruff:, isort:, pylint:, pyright:, mypy:.
  • Banners such as # ---- and # -- title ----.
  • List items, TODO/FIXME/NOTE markers, and comments indented deeper than their paragraph, such as code samples.

A line ending in : closes its paragraph. Files that fail to tokenize are left unchanged, and CRLF line endings are preserved.

Docstrings

--docstrings (pass it as args: [--docstrings] in the hook) also rewraps the plain prose paragraphs of docstrings, under the same join rules. It is deliberately narrow:

  • Only """ docstrings that span several lines with the closing quotes on their own line. One-liners, ''' and raw strings are skipped.
  • The summary line is never touched, even when it overflows.
  • Rewrapping stops at the first section header (Args:, Returns:, a NumPy underlined header), Sphinx field (:param x:), directive (.. note::) or doctest (>>>). Everything from there on is left as it is.
  • Paragraphs indented deeper than the docstring, such as code after ::, tables and continuation lines, are left alone.

Treat it as experimental. Docstrings carry far more structure than comments, and the rules above are heuristics, not a parser for any docstring style. Review the diff the first time you run it on a codebase, and expect the description under Args: and friends to stay as it is until section-aware wrapping lands.

Development

uv sync
uv run pytest
pre-commit run --all-files

Releasing

Bump version in pyproject.toml, merge to main, then tag and push:

git tag v0.2.0 && git push origin v0.2.0

The release workflow checks the tag against the version, builds and smoke tests the wheel, publishes to PyPI through trusted publishing, and creates the GitHub release with the artifacts attached.

Metadata

Release files for reef-il 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reef-il 0.1.0
File Size Uploaded Provenance Actions
reef_il-0.1.0.tar.gz 21.4 kB Without provenance Details for reef_il-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for reef-il 0.1.0
File Interpreter ABI Platform Actions
reef_il-0.1.0-py3-none-any.whl Python 3 none any Details for reef_il-0.1.0-py3-none-any.whl

Total release size: 30.6 kB

Release files / reef_il-0.1.0.tar.gz

Download URL reef_il-0.1.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c95415a374d3bb8cc0bae4d77ef777c7a23a622dc950bddea783a1d3adcb3323
BLAKE2b-256 checksum
How to use checksums
b6d29070c154e18e3b4b88b5f46770ba7fe4a163781a3047587684cbef5a14f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / reef_il-0.1.0-py3-none-any.whl

Download URL reef_il-0.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1da6536e261c6c13f712358bfbbf916bbc624ffa594949d9a6b82f74abd387b5
BLAKE2b-256 checksum
How to use checksums
3ee84eebb49d5174848d351e4c14bcb80db5a5b5b70df9cac419b9495b9d8c44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for reef-il 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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