mo-black


Namemo-black JSON
Version 22.364.23070 PyPI version JSON
download
home_pagehttps://github.com/klahnakoski/mo-black
SummaryMore Black! Denser Black formatting
upload_time2023-03-11 20:14:38
maintainer
docs_urlNone
authorVarious
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            
# More Black! - Denser Black formatting

This is s a fork of [the Black code formatter](https://github.com/psf/black)

### Requires Python 3.7

The old version of Black depends on a number of binaries, each particular to Python 3.7. 

### Problem

I love Black formatting because I agree with its formatting choices, but it does have one pathology: [Excessive indenting on data structures](https://github.com/psf/black/issues/626)

Here is an example of Black formatting; many lines are wasted on lonely brackets:  

```python
my_method(
    [
        {
            "name": "a",
            "value": 42
        }
    ]
)
```

## Solution: More Black!

When there is only one property (or list item, or parameter), then do not make a new line.

```python
my_method([{
    "name": "a",
    "value": 42
}])
```


## Usage

Please [read the official Black documentation at time of fork](https://github.com/psf/black/blob/537ea8df35b1004bdb228b483907fb5dd92e5257/README.md#usage)

    pip install mo-black


## More about this fork

The `right_hand_split()` function has [additional code](https://github.com/klahnakoski/mo-black/blob/25e1fd648530279dffbf701721df76d52213651a/src/black/__init__.py#L4786) that attempts to identify "simple" structures inside brackets. If it is simple, then block the multiline formatting and, recurse into deeper brackets to find something more complicated to split.

## Development



Be sure you are in the `mo-black` main directory

Setup virtual environment

    python -m venv .venv
    source .venv/bin/activate

Install requirements 

    pip-compile --output-file=packaging/requirements.txt packaging/requirements.in
    pip install -r packaging/requirements.txt
    pip install -r tests/requirements.txt

Set some environment variables

    export PYTHONPATH=.

Run the tests 

    python -m unittest tests/test_black.py

Here is the same for Windows...

    c:\Python38\python -m pip install virtualenv
    c:\Python38\python -m virtualenv .venv             
    .venv\Scripts\activate
    pip install -r packaging\requirements.txt
    pip install -r tests\requirements.txt
    set PYTHONPATH=.
    python -m unittest tests\test_black.py


### Development Installation

You can install `mo-black` from the main directory

    python.exe -m pip install .

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/klahnakoski/mo-black",
    "name": "mo-black",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Various",
    "author_email": "kyle@lahnakoski.com",
    "download_url": "",
    "platform": null,
    "description": "\r\n# More Black! - Denser Black formatting\r\n\r\nThis is s a fork of [the Black code formatter](https://github.com/psf/black)\r\n\r\n### Requires Python 3.7\r\n\r\nThe old version of Black depends on a number of binaries, each particular to Python 3.7. \r\n\r\n### Problem\r\n\r\nI love Black formatting because I agree with its formatting choices, but it does have one pathology: [Excessive indenting on data structures](https://github.com/psf/black/issues/626)\r\n\r\nHere is an example of Black formatting; many lines are wasted on lonely brackets:  \r\n\r\n```python\r\nmy_method(\r\n    [\r\n        {\r\n            \"name\": \"a\",\r\n            \"value\": 42\r\n        }\r\n    ]\r\n)\r\n```\r\n\r\n## Solution: More Black!\r\n\r\nWhen there is only one property (or list item, or parameter), then do not make a new line.\r\n\r\n```python\r\nmy_method([{\r\n    \"name\": \"a\",\r\n    \"value\": 42\r\n}])\r\n```\r\n\r\n\r\n## Usage\r\n\r\nPlease [read the official Black documentation at time of fork](https://github.com/psf/black/blob/537ea8df35b1004bdb228b483907fb5dd92e5257/README.md#usage)\r\n\r\n    pip install mo-black\r\n\r\n\r\n## More about this fork\r\n\r\nThe `right_hand_split()` function has [additional code](https://github.com/klahnakoski/mo-black/blob/25e1fd648530279dffbf701721df76d52213651a/src/black/__init__.py#L4786) that attempts to identify \"simple\" structures inside brackets. If it is simple, then block the multiline formatting and, recurse into deeper brackets to find something more complicated to split.\r\n\r\n## Development\r\n\r\n\r\n\r\nBe sure you are in the `mo-black` main directory\r\n\r\nSetup virtual environment\r\n\r\n    python -m venv .venv\r\n    source .venv/bin/activate\r\n\r\nInstall requirements \r\n\r\n    pip-compile --output-file=packaging/requirements.txt packaging/requirements.in\r\n    pip install -r packaging/requirements.txt\r\n    pip install -r tests/requirements.txt\r\n\r\nSet some environment variables\r\n\r\n    export PYTHONPATH=.\r\n\r\nRun the tests \r\n\r\n    python -m unittest tests/test_black.py\r\n\r\nHere is the same for Windows...\r\n\r\n    c:\\Python38\\python -m pip install virtualenv\r\n    c:\\Python38\\python -m virtualenv .venv             \r\n    .venv\\Scripts\\activate\r\n    pip install -r packaging\\requirements.txt\r\n    pip install -r tests\\requirements.txt\r\n    set PYTHONPATH=.\r\n    python -m unittest tests\\test_black.py\r\n\r\n\r\n### Development Installation\r\n\r\nYou can install `mo-black` from the main directory\r\n\r\n    python.exe -m pip install .\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "More Black! Denser Black formatting",
    "version": "22.364.23070",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71e71d23263352c3e142f44780f5183bc6171a82a6e9b2c410c65b48e531d73d",
                "md5": "432111ef8d4d5b7bfaec29fbc1d66660",
                "sha256": "0268b80f0b859d1f0d83e8c954141fd5defb509c747c71e3399117a7c46edba2"
            },
            "downloads": -1,
            "filename": "mo_black-22.364.23070-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "432111ef8d4d5b7bfaec29fbc1d66660",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 94448,
            "upload_time": "2023-03-11T20:14:38",
            "upload_time_iso_8601": "2023-03-11T20:14:38.499452Z",
            "url": "https://files.pythonhosted.org/packages/71/e7/1d23263352c3e142f44780f5183bc6171a82a6e9b2c410c65b48e531d73d/mo_black-22.364.23070-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-11 20:14:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "klahnakoski",
    "github_project": "mo-black",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mo-black"
}
        
Elapsed time: 1.42821s