Skip to main content

Format Blocks

Format Blocks is a Python library for building code formatters.

Usage

Format Blocks provides a number of 'block' objects which know how to arrange text in various ways, such as LineBlock which arranges elements on one line, and StackBlock which stacks them across lines, and WrapBlock which wraps inserts line breaks at the margin.

However, the most import block is ChoiceBlock. ChoiceBlock accepts multiple formatting options, and allows for the solver to pick the choices which minimize the overall formatting cost.

See the tests for some examples!

Origins

Format Blocks is a fork of the guts of Google's R Formatter, rfmt. Rfmt was structured as a formatting library with an R implementation, almost entirely decoupled. To create Format Blocks, I just did some final decoupling, then polished up the code and wrote some extra features and tests.

Metadata

Release files for format-blocks 0.1.2

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

Source distribution (sdist)

Source distribution for format-blocks 0.1.2
File Size Uploaded
format-blocks-0.1.2.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for format-blocks 0.1.2
File Interpreter ABI Platform
format_blocks-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 37.3 kB

Release files / format-blocks-0.1.2.tar.gz

Download URL format-blocks-0.1.2.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
acd810bed065989b7e07a071fb13e8eafcebb91fb674a03bb428cd55d882ca59
BLAKE2b-256 checksum
How to use checksums
02ad81396b2384846c3e69ffc63527538d249c00442e2c9d7d7f39dc5ae46a93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.0 Darwin/19.6.0

Release files / format_blocks-0.1.2-py3-none-any.whl

Download URL format_blocks-0.1.2-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2c226e160b2189c4789340737d9adb494a9869e4b18b7e21b20a6353e56da85
BLAKE2b-256 checksum
How to use checksums
78d5ddeae1cc145a30b3e8aa6a15f69bb306cbc34910d375087258386456a6cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.10 CPython/3.8.0 Darwin/19.6.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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