Skip to content

Commit 0a9ad0c

Browse files
authored
Refresh linters & formatters (#269)
1 parent 88571c6 commit 0a9ad0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1415
-1091
lines changed

.pre-commit-config.yaml

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,86 @@
11
---
22
exclude: ^tests/test_data/
33
repos:
4-
- repo: https://github.com/pycqa/isort
5-
rev: 6.0.1
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
66
hooks:
7-
- id: isort
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
exclude: \.json$|\.ipynb$
10+
- id: requirements-txt-fixer
11+
- id: check-added-large-files
12+
args: [--maxkb=1000]
13+
- id: check-toml
14+
- id: check-yaml
15+
- id: name-tests-test
16+
args: [--pytest-test-first]
17+
exclude: ^tests/helpers\.py$
18+
- id: check-merge-conflict
819
- repo: https://github.com/jsh9/muff-pre-commit
9-
rev: 0.12.11.1
20+
rev: 0.13.2
1021
hooks:
1122
- id: muff-format
1223
args: [--config, muff.toml]
1324
- repo: https://github.com/lyz-code/yamlfix
14-
rev: 1.17.0
25+
rev: 1.18.0
1526
hooks:
1627
- id: yamlfix
28+
- repo: https://github.com/pappasam/toml-sort
29+
rev: v0.24.3
30+
hooks:
31+
- id: toml-sort-fix
32+
args:
33+
- --in-place
34+
- --sort-table-keys
35+
- --sort-inline-tables
36+
- --sort-first=name,version,dependencies,requires-python,authors,maintainers
37+
- --trailing-comma-inline-array
38+
- --sort-inline-arrays
39+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
40+
rev: v2.15.0
41+
hooks:
42+
- id: pretty-format-ini
43+
args: [--autofix]
1744
- repo: https://github.com/hukkin/mdformat
18-
rev: 0.7.22 # Use the ref you want to point at
45+
rev: 1.0.0
1946
hooks:
2047
- id: mdformat
21-
args: [--wrap, '79']
22-
additional_dependencies: [mdformat-tables]
23-
- repo: https://github.com/pre-commit/pre-commit-hooks
24-
rev: v6.0.0
48+
args: [--wrap=79, --number]
49+
additional_dependencies: [mdformat-gfm]
50+
- repo: https://github.com/jsh9/format-json
51+
rev: 0.1.2
2552
hooks:
26-
- id: end-of-file-fixer
27-
- id: trailing-whitespace
28-
- id: pretty-format-json
29-
args: [--no-ensure-ascii, --indent=4, --no-sort-keys]
30-
- repo: https://github.com/pre-commit/pre-commit
31-
rev: v4.3.0
53+
- id: format-json
54+
args:
55+
- --autofix
56+
- --no-ensure-ascii
57+
- --indent=4
58+
- --no-sort-keys
59+
- --no-eof-newline
60+
- repo: https://github.com/jsh9/markdown-heading-numbering
61+
rev: 0.1.0
3262
hooks:
33-
- id: validate_manifest
63+
- id: markdown-heading-numbering
64+
exclude: ^CHANGELOG\.md$
3465
- repo: https://github.com/jsh9/markdown-toc-creator
35-
rev: 0.0.10
66+
rev: 0.1.1
3667
hooks:
3768
- id: markdown-toc-creator
69+
exclude: ^AGENTS\.md$|^CHANGELOG\.md$
70+
- repo: https://github.com/jsh9/format-docstring
71+
rev: 0.2.3
72+
hooks:
73+
- id: format-docstring
74+
name: Format docstrings in .py files
75+
args: [--line-length=79]
76+
- id: format-docstring-jupyter
77+
name: Format docstrings in .ipynb files
78+
args: [--line-length=79]
3879
- repo: https://github.com/jsh9/blank-line-after-blocks
3980
rev: 0.1.4
4081
hooks:
4182
- id: blank-line-after-blocks
42-
args: [--exclude, r"tests/|_generated\.py$"]
83+
args: [--exclude, r"tests/test_data|_generated\.py$"]
4384
- repo: local
4485
hooks:
4586
- id: copy_readme

.pre_commit_helper_scripts/copy_readme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Copy `README.md` into `docs/index.md` at every pre-commit runs"""
1+
"""Copy ``README.md`` into ``docs/index.md`` at every pre-commit runs"""
22

33
with open('README.md', encoding='UTF-8') as fp:
44
lines = fp.readlines()

AGENTS.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33
This file provides guidance to AI coding assistants when working with code in
44
this repository.
55

6-
## pydoclint Project Conventions
6+
## 1. pydoclint Project Conventions
77

8-
### Code Style
8+
### 1.1. Code Style
99

1010
- Use camelCase for function and variable names (not snake_case)
1111

12-
### Branch Naming
12+
### 1.2. Branch Naming
1313

1414
- Format: `yyyy-mm-dd-What-this-branch-does`
1515

16-
### Commit Messages & PR Titles
16+
### 1.3. Commit Messages & PR Titles
1717

1818
- Use action verbs (imperative mood), not past tense
1919
- Good: "Add feature", "Fix bug"
2020
- Bad: "Added feature", "Fixed bug"
2121

22-
## Development Commands
22+
## 2. Development Commands
2323

24-
### Testing
24+
### 2.1. Testing
2525

2626
- `pytest --tb=long .` - Run all tests with detailed traceback
2727
- `tox` - Run full test suite across multiple Python versions
2828
- `tox -e py311` - Run tests on specific Python version (py39, py310, py311,
2929
py312, py313)
3030

31-
### Code Quality
31+
### 2.2. Code Quality
3232

3333
- `mypy pydoclint/` - Type checking
3434
- `muff format --diff --config=muff.toml pydoclint tests` - Format checking
@@ -37,7 +37,7 @@ this repository.
3737
- `pydoclint --config=pyproject.toml .` - Self-check using pydoclint
3838
- `pre-commit run -a` - Run all pre-commit hooks
3939

40-
### Specialized Tox Commands
40+
### 2.3. Specialized Tox Commands
4141

4242
- `tox -e mypy` - Type checking only
4343
- `tox -e muff` - Format checking only
@@ -47,7 +47,7 @@ this repository.
4747
- `tox -e flake8-docstrings` - Docstring style checks
4848
- `tox -e pre-commit` - Pre-commit hooks (skips muff formatter)
4949

50-
### Running a Single Test
50+
### 2.4. Running a Single Test
5151

5252
Use pytest with specific test file or test function:
5353

@@ -56,12 +56,12 @@ pytest tests/test_main.py
5656
pytest tests/test_main.py::test_function_name
5757
```
5858

59-
## Architecture Overview
59+
## 3. Architecture Overview
6060

6161
Pydoclint is a Python docstring linter that checks docstring sections against
6262
function signatures. The core architecture consists of:
6363

64-
### Main Components
64+
### 3.1. Main Components
6565

6666
- **main.py**: CLI entry point using Click, handles command-line options and
6767
orchestrates linting
@@ -72,7 +72,7 @@ function signatures. The core architecture consists of:
7272
sources
7373
- **baseline.py**: Baseline functionality for gradual adoption
7474

75-
### Utils Package Structure
75+
### 3.2. Utils Package Structure
7676

7777
- **arg.py/argList.py**: Function argument representation and handling
7878
- **doc.py**: Docstring parsing and representation
@@ -86,21 +86,21 @@ function signatures. The core architecture consists of:
8686
function bodies
8787
- **visitor_helper.py**: Helper functions for the main visitor
8888

89-
### Supported Docstring Styles
89+
### 3.3. Supported Docstring Styles
9090

9191
- **Numpy**: numpydoc format
9292
- **Google**: Google-style docstrings
9393
- **Sphinx**: Sphinx/reStructuredText format
9494

95-
### Key Features
95+
### 3.4. Key Features
9696

9797
- Fast AST-based analysis (thousands of times faster than darglint)
9898
- Supports type hint checking against docstring parameter types
9999
- Class attribute documentation checking
100100
- Baseline mode for gradual adoption in existing codebases
101101
- Both standalone CLI and flake8 plugin modes
102102

103-
### Test Structure
103+
### 3.5. Test Structure
104104

105105
- `tests/data/` contains test cases organized by docstring style (google,
106106
numpy, sphinx, edge_cases)

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## [0.7.6] - 2025-10-26
4+
5+
- Changed
6+
- Updated linter and auto-formatter configurations
7+
- Made a lot of changes to fix code style; some logic was also updated per
8+
the suggestions of linters
9+
- Full diff
10+
- https://github.com/jsh9/pydoclint/compare/0.7.5...0.7.6
11+
312
## [0.7.5] - 2025-10-25
413

514
- Fixed
@@ -467,7 +476,7 @@
467476
- Added baseline file integration and 2 options:
468477
1. `--generate-baseline True` Generate baseline content, and write it to a
469478
file specified from `--baseline` option path.
470-
1. `--baseline <PATH>` Specify path to file with baseline content.
479+
2. `--baseline <PATH>` Specify path to file with baseline content.
471480
- Changed
472481
- For the `--config` option, the default value is now `pyproject.toml`.
473482
- Full diff

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ here: [https://jsh9.github.io/pydoclint](https://jsh9.github.io/pydoclint)
3939
The corresponding Github repository of _pydoclint_ is:
4040
[https://github.com/jsh9/pydoclint](https://github.com/jsh9/pydoclint)
4141

42+
<!--TOC-->
43+
4244
______________________________________________________________________
4345

4446
**Table of Contents**
4547

46-
<!--TOC-->
47-
4848
- [1. Installation](#1-installation)
4949
- [2. Usage](#2-usage)
5050
- [2.1. As a native command line tool](#21-as-a-native-command-line-tool)
@@ -63,6 +63,8 @@ ______________________________________________________________________
6363
- [4. Additional notes for users](#4-additional-notes-for-users)
6464
- [5. Notes for developers](#5-notes-for-developers)
6565

66+
______________________________________________________________________
67+
6668
<!--TOC-->
6769

6870
## 1. Installation

docs/checking_class_attributes.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Checking class attributes
22

3+
<!--TOC-->
4+
5+
______________________________________________________________________
6+
7+
**Table of Contents**
8+
9+
- [1. Numpy style](#1-numpy-style)
10+
- [2. Google style](#2-google-style)
11+
- [3. Sphinx style](#3-sphinx-style)
12+
13+
______________________________________________________________________
14+
15+
<!--TOC-->
16+
317
Class attributes are similar to function arguments. They look like this:
418

519
```python
@@ -66,7 +80,7 @@ From this example, we can see a few things:
6680

6781
1. The class attributes should be put in a different docstring section than the
6882
argument passed into the class constructor (`__init__()`)
69-
1. Both the class attributes and the input arguments to `__init__()` are in the
83+
2. Both the class attributes and the input arguments to `__init__()` are in the
7084
same docstring. (This is assuming the _pydoclint_ option
7185
`--allow-init-docstring` is `False`)
7286

docs/config_options.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ For how to actually implement these options in your commands, please read this
77
page:
88
[How to configure _pydoclint_](https://jsh9.github.io/pydoclint/how_to_config.html).
99

10-
**Table of Contents**
11-
1210
<!--TOC-->
1311

12+
______________________________________________________________________
13+
14+
**Table of Contents**
15+
1416
- [1. `--quiet` (shortform: `-q`)](#1---quiet-shortform--q)
1517
- [2. `--exclude`](#2---exclude)
1618
- [3. `--style`](#3---style)
@@ -38,6 +40,8 @@ page:
3840
- [25. `--show-filenames-in-every-violation-message` (shortform: `-sfn`, default: `False`)](#25---show-filenames-in-every-violation-message-shortform--sfn-default-false)
3941
- [26. `--config` (default: `pyproject.toml`)](#26---config-default-pyprojecttoml)
4042

43+
______________________________________________________________________
44+
4145
<!--TOC-->
4246

4347
## 1. `--quiet` (shortform: `-q`)

docs/how_to_config.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# How to configure _pydoclint_
22

3+
<!--TOC-->
4+
5+
______________________________________________________________________
6+
7+
**Table of Contents**
8+
9+
- [1. All configuration options](#1-all-configuration-options)
10+
- [2. Specifying options inline](#2-specifying-options-inline)
11+
- [3. Specifying options in a configuration file](#3-specifying-options-in-a-configuration-file)
12+
- [4. Specifying options in `.pre-commit-config.yaml`](#4-specifying-options-in-pre-commit-configyaml)
13+
14+
______________________________________________________________________
15+
16+
<!--TOC-->
17+
318
This document shows you how to configure _pydoclint_.
419

520
## 1. All configuration options

docs/how_to_ignore.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
# How to ignore certain violations
22

3-
## As a native tool
3+
<!--TOC-->
4+
5+
______________________________________________________________________
6+
7+
**Table of Contents**
8+
9+
- [1. As a native tool](#1-as-a-native-tool)
10+
- [2. As a _flake8_ plugin](#2-as-a-flake8-plugin)
11+
- [2.1. Usage with Ruff](#21-usage-with-ruff)
12+
13+
______________________________________________________________________
14+
15+
<!--TOC-->
16+
17+
## 1. As a native tool
418

519
Currently, pydoclint does not support ignoring certain violations as a native
620
tool. Please use it as a _flake8_ plugin to achieve that, or feel free to
721
contribute this feature.
822

9-
## As a _flake8_ plugin
23+
## 2. As a _flake8_ plugin
1024

1125
In _flake8_ mode (meaning that you use _pydoclint_ as a flake8 plugin), if
1226
you'd like to ignore a specific violation code (such as `DOC201` and `DOC301`)
@@ -35,7 +49,7 @@ All the usage is consistent with how you would use _flake8_. Please read the
3549
official _flake8_ documentation for full details:
3650
https://flake8.pycqa.org/en/latest/user/violations.html.
3751

38-
### Usage with [Ruff](https://github.com/astral-sh/ruff)
52+
### 2.1. Usage with [Ruff](https://github.com/astral-sh/ruff)
3953

4054
With `ruff>=0.1.3`, allowlist `DOC` codes using the
4155
[`external` setting](https://docs.astral.sh/ruff/settings/#external):

0 commit comments

Comments
 (0)