sigdrift 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ${{ matrix.os }}
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ os: [ubuntu-latest, macos-latest, windows-latest]
18
+ python: ["3.11", "3.12", "3.13", "3.14"]
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python }}
24
+ - run: python -m pip install -e ".[test]"
25
+ - run: python -m pytest -q
@@ -0,0 +1,48 @@
1
+ name: Release
2
+
3
+ # Publishing a GitHub release tagged vX.Y.Z uploads that version to PyPI
4
+ # through trusted publishing (no API token is stored anywhere).
5
+ on:
6
+ release:
7
+ types: [published]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.13"
20
+ - name: Check the tag matches the package version
21
+ run: |
22
+ version=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
23
+ if [ "v$version" != "$GITHUB_REF_NAME" ]; then
24
+ echo "Tag $GITHUB_REF_NAME does not match version $version" >&2
25
+ exit 1
26
+ fi
27
+ - run: python -m pip install build twine
28
+ - run: python -m build
29
+ - run: python -m twine check --strict dist/*
30
+ - uses: actions/upload-artifact@v4
31
+ with:
32
+ name: dist
33
+ path: dist/
34
+
35
+ publish:
36
+ needs: build
37
+ runs-on: ubuntu-latest
38
+ environment:
39
+ name: pypi
40
+ url: https://pypi.org/project/sigdrift/
41
+ permissions:
42
+ id-token: write
43
+ steps:
44
+ - uses: actions/download-artifact@v4
45
+ with:
46
+ name: dist
47
+ path: dist/
48
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ dist/
6
+ build/
7
+ .pytest_cache/
@@ -0,0 +1,8 @@
1
+ - id: sigdrift
2
+ name: sigdrift
3
+ description: Find parameter names in Sphinx docs that the real callable rejects as keywords.
4
+ entry: sigdrift
5
+ # Needs to import your package, so it runs in your environment.
6
+ language: system
7
+ files: \.rst$
8
+ pass_filenames: false
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-12-06)
4
+
5
+ First release.
6
+
7
+ - Reads callable directives (`function`, `method`, `class`, `exception`,
8
+ `classmethod`, `staticmethod`, coroutine variants) from Sphinx `.rst` files,
9
+ following `module` / `currentmodule` and nested classes.
10
+ - Tests each documented keyword with `inspect.signature().bind_partial()`;
11
+ nothing documented is called.
12
+ - Codes: SD001 renamed parameter, SD003 unknown parameter (both default),
13
+ SD002 positional-only without `/` (opt-in).
14
+ - `[tool.sigdrift]` config: `paths`, `select`, `ignore`, `include-brackets`,
15
+ `skip-modules`, `aliases`.
16
+ - Text, JSON and GitHub annotation output; pre-commit hook.
sigdrift-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thejesh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.5
2
+ Name: sigdrift
3
+ Version: 0.1.0
4
+ Summary: Find parameter names in hand-written Sphinx docs that the real function rejects as keywords.
5
+ Project-URL: Homepage, https://github.com/thejesh23/sigdrift
6
+ Project-URL: Issues, https://github.com/thejesh23/sigdrift/issues
7
+ Project-URL: Changelog, https://github.com/thejesh23/sigdrift/blob/main/CHANGELOG.md
8
+ Author: Thejesh
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: documentation,lint,rst,signature,sphinx
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Framework :: Sphinx
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Documentation :: Sphinx
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Requires-Python: >=3.11
20
+ Provides-Extra: test
21
+ Requires-Dist: pytest>=8; extra == 'test'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # sigdrift
25
+
26
+ Find parameter names in hand-written Sphinx docs that the real function
27
+ rejects as keywords.
28
+
29
+ ```rst
30
+ .. function:: loads(data, *, fmt=None, dict_type=dict, aware_datetime=False)
31
+ ```
32
+
33
+ ```python
34
+ >>> plistlib.loads(data=b"...")
35
+ TypeError: loads() got an unexpected keyword argument 'data'
36
+ ```
37
+
38
+ The docs say `data`; the code says `value`. Anyone who copies the name from
39
+ the docs, including a code assistant, gets a `TypeError`. Docstring linters
40
+ such as docsig and pylint's `docparams` don't see this, because the signature
41
+ lives in an `.rst` file and not in a docstring. sigdrift reads those
42
+ directives, imports what they describe and asks Python whether each
43
+ documented keyword would bind.
44
+
45
+ ```console
46
+ $ python -m sigdrift Doc/library/plistlib.rst
47
+ Doc/library/plistlib.rst:85: SD001 plistlib.loads: 'data' is not accepted as a keyword; the real name is 'value'
48
+ 1 finding(s) in 5 checked signature(s); 0 unresolved, 0 without a signature
49
+ ```
50
+
51
+ ## Install
52
+
53
+ ```console
54
+ pip install sigdrift
55
+ ```
56
+
57
+ Python 3.11 or later, no dependencies. Install it into the same environment as
58
+ the package whose docs you are checking.
59
+
60
+ ## Usage
61
+
62
+ Run sigdrift **with the interpreter whose packages the docs describe**, since
63
+ it imports them to read their real signatures:
64
+
65
+ ```console
66
+ python -m sigdrift docs/ # folders are searched for *.rst
67
+ python -m sigdrift docs/api.rst --format json
68
+ python -m sigdrift docs/ --format github # annotations in GitHub Actions
69
+ ```
70
+
71
+ It exits 1 when there are findings, so it can gate CI. A
72
+ [pre-commit](https://pre-commit.com) hook is included (`id: sigdrift`).
73
+
74
+ | Code | Meaning | Default |
75
+ |---|---|---|
76
+ | SD001 | The docs name a parameter that exists under another, keyword-passable name | on |
77
+ | SD002 | The docs imply a keyword, but the real parameter is positional-only and the docs don't show `/` | off |
78
+ | SD003 | The docs name a parameter the callable does not have | on |
79
+
80
+ SD002 is opt-in (`--select SD001,SD002,SD003`): many C functions are
81
+ positional-only and their docs predate the `/` notation, so it is a much
82
+ larger, separate cleanup.
83
+
84
+ ### Options and configuration
85
+
86
+ ```toml
87
+ [tool.sigdrift]
88
+ paths = ["Doc"]
89
+ select = ["SD001", "SD003"]
90
+ # fnmatch patterns over "module.name" or "module.name:param"
91
+ ignore = [
92
+ "urllib.parse.urlsplit:urlstring", # name chosen on purpose
93
+ "decimal.*",
94
+ ]
95
+ include-brackets = false # also check old-style [optional] parameters
96
+ skip-modules = ["myapp.gui"] # never import these
97
+ aliases = { "asyncio.loop" = "asyncio.SelectorEventLoop" } # doc-only names
98
+ ```
99
+
100
+ Each setting has a command-line flag: `--select`, `--ignore`, `--include-brackets`,
101
+ `--skip-module`, `--alias OLD=NEW`, `--config`. Use `-v` to list what could not
102
+ be checked.
103
+
104
+ ## How it works
105
+
106
+ 1. Each `function`, `method`, `class`, `exception`, `classmethod`,
107
+ `staticmethod` and coroutine directive is read along with its signature
108
+ lines, tracking `module` / `currentmodule` and nested classes.
109
+ 2. The documented parameter list is parsed, including `/`, `*`, defaults that
110
+ contain commas, and the old `foo(a[, b])` bracket notation.
111
+ 3. The documented name is imported, and every parameter the docs present as
112
+ passable by keyword is tested with
113
+ `inspect.signature(obj).bind_partial(name=...)`. Nothing is called.
114
+
115
+ It stays quiet when the docs are describing positions rather than keywords:
116
+ parameters absorbed by a real `*args`, bracketed parameters (unless
117
+ `--include-brackets`), a leading `self`/`cls`, and `.. class:: Name(Base)`
118
+ directives that list base classes.
119
+
120
+ Limits:
121
+
122
+ - Importing a module runs its import-time code. Use `skip-modules` for anything
123
+ with side effects. `antigravity` and `this` are skipped by default.
124
+ - Names that don't import on this machine (platform-only modules, missing C
125
+ extensions) are reported as *unresolved* and never guessed. A missing `lzma`
126
+ is not silently replaced by `builtins.open`.
127
+ - Some C callables have no introspectable signature; those are counted, not
128
+ checked.
129
+ - Not every finding is a bug. Sometimes a descriptive name is chosen on purpose
130
+ (CPython's `urlsplit(urlstring)` signals "str or bytes"). Check the history,
131
+ then add an `ignore` entry.
132
+
133
+ ## Case study: CPython's documentation
134
+
135
+ Run against `Doc/` from a CPython main checkout of November 2026 (plus one
136
+ docs commit fixing the `email.utils` names), with the interpreter built from
137
+ the same commit:
138
+
139
+ | | |
140
+ |---|---|
141
+ | `.rst` files / callable signatures found | 576 / 7,862 |
142
+ | Signatures checked | 3,187 |
143
+ | Findings (SD001 + SD003) | 185 (181 + 4), in 162 callables across 63 files |
144
+ | Additional SD002 (positional-only without `/`) | 540 |
145
+ | Run time | about 1 second |
146
+
147
+ Examples, each confirmed to raise `TypeError` when called as documented:
148
+ `inspect.signature(callable=)`, `asyncio.run(coro=)`,
149
+ `plistlib.loads(data=)`, `logging.makeLogRecord(attrdict=)`,
150
+ `urllib.parse.urlunsplit(parts=)`, `unittest.TestCase.assertIs(first=, second=)`.
151
+
152
+ A few are deliberate, like `copy.copy(obj)` and `urlsplit(urlstring)`, and
153
+ belong in an `ignore` list rather than a docs change.
154
+
155
+ ## Roadmap
156
+
157
+ - A Sphinx extension that emits these as build warnings
158
+ - An inline ignore comment next to the directive
159
+ - MyST Markdown directives
160
+
161
+ ## License
162
+
163
+ MIT
@@ -0,0 +1,140 @@
1
+ # sigdrift
2
+
3
+ Find parameter names in hand-written Sphinx docs that the real function
4
+ rejects as keywords.
5
+
6
+ ```rst
7
+ .. function:: loads(data, *, fmt=None, dict_type=dict, aware_datetime=False)
8
+ ```
9
+
10
+ ```python
11
+ >>> plistlib.loads(data=b"...")
12
+ TypeError: loads() got an unexpected keyword argument 'data'
13
+ ```
14
+
15
+ The docs say `data`; the code says `value`. Anyone who copies the name from
16
+ the docs, including a code assistant, gets a `TypeError`. Docstring linters
17
+ such as docsig and pylint's `docparams` don't see this, because the signature
18
+ lives in an `.rst` file and not in a docstring. sigdrift reads those
19
+ directives, imports what they describe and asks Python whether each
20
+ documented keyword would bind.
21
+
22
+ ```console
23
+ $ python -m sigdrift Doc/library/plistlib.rst
24
+ Doc/library/plistlib.rst:85: SD001 plistlib.loads: 'data' is not accepted as a keyword; the real name is 'value'
25
+ 1 finding(s) in 5 checked signature(s); 0 unresolved, 0 without a signature
26
+ ```
27
+
28
+ ## Install
29
+
30
+ ```console
31
+ pip install sigdrift
32
+ ```
33
+
34
+ Python 3.11 or later, no dependencies. Install it into the same environment as
35
+ the package whose docs you are checking.
36
+
37
+ ## Usage
38
+
39
+ Run sigdrift **with the interpreter whose packages the docs describe**, since
40
+ it imports them to read their real signatures:
41
+
42
+ ```console
43
+ python -m sigdrift docs/ # folders are searched for *.rst
44
+ python -m sigdrift docs/api.rst --format json
45
+ python -m sigdrift docs/ --format github # annotations in GitHub Actions
46
+ ```
47
+
48
+ It exits 1 when there are findings, so it can gate CI. A
49
+ [pre-commit](https://pre-commit.com) hook is included (`id: sigdrift`).
50
+
51
+ | Code | Meaning | Default |
52
+ |---|---|---|
53
+ | SD001 | The docs name a parameter that exists under another, keyword-passable name | on |
54
+ | SD002 | The docs imply a keyword, but the real parameter is positional-only and the docs don't show `/` | off |
55
+ | SD003 | The docs name a parameter the callable does not have | on |
56
+
57
+ SD002 is opt-in (`--select SD001,SD002,SD003`): many C functions are
58
+ positional-only and their docs predate the `/` notation, so it is a much
59
+ larger, separate cleanup.
60
+
61
+ ### Options and configuration
62
+
63
+ ```toml
64
+ [tool.sigdrift]
65
+ paths = ["Doc"]
66
+ select = ["SD001", "SD003"]
67
+ # fnmatch patterns over "module.name" or "module.name:param"
68
+ ignore = [
69
+ "urllib.parse.urlsplit:urlstring", # name chosen on purpose
70
+ "decimal.*",
71
+ ]
72
+ include-brackets = false # also check old-style [optional] parameters
73
+ skip-modules = ["myapp.gui"] # never import these
74
+ aliases = { "asyncio.loop" = "asyncio.SelectorEventLoop" } # doc-only names
75
+ ```
76
+
77
+ Each setting has a command-line flag: `--select`, `--ignore`, `--include-brackets`,
78
+ `--skip-module`, `--alias OLD=NEW`, `--config`. Use `-v` to list what could not
79
+ be checked.
80
+
81
+ ## How it works
82
+
83
+ 1. Each `function`, `method`, `class`, `exception`, `classmethod`,
84
+ `staticmethod` and coroutine directive is read along with its signature
85
+ lines, tracking `module` / `currentmodule` and nested classes.
86
+ 2. The documented parameter list is parsed, including `/`, `*`, defaults that
87
+ contain commas, and the old `foo(a[, b])` bracket notation.
88
+ 3. The documented name is imported, and every parameter the docs present as
89
+ passable by keyword is tested with
90
+ `inspect.signature(obj).bind_partial(name=...)`. Nothing is called.
91
+
92
+ It stays quiet when the docs are describing positions rather than keywords:
93
+ parameters absorbed by a real `*args`, bracketed parameters (unless
94
+ `--include-brackets`), a leading `self`/`cls`, and `.. class:: Name(Base)`
95
+ directives that list base classes.
96
+
97
+ Limits:
98
+
99
+ - Importing a module runs its import-time code. Use `skip-modules` for anything
100
+ with side effects. `antigravity` and `this` are skipped by default.
101
+ - Names that don't import on this machine (platform-only modules, missing C
102
+ extensions) are reported as *unresolved* and never guessed. A missing `lzma`
103
+ is not silently replaced by `builtins.open`.
104
+ - Some C callables have no introspectable signature; those are counted, not
105
+ checked.
106
+ - Not every finding is a bug. Sometimes a descriptive name is chosen on purpose
107
+ (CPython's `urlsplit(urlstring)` signals "str or bytes"). Check the history,
108
+ then add an `ignore` entry.
109
+
110
+ ## Case study: CPython's documentation
111
+
112
+ Run against `Doc/` from a CPython main checkout of November 2026 (plus one
113
+ docs commit fixing the `email.utils` names), with the interpreter built from
114
+ the same commit:
115
+
116
+ | | |
117
+ |---|---|
118
+ | `.rst` files / callable signatures found | 576 / 7,862 |
119
+ | Signatures checked | 3,187 |
120
+ | Findings (SD001 + SD003) | 185 (181 + 4), in 162 callables across 63 files |
121
+ | Additional SD002 (positional-only without `/`) | 540 |
122
+ | Run time | about 1 second |
123
+
124
+ Examples, each confirmed to raise `TypeError` when called as documented:
125
+ `inspect.signature(callable=)`, `asyncio.run(coro=)`,
126
+ `plistlib.loads(data=)`, `logging.makeLogRecord(attrdict=)`,
127
+ `urllib.parse.urlunsplit(parts=)`, `unittest.TestCase.assertIs(first=, second=)`.
128
+
129
+ A few are deliberate, like `copy.copy(obj)` and `urlsplit(urlstring)`, and
130
+ belong in an `ignore` list rather than a docs change.
131
+
132
+ ## Roadmap
133
+
134
+ - A Sphinx extension that emits these as build warnings
135
+ - An inline ignore comment next to the directive
136
+ - MyST Markdown directives
137
+
138
+ ## License
139
+
140
+ MIT
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.24"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "sigdrift"
7
+ version = "0.1.0"
8
+ description = "Find parameter names in hand-written Sphinx docs that the real function rejects as keywords."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.11"
13
+ authors = [{ name = "Thejesh" }]
14
+ keywords = ["sphinx", "documentation", "lint", "signature", "rst"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Environment :: Console",
18
+ "Framework :: Sphinx",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3",
21
+ "Topic :: Documentation :: Sphinx",
22
+ "Topic :: Software Development :: Quality Assurance",
23
+ ]
24
+ dependencies = []
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/thejesh23/sigdrift"
28
+ Issues = "https://github.com/thejesh23/sigdrift/issues"
29
+ Changelog = "https://github.com/thejesh23/sigdrift/blob/main/CHANGELOG.md"
30
+
31
+ [project.optional-dependencies]
32
+ test = ["pytest>=8"]
33
+
34
+ [project.scripts]
35
+ sigdrift = "sigdrift.cli:main"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["src/sigdrift"]
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
@@ -0,0 +1,3 @@
1
+ """Find documented parameter names that the real callable rejects."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())