Metadata-Version: 2.1
Name: straitjacket
Version: 202107.1020
Summary: Another Uncompromising Code Formatter for Python.
Home-page: https://github.com/mbarkhau/straitjacket
Author: Manuel Barkhau
Author-email: mbarkhau@gmail.com
License: MIT
Keywords: formatter yapf black pyfmt gofmt
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Environment :: Other Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Unix
Classifier: Operating System :: POSIX
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Provides-Extra: d
License-File: LICENSE

<div align="center">
<p align="center">
  <img alt="logo" src="https://gitlab.com/mbarkhau/straitjacket/-/raw/master/logo.png">
</p>
</div>


# [StraitJacket: Another Uncompromising Code Formatter for Python][repo_ref]

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

Project/Repo:

[![MIT License][license_img]][license_ref]
[![Supported Python Versions][pyversions_img]][pyversions_ref]
[![CalVer v202107.1020][version_img]][version_ref]
[![PyPI Version][pypi_img]][pypi_ref]
[![PyPI Downloads][downloads_img]][downloads_ref]

Code Quality/CI:

[![GitHub Build Status][github_build_img]][github_build_ref]
[![GitLab Build Status][gitlab_build_img]][gitlab_build_ref]
[![Type Checked with mypy][mypy_img]][mypy_ref]
[![Code Coverage][codecov_img]][codecov_ref]
[![Code Style: sjfmt][style_img]][style_ref]


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


<!--
  To update the TOC:
  $ pip install md-toc
  $ md_toc -i gitlab README.md
-->


[](TOC)

  - [Alignment](#alignment)
  - [Usage](#usage)
  - [Editor/Tooling Integration](#editortooling-integration)
      - [sublack](#sublack)
      - [vscode python extension](#vscode-python-extension)
      - [BlackPycharm](#blackpycharm)
  - [Flake8](#flake8)

[](TOC)

## Alignment

Example of automatic alignment.

```python
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`.

```shell
$ 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
```

## Editor/Tooling Integration

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

Unix
```shell
$ which sjfmt
/home/user/miniconda3/envs/py36/bin/sjfmt
$ which sjfmtd
/home/user/miniconda3/envs/py36/bin/sjfmtd
```

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

or

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

### [sublack](https://github.com/jgirardet/sublack):

```json
{

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

Document formatting can be triggered with `Ctrl+Alt+F`.


### [vscode python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)


```json
{
    "python.formatting.provider": "black",
    "python.formatting.blackPath": "C:\\Python37\\Scripts\\sjfmt.exe",
    "python.formatting.blackArgs": [
        "--line-length", "100",
        "--py36",
        "--skip-string-normalization"
    ],
}
```

Document formatting can be triggered with `Shift+Alt+F`.


### [BlackPycharm](https://github.com/pablogsal/black-pycharm)

Install the plugin `black-pycharm`, which can be found in
`Settings > Plugins > Brows Repositories`. You may have to
restart PyCharm for the plugin to load.

To configure the path, go to `Settings > Tools > BlackPycharm
Configuration` and set `Path to Black executable` to the location
of the sjfmt binary.

You can reformat your code using `Ctrl + Shift + A` to access the
`Find Action` panel. The name of the action to format your code
is `Reformat code (BLACK)`. You may want to rebind this action,
at least in my setup the default binding didn't seem to work.


## Flake8

By the nature of this plugin, certain flake8 codes will be
violated. This is an excerpt from what you might put in your
`setup.cfg` to ignore these:

```
[flake8]
ignore =
    # No whitespace after paren open "("
    E201
    # No whitespace before paren ")"
    E202
    # Whitespace before ":"
    E203
    # Multiple spaces before operator
    E221
    # Multiple spaces after operand
    E222
    # Multiple spaces after ':'
    E241
    # Multiple spaces before keyword
    E272
    # Spaces around keyword/parameter equals
    E251
```


[repo_ref]: https://github.com/mbarkhau/straitjacket

[github_build_img]: https://github.com/mbarkhau/straitjacket/workflows/CI/badge.svg
[github_build_ref]: https://github.com/mbarkhau/straitjacket/actions?query=workflow%3ACI

[gitlab_build_img]: https://gitlab.com/mbarkhau/straitjacket/badges/master/pipeline.svg
[gitlab_build_ref]: https://gitlab.com/mbarkhau/straitjacket/pipelines

[codecov_img]: https://gitlab.com/mbarkhau/straitjacket/badges/master/coverage.svg
[codecov_ref]: https://mbarkhau.gitlab.io/straitjacket/cov

[license_img]: https://img.shields.io/badge/License-MIT-blue.svg
[license_ref]: https://gitlab.com/mbarkhau/straitjacket/blob/master/LICENSE

[mypy_img]: https://img.shields.io/badge/mypy-checked-green.svg
[mypy_ref]: https://mbarkhau.gitlab.io/straitjacket/mypycov

[style_img]: https://img.shields.io/badge/code%20style-%20sjfmt-f71.svg
[style_ref]: https://gitlab.com/mbarkhau/straitjacket/

[pypi_img]: https://img.shields.io/badge/PyPI-wheels-green.svg
[pypi_ref]: https://pypi.org/project/straitjacket/#files

[downloads_img]: https://pepy.tech/badge/straitjacket/month
[downloads_ref]: https://pepy.tech/project/straitjacket

[version_img]: https://img.shields.io/static/v1.svg?label=CalVer&message=v202107.1020&color=blue
[version_ref]: https://pypi.org/project/bumpver/

[pyversions_img]: https://img.shields.io/pypi/pyversions/straitjacket.svg
[pyversions_ref]: https://pypi.python.org/pypi/straitjacket



# Changelog for straitjacket

## v202107.1020

- Update pinned black to 21.7b0


## v202106.1019

- Remove vendored black (monkey patch instead)
- Update pinned black to 21.6b0


## v202104.1018

- Update vendored black to 21.4b2


## v202104.1017

- Update vendored black to 21.4b1


## v202008.1016

- Bugfix: Bad path handling at root level.


## v202008.1015

- Update vendored black to 20.8b1


## v202008.1014

- Vendor black from master
- Fix issue with multiprocessing/fork on MacOS


## v201910.0011-beta

- Update for release of black==19.10b0


## v201904.0010-beta

- Update for release of black==19.3b0


## 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


