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:
Code Quality/CI:
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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for straitjacket-201812.7a0-py36.py37-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd50d56197e73fdbbab6388916508ab37d9d68ea231ab310efce040ad831a3a3 |
|
MD5 | 2ffebf98d4d8395814270ba034dae2c7 |
|
BLAKE2b-256 | 7b379e13c1e464e93a102814f5e31cd4b7af638ae7a94be362eb94ac9b2282f2 |