Skip to content

Commit 342f3e7

Browse files
Add prettier to pre-commit and apply it
1 parent 4aa1d55 commit 342f3e7

File tree

4 files changed

+57
-38
lines changed

4 files changed

+57
-38
lines changed

.github/CONTRIBUTING.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Use `pre-commit install` to install the pre-commit hook for the repository.
66

77
### Creating a new formatter
88

9-
- Implement a Formatter by inheriting from ``pydocstringformatter.formatting.Formatter``
10-
- Add your new formatter to ``pydocstringformatter.formatting.FORMATTERS``
11-
- Choose a proper name because this will be user-facing: the name will be used for options of the CLI.
9+
- Implement a Formatter by inheriting from `pydocstringformatter.formatting.Formatter`
10+
- Add your new formatter to `pydocstringformatter.formatting.FORMATTERS`
11+
- Choose a proper name because this will be user-facing: the name will be used for
12+
options of the CLI.
1213

1314
### Testing
1415

@@ -18,9 +19,12 @@ To run all the tests:
1819
pytest
1920
```
2021

21-
To create test for a specific formatting option use the `tests/data/format` directory. For each `.py` file create a `.py.out` file with the expected output after formatting. The test suite will automatically pickup the new tests.
22+
To create test for a specific formatting option use the `tests/data/format` directory.
23+
For each `.py` file create a `.py.out` file with the expected output after formatting.
24+
The test suite will automatically pickup the new tests.
2225

23-
To only run a specific test from that directory, for example `tests/data/format/multi_line/class_docstring.py`, use:
26+
To only run a specific test from that directory, for example
27+
`tests/data/format/multi_line/class_docstring.py`, use:
2428

2529
```shell
2630
pytest -k multi_line-class_docstring

.pre-commit-config.yaml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
exclude: "tests/data"
22
repos:
3-
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
44
rev: v4.1.0
55
hooks:
6-
- id: trailing-whitespace
7-
- id: end-of-file-fixer
8-
- id: check-yaml
9-
- id: check-toml
10-
- repo: https://github.com/myint/autoflake
6+
- id: trailing-whitespace
7+
- id: end-of-file-fixer
8+
- id: check-yaml
9+
- id: check-toml
10+
- repo: https://github.com/myint/autoflake
1111
rev: v1.4
1212
hooks:
1313
- id: autoflake
@@ -17,37 +17,42 @@ repos:
1717
- --expand-star-imports
1818
- --remove-duplicate-keys
1919
- --remove-unused-variables
20-
- repo: https://github.com/asottile/pyupgrade
20+
- repo: https://github.com/asottile/pyupgrade
2121
rev: v2.31.0
2222
hooks:
2323
- id: pyupgrade
2424
args: [--py38-plus]
25-
- repo: https://github.com/PyCQA/isort
25+
- repo: https://github.com/PyCQA/isort
2626
rev: 5.10.1
2727
hooks:
2828
- id: isort
29-
- repo: https://github.com/psf/black
29+
- repo: https://github.com/psf/black
3030
rev: 21.12b0
3131
hooks:
3232
- id: black
3333
args: [--quiet]
34-
- repo: https://github.com/PyCQA/flake8
34+
- repo: https://github.com/PyCQA/flake8
3535
rev: 4.0.1
3636
hooks:
3737
- id: flake8
3838
additional_dependencies: [flake8-typing-imports==1.10.1]
39-
- repo: https://github.com/pycqa/pylint
39+
- repo: https://github.com/pycqa/pylint
4040
rev: v2.12.2
4141
hooks:
42-
- id: pylint
42+
- id: pylint
4343
args: ["--disable=import-error, cyclic-import"]
44-
- repo: https://github.com/pre-commit/mirrors-mypy
44+
- repo: https://github.com/pre-commit/mirrors-mypy
4545
rev: v0.930
4646
hooks:
47-
- id: mypy
47+
- id: mypy
4848
args: [--ignore-missing-imports]
4949
additional_dependencies: [pytest-stub==1.1.0]
50-
- repo: https://github.com/DanielNoord/pydocstringformatter
50+
- repo: https://github.com/DanielNoord/pydocstringformatter
5151
rev: v0.2.0
5252
hooks:
53-
- id: pydocstringformatter
53+
- id: pydocstringformatter
54+
- repo: https://github.com/pre-commit/mirrors-prettier
55+
rev: v2.5.1
56+
hooks:
57+
- id: prettier
58+
args: [--prose-wrap=always, --print-width=88]

.pre-commit-hooks.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- id: pydocstringformatter
2-
name: pydocstringformatter
3-
entry: pydocstringformatter
4-
language: python
5-
args: ["--write"]
1+
- id: pydocstringformatter
2+
name: pydocstringformatter
3+
entry: pydocstringformatter
4+
language: python
5+
args: ["--write"]

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pydocstringformatter.svg)](https://pypi.python.org/pypi/pydocstringformatter/) [![Coverage Status](https://coveralls.io/repos/github/DanielNoord/pydocstringformatter/badge.svg?branch=main)](https://coveralls.io/github/DanielNoord/pydocstringformatter?branch=main) [![Tests](https://github.com/DanielNoord/pydocstringformatter/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/DanielNoord/pydocstringformatter/actions/workflows/tests.yaml) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/DanielNoord/pydocstringformatter/main.svg)](https://results.pre-commit.ci/latest/github/DanielNoord/pydocstringformatter/main)
1+
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pydocstringformatter.svg)](https://pypi.python.org/pypi/pydocstringformatter/)
2+
[![Coverage Status](https://coveralls.io/repos/github/DanielNoord/pydocstringformatter/badge.svg?branch=main)](https://coveralls.io/github/DanielNoord/pydocstringformatter?branch=main)
3+
[![Tests](https://github.com/DanielNoord/pydocstringformatter/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/DanielNoord/pydocstringformatter/actions/workflows/tests.yaml)
4+
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/DanielNoord/pydocstringformatter/main.svg)](https://results.pre-commit.ci/latest/github/DanielNoord/pydocstringformatter/main)
25

36
# Pydocstringformatter
47

5-
A tool to automatically format Python docstrings that tries to follow recommendations from [`PEP 8`](https://www.python.org/dev/peps/pep-0008/) and [`PEP 257`](https://www.python.org/dev/peps/pep-0257/). See [What it does](#what-it-does) for currently supported auto-formatting.
8+
A tool to automatically format Python docstrings that tries to follow recommendations
9+
from [`PEP 8`](https://www.python.org/dev/peps/pep-0008/) and
10+
[`PEP 257`](https://www.python.org/dev/peps/pep-0257/). See
11+
[What it does](#what-it-does) for currently supported auto-formatting.
612

713
## How to install
814

@@ -26,24 +32,28 @@ options:
2632

2733
### Configuration
2834

29-
Pydocstringformatter will also read any configuration added to the `[tool.pydocstringformatter]` section of a `pyproject.toml` file.
35+
Pydocstringformatter will also read any configuration added to the
36+
`[tool.pydocstringformatter]` section of a `pyproject.toml` file.
3037

3138
## Pre-commit
3239

33-
Pydocstringformatter can also be used as a [pre-commit hook](https://pre-commit.com). Add the following to your `.pre-commit-config.yaml` file:
40+
Pydocstringformatter can also be used as a [pre-commit hook](https://pre-commit.com).
41+
Add the following to your `.pre-commit-config.yaml` file:
3442

3543
```yaml
36-
- repo: https://github.com/DanielNoord/pydocstringformatter
37-
rev: SPECIFY VERSION HERE
38-
hooks:
39-
- id: pydocstringformatter
44+
- repo: https://github.com/DanielNoord/pydocstringformatter
45+
rev: SPECIFY VERSION HERE
46+
hooks:
47+
- id: pydocstringformatter
4048
```
4149
4250
## What it does
4351
44-
The following examples show what pydocstringformatter will pick up on. All _bad_ examples will be rewritten to follow the _good_ patterns.
52+
The following examples show what pydocstringformatter will pick up on. All _bad_
53+
examples will be rewritten to follow the _good_ patterns.
4554
46-
**PEP 8: _Note that most importantly, the """ that ends a multiline docstring should be on a line by itself:_**
55+
**PEP 8: _Note that most importantly, the """ that ends a multiline docstring should be
56+
on a line by itself:_**
4757
4858
```python
4959
# Bad
@@ -56,7 +66,6 @@ multi-line docstring
5666
"""
5767
```
5868

59-
6069
**PEP 256: _The closing quotes are on the same line as the opening quotes_**
6170

6271
For consistency this rule also gets applied to multi-line docstrings
@@ -86,4 +95,5 @@ multi-line docstring
8695

8796
## Development
8897

89-
For development and contributing guidelines please see [`Contributing`](https://github.com/DanielNoord/pydocstringformatter/blob/main/.github/CONTRIBUTING.md).
98+
For development and contributing guidelines please see
99+
[`Contributing`](https://github.com/DanielNoord/pydocstringformatter/blob/main/.github/CONTRIBUTING.md).

0 commit comments

Comments
 (0)