Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mirceaulinic/black
Docker image for Black
https://github.com/mirceaulinic/black
black docker docker-image python
Last synced: 11 days ago
JSON representation
Docker image for Black
- Host: GitHub
- URL: https://github.com/mirceaulinic/black
- Owner: mirceaulinic
- License: bsd-3-clause
- Created: 2019-05-07T08:03:23.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T05:50:56.000Z (over 3 years ago)
- Last Synced: 2024-10-10T20:59:19.400Z (28 days ago)
- Topics: black, docker, docker-image, python
- Language: Makefile
- Size: 4.88 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Black
Docker image for [Black](https://black.readthedocs.io/en/stable/), the
uncompromising Python code formatter.## Usage
The Docker image is on [Docker hub](https://hub.docker.com/r/mirceaulinic/black),
and you can pull it by executing ``docker pull mirceaulinic/black``. The
following instructions would use the public image.### Shell alias
In your environment, you can the define the following bash / zsh/ etc. aliases:
```bash
function black-check(){
docker run --rm -v $PWD:PWD -ti mirceaulinic/black black --fast --skip-string-normalization --check $PWD
}
```and / or:
```bash
function black-format(){
docker run --rm -v $PWD:PWD -ti mirceaulinic/black black --fast --skip-string-normalization $PWD
}
```And use them when inside your project:
```bash
$ black-format
All done! ✨ 🍰 ✨
2 files left unchanged.
```### Using [this](https://github.com/mirceaulinic/black/blob/master/Makefile) Makefile
Execute ``make black`` or ``make format`` passing the ``CODEPATH`` variable
with the absolute path to where you have the code to be checked or formatted,
e.g.,```bash
$ make format CODEPATH=/path/to/my/code
All done! ✨ 🍰 ✨
85 files left unchanged.
```The instruction above would Black-format your code found under the
``path/to/my/code`` directory. ``make black`` works in a similar way, but it
only returns whether the code passed the Black checks without updating your
code, e.g.,```bash
$ make format CODEPATH=/path/to/my/code
All done! 💥 💔 💥
2050 files would be reformatted, 593 files would be left unchanged, 4 files would fail to reformat.
Makefile:14: recipe for target 'black' failed
make: *** [black] Error 123$ echo $?
2
```*Note*:
> One detail to note is that both ``make format`` and ``make black`` are using
> the ``--skip-string-normalization`` option which tells Black to ignore the
> single quotes (by default Black prefers double quotes in the favour of
> single quotes).