Skip to main content

Another Uncompromising Code Formatter for Python.

Project description

StraitJacket: Another Uncompromising Code Formatter for Python

StraitJacket is a wrapper around black which implements post processing to perform automatic code alignment.

Project/Repo:

MIT License Supported Python Versions PyCalVer v201812.0007-alpha PyPI Version PyPI Downloads

Code Quality/CI:

Type Checked with mypy Code Style: sjfmt Code Coverage Build Status

Name role since until
Manuel Barkhau (mbarkhau@gmail.com) author/maintainer 2018-10 -

Alignment

Example of automatic alignment.

class TokenType(enum.Enum):           # class TokenType(enum.Enum):

    INDENT    = 0                     #     INDENT = 0
    SEPARATOR = 1                     #     SEPARATOR = 1
    CODE      = 2                     #     CODE = 2


Indent      = str                     # Indent = str
RowIndex    = int                     # RowIndex = int
ColIndex    = int                     # ColIndex = int
OffsetWidth = int                     # OffsetWidth = int
TokenTable  = typ.List[TokenRow]      # TokenTable = typ.List[TokenRow]

Usage

Usage is exactly the same as for black, except that the command is named sjfmt.

$ pip install straitjacket
$ sjfmt --help
Usage: sjfmt [OPTIONS] [SRC]...

  Another uncompromising code formatter.

Options:
  -l, --line-length INTEGER       How many characters per line to allow.
                                  [default: 88]
  --py36                          Allow using Python 3.6-only syntax on all

Editors

Plugins for your editor usually support setting a custom path to black. You can simply point to sjfmt instead.

Unix

$ which sjfmt
/home/user/miniconda3/envs/py36/bin/sjfmt
$ which sjfmtd
/home/user/miniconda3/envs/py36/bin/sjfmtd

Windows

C:\Users\Username>where sjfmt
C:\Python37\Scripts\sjfmt.exe

or

PS C:\Users\ManuelBarkhau> (gcm sjfmt).Path
C:\Python37\Scripts\sjfmt.exe

[sublack]:

{
      "black_command": "C:/Python37/Scripts/sjfmt.exe",
      "black_line_length": 100,
      // ...
}

Changelog for straitjacket

v201812.0007-alpha

TLDR: more bugfixes and updated documentation

v201812.0006-alpha

TLDR: no major changes, just bug fixes.

  • Fixed #1: Disable right alignment of numbers when not preceded by a number.
  • Fixed #3: Disable alignment when preceded by a multiline string.
  • Fixed #4: Excessive whitespace in non aligned context.
  • Fixed #8: Double and single quotes around strings not consistent

v201810.0004-alpha

  • Initial release

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

straitjacket-201812.7a0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

straitjacket-201812.7a0-py36.py37-none-any.whl (11.6 kB view details)

Uploaded Python 3.6 Python 3.7

File details

Details for the file straitjacket-201812.7a0.tar.gz.

File metadata

  • Download URL: straitjacket-201812.7a0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for straitjacket-201812.7a0.tar.gz
Algorithm Hash digest
SHA256 4aa85764a55d57b61f6beb6280c359b919e7f7bafd33f77ef5eb2f2a944dbb64
MD5 53fcda9ea5df9d251ec6082672940424
BLAKE2b-256 059b0f1f2a09872ac9fb48575c92d190360e64ffe5afbcf8b73084ac9600ae9f

See more details on using hashes here.

File details

Details for the file straitjacket-201812.7a0-py36.py37-none-any.whl.

File metadata

  • Download URL: straitjacket-201812.7a0-py36.py37-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3.6, Python 3.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for straitjacket-201812.7a0-py36.py37-none-any.whl
Algorithm Hash digest
SHA256 bd50d56197e73fdbbab6388916508ab37d9d68ea231ab310efce040ad831a3a3
MD5 2ffebf98d4d8395814270ba034dae2c7
BLAKE2b-256 7b379e13c1e464e93a102814f5e31cd4b7af638ae7a94be362eb94ac9b2282f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page