Skip to content

Instantly share code, notes, and snippets.

@kstrauser
Last active March 18, 2023 00:24
Show Gist options
  • Select an option

  • Save kstrauser/c0cf3c440c3bffed60cb8e85de7f6649 to your computer and use it in GitHub Desktop.

Select an option

Save kstrauser/c0cf3c440c3bffed60cb8e85de7f6649 to your computer and use it in GitHub Desktop.

Revisions

  1. kstrauser revised this gist May 24, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions black.md
    Original file line number Diff line number Diff line change
    @@ -31,9 +31,10 @@ Open your user settings and add:
    "editor.rulers": [
    99
    ],
    "black.path": "/Users/kirk/.local/share/virtualenvs/black-wkc_P2WA/bin/black",
    "python.formatting.provider": "none",
    },
    "black.lineLength": 99,
    "black.path": "/Users/kirk/.local/share/virtualenvs/black-wkc_P2WA/bin/black",
    "python.formatting.provider": "none",
    ```

    # Profit
  2. kstrauser revised this gist May 24, 2018. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions black.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,10 @@
    # Make a Python 3.6 virtual for running Black
    This is how to use the [Black](https://pypi.org/project/black/) Python code formatter in VS Code.

    I had to give a specific version of [black](https://pypi.org/project/black/) this morning. I didn't yesterday. Don't specify the version unless it makes you.
    # Make a Python 3.6 virtualenv for running Black

    Black itself requires Python 3.6 to run, but few of our projects are on that version. The VS Code plugin conveniently lets you run black from its own virtualenv.

    I had to give a specific version of black this morning. I didn't yesterday. Don't specify the version unless it makes you (and if you do, give the current version, not the one from this doc).

    ```shell
    $ cd ~/Envs
  3. kstrauser created this gist May 24, 2018.
    37 changes: 37 additions & 0 deletions black.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    # Make a Python 3.6 virtual for running Black

    I had to give a specific version of [black](https://pypi.org/project/black/) this morning. I didn't yesterday. Don't specify the version unless it makes you.

    ```shell
    $ cd ~/Envs
    $ mkdir black
    $ cd black
    $ pipenv --python 3.6
    $ pipenv install black==18.5b0
    $ pipenv run which black
    /Users/kirk/.local/share/virtualenvs/black-wkc_P2WA/bin/black
    ```

    Take note of that last line!

    # Install the VS Code plugin for Black

    https://marketplace.visualstudio.com/items?itemName=joslarson.black-vscode

    # Configure the plugin

    Open your user settings and add:

    ```
    "[python]": {
    "editor.rulers": [
    99
    ],
    "black.path": "/Users/kirk/.local/share/virtualenvs/black-wkc_P2WA/bin/black",
    "python.formatting.provider": "none",
    },
    ```

    # Profit

    Now you can use the command palette to run "Format Document" to run Black on the current file. Down the road, we can set `"editor.formatOnSave": true` to automatically run it every time you save a file.