docstringify 1.0.0__tar.gz → 1.1.1__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.
Files changed (45) hide show
  1. {docstringify-1.0.0 → docstringify-1.1.1}/.github/dependabot.yml +4 -0
  2. {docstringify-1.0.0 → docstringify-1.1.1}/.github/workflows/ci.yml +4 -2
  3. {docstringify-1.0.0 → docstringify-1.1.1}/.pre-commit-config.yaml +8 -8
  4. docstringify-1.1.1/.python-version +1 -0
  5. {docstringify-1.0.0 → docstringify-1.1.1}/CONTRIBUTING.md +1 -1
  6. {docstringify-1.0.0 → docstringify-1.1.1}/PKG-INFO +9 -36
  7. {docstringify-1.0.0 → docstringify-1.1.1}/README.md +5 -5
  8. {docstringify-1.0.0 → docstringify-1.1.1}/pyproject.toml +15 -23
  9. docstringify-1.1.1/src/docstringify/__init__.py +10 -0
  10. docstringify-1.1.1/src/docstringify/components.py +47 -0
  11. docstringify-1.1.1/src/docstringify/nodes/base.py +110 -0
  12. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/nodes/function.py +145 -3
  13. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/traversal/transformer.py +55 -9
  14. docstringify-1.1.1/uv.lock +423 -0
  15. docstringify-1.0.0/setup.cfg +0 -4
  16. docstringify-1.0.0/src/docstringify/__init__.py +0 -6
  17. docstringify-1.0.0/src/docstringify/components.py +0 -22
  18. docstringify-1.0.0/src/docstringify/nodes/base.py +0 -58
  19. docstringify-1.0.0/src/docstringify.egg-info/PKG-INFO +0 -243
  20. docstringify-1.0.0/src/docstringify.egg-info/SOURCES.txt +0 -38
  21. docstringify-1.0.0/src/docstringify.egg-info/dependency_links.txt +0 -1
  22. docstringify-1.0.0/src/docstringify.egg-info/entry_points.txt +0 -2
  23. docstringify-1.0.0/src/docstringify.egg-info/requires.txt +0 -6
  24. docstringify-1.0.0/src/docstringify.egg-info/top_level.txt +0 -1
  25. {docstringify-1.0.0 → docstringify-1.1.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  26. {docstringify-1.0.0 → docstringify-1.1.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  27. {docstringify-1.0.0 → docstringify-1.1.1}/.github/pull_request_template.md +0 -0
  28. {docstringify-1.0.0 → docstringify-1.1.1}/.github/release.yml +0 -0
  29. {docstringify-1.0.0 → docstringify-1.1.1}/.github/workflows/greetings.yml +0 -0
  30. {docstringify-1.0.0 → docstringify-1.1.1}/.github/workflows/pypi-publish.yml +0 -0
  31. {docstringify-1.0.0 → docstringify-1.1.1}/.gitignore +0 -0
  32. {docstringify-1.0.0 → docstringify-1.1.1}/.pre-commit-hooks.yaml +0 -0
  33. {docstringify-1.0.0 → docstringify-1.1.1}/CODE_OF_CONDUCT.md +0 -0
  34. {docstringify-1.0.0 → docstringify-1.1.1}/LICENSE +0 -0
  35. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/__main__.py +0 -0
  36. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/cli.py +0 -0
  37. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/converters/__init__.py +0 -0
  38. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/converters/base.py +0 -0
  39. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/converters/google.py +0 -0
  40. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/converters/numpydoc.py +0 -0
  41. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/converters/stub.py +0 -0
  42. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/exceptions.py +0 -0
  43. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/nodes/__init__.py +0 -0
  44. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/traversal/__init__.py +0 -0
  45. {docstringify-1.0.0 → docstringify-1.1.1}/src/docstringify/traversal/visitor.py +0 -0
@@ -9,3 +9,7 @@ updates:
9
9
  schedule:
10
10
  # Check for updates to GitHub Actions every month
11
11
  interval: "monthly"
12
+ groups:
13
+ actions:
14
+ patterns:
15
+ - "*"
@@ -22,6 +22,8 @@ on:
22
22
  - '!.github/**'
23
23
  - '.github/workflows/ci.yml'
24
24
 
25
+ workflow_dispatch:
26
+
25
27
  concurrency:
26
28
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
27
29
  cancel-in-progress: true
@@ -60,8 +62,8 @@ jobs:
60
62
  - name: Check entry point
61
63
  run: docstringify --version
62
64
 
63
- - name: Install testing dependencies
64
- run: python -m pip install '.[dev]'
65
+ - name: Install dev dependencies
66
+ run: python -m pip install --group dev
65
67
 
66
68
  - name: Validate pre-commit hook
67
69
  run: pre-commit try-repo . docstringify
@@ -11,14 +11,20 @@ repos:
11
11
  - id: end-of-file-fixer
12
12
  - id: trailing-whitespace
13
13
 
14
+ - repo: https://github.com/numpy/numpydoc
15
+ rev: v1.9.0
16
+ hooks:
17
+ - id: numpydoc-validation
18
+ exclude: (tests|docs)/.*
19
+
14
20
  - repo: https://github.com/stefmolin/docstringify
15
- rev: 0.7.0
21
+ rev: 1.0.0
16
22
  hooks:
17
23
  - id: docstringify
18
24
  args: [--make-changes-inplace=numpydoc]
19
25
 
20
26
  - repo: https://github.com/astral-sh/ruff-pre-commit
21
- rev: v0.11.10
27
+ rev: v0.12.2
22
28
  hooks:
23
29
  - id: ruff-check
24
30
  args: [--fix, --exit-non-zero-on-fix, --show-fixes]
@@ -29,9 +35,3 @@ repos:
29
35
  hooks:
30
36
  - id: pyproject-fmt
31
37
  args: [--keep-full-version, --no-print-diff]
32
-
33
- - repo: https://github.com/numpy/numpydoc
34
- rev: v1.8.0
35
- hooks:
36
- - id: numpydoc-validation
37
- exclude: (tests|docs)/.*
@@ -0,0 +1 @@
1
+ 3.13
@@ -9,7 +9,7 @@ Open up an issue describing in detail the bug or feature request you are proposi
9
9
  Once you have been given the go ahead, you can start working on the code. Start by forking the project, cloning locally, and then creating a branch to work on. You will need to then install main dependencies as well as the `dev` dependencies, which can be done by running the following command:
10
10
 
11
11
  ```shell
12
- $ pip install -e '.[dev]'
12
+ $ pip install -e . --group dev
13
13
  ```
14
14
 
15
15
  Set up the pre-commit hooks to make sure you can pass the CI checks:
@@ -1,33 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstringify
3
- Version: 1.0.0
3
+ Version: 1.1.1
4
4
  Summary: Flag missing docstrings and, optionally, generate them from signatures and type annotations.
5
- Author-email: Stefanie Molin <docstringify@stefaniemolin.com>
6
- License: MIT License
7
-
8
- Copyright (c) 2025 Stefanie Molin
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
5
  Project-URL: Documentation, https://github.com/stefmolin/docstringify
29
6
  Project-URL: Homepage, https://github.com/stefmolin/docstringify
30
7
  Project-URL: Source, https://github.com/stefmolin/docstringify
8
+ Author-email: Stefanie Molin <docstringify@stefaniemolin.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
31
11
  Keywords: ast,docstring generation,google-style docstring,numpydoc-style docstring,pre-commit
32
12
  Classifier: Development Status :: 4 - Beta
33
13
  Classifier: Programming Language :: Python
@@ -39,13 +19,6 @@ Classifier: Programming Language :: Python :: 3.12
39
19
  Classifier: Programming Language :: Python :: 3.13
40
20
  Requires-Python: >=3.9
41
21
  Description-Content-Type: text/markdown
42
- License-File: LICENSE
43
- Provides-Extra: dev
44
- Requires-Dist: pre-commit; extra == "dev"
45
- Requires-Dist: pytest; extra == "dev"
46
- Requires-Dist: pytest-cov; extra == "dev"
47
- Requires-Dist: pytest-randomly; extra == "dev"
48
- Dynamic: license-file
49
22
 
50
23
  # Docstringify
51
24
  Flag missing docstrings and, optionally, generate them from signatures and type annotations.
@@ -107,7 +80,7 @@ Add the following to your `.pre-commit-config.yaml` file to block commits with m
107
80
 
108
81
  ```yaml
109
82
  - repo: https://github.com/stefmolin/docstringify
110
- rev: 1.0.0
83
+ rev: 1.1.0
111
84
  hooks:
112
85
  - id: docstringify
113
86
  ```
@@ -116,7 +89,7 @@ By default, all docstrings are required. If you want to be more lenient, you can
116
89
 
117
90
  ```yaml
118
91
  - repo: https://github.com/stefmolin/docstringify
119
- rev: 1.0.0
92
+ rev: 1.1.0
120
93
  hooks:
121
94
  - id: docstringify
122
95
  args: [--threshold=0.75]
@@ -126,7 +99,7 @@ If you would like to see suggested docstring templates (inferred from type annot
126
99
 
127
100
  ```yaml
128
101
  - repo: https://github.com/stefmolin/docstringify
129
- rev: 1.0.0
102
+ rev: 1.1.0
130
103
  hooks:
131
104
  - id: docstringify
132
105
  args: [--suggest-changes=numpydoc]
@@ -136,7 +109,7 @@ Use `--make-changes` to create a copy of each file with docstring templates. Her
136
109
 
137
110
  ```yaml
138
111
  - repo: https://github.com/stefmolin/docstringify
139
- rev: 1.0.0
112
+ rev: 1.1.0
140
113
  hooks:
141
114
  - id: docstringify
142
115
  args: [--make-changes=google]
@@ -146,7 +119,7 @@ If you want the changes to be made in place, change `--make-changes` to `--make-
146
119
 
147
120
  ```yaml
148
121
  - repo: https://github.com/stefmolin/docstringify
149
- rev: 1.0.0
122
+ rev: 1.1.0
150
123
  hooks:
151
124
  - id: docstringify
152
125
  args: [--make-changes-inplace=numpydoc]
@@ -58,7 +58,7 @@ Add the following to your `.pre-commit-config.yaml` file to block commits with m
58
58
 
59
59
  ```yaml
60
60
  - repo: https://github.com/stefmolin/docstringify
61
- rev: 1.0.0
61
+ rev: 1.1.0
62
62
  hooks:
63
63
  - id: docstringify
64
64
  ```
@@ -67,7 +67,7 @@ By default, all docstrings are required. If you want to be more lenient, you can
67
67
 
68
68
  ```yaml
69
69
  - repo: https://github.com/stefmolin/docstringify
70
- rev: 1.0.0
70
+ rev: 1.1.0
71
71
  hooks:
72
72
  - id: docstringify
73
73
  args: [--threshold=0.75]
@@ -77,7 +77,7 @@ If you would like to see suggested docstring templates (inferred from type annot
77
77
 
78
78
  ```yaml
79
79
  - repo: https://github.com/stefmolin/docstringify
80
- rev: 1.0.0
80
+ rev: 1.1.0
81
81
  hooks:
82
82
  - id: docstringify
83
83
  args: [--suggest-changes=numpydoc]
@@ -87,7 +87,7 @@ Use `--make-changes` to create a copy of each file with docstring templates. Her
87
87
 
88
88
  ```yaml
89
89
  - repo: https://github.com/stefmolin/docstringify
90
- rev: 1.0.0
90
+ rev: 1.1.0
91
91
  hooks:
92
92
  - id: docstringify
93
93
  args: [--make-changes=google]
@@ -97,7 +97,7 @@ If you want the changes to be made in place, change `--make-changes` to `--make-
97
97
 
98
98
  ```yaml
99
99
  - repo: https://github.com/stefmolin/docstringify
100
- rev: 1.0.0
100
+ rev: 1.1.0
101
101
  hooks:
102
102
  - id: docstringify
103
103
  args: [--make-changes-inplace=numpydoc]
@@ -1,13 +1,11 @@
1
1
  [build-system]
2
- build-backend = "setuptools.build_meta"
2
+ build-backend = "hatchling.build"
3
3
 
4
- requires = [
5
- "setuptools",
6
- "setuptools-scm",
7
- ]
4
+ requires = [ "hatchling" ]
8
5
 
9
6
  [project]
10
7
  name = "docstringify"
8
+ version = "1.1.1"
11
9
  description = "Flag missing docstrings and, optionally, generate them from signatures and type annotations."
12
10
  readme = "README.md"
13
11
  keywords = [
@@ -17,7 +15,8 @@ keywords = [
17
15
  "numpydoc-style docstring",
18
16
  "pre-commit",
19
17
  ]
20
- license = { file = "LICENSE" }
18
+ license = "MIT"
19
+ license-files = [ "LICENSE" ]
21
20
  authors = [
22
21
  { name = "Stefanie Molin", email = "docstringify@stefaniemolin.com" },
23
22
  ]
@@ -32,29 +31,21 @@ classifiers = [
32
31
  "Programming Language :: Python :: 3.12",
33
32
  "Programming Language :: Python :: 3.13",
34
33
  ]
35
- dynamic = [
36
- "version",
37
- ]
38
34
 
39
35
  dependencies = [ ]
40
- optional-dependencies.dev = [
41
- "pre-commit",
42
- "pytest",
43
- "pytest-cov",
44
- "pytest-randomly",
45
- ]
46
36
  urls.Documentation = "https://github.com/stefmolin/docstringify"
47
37
  urls.Homepage = "https://github.com/stefmolin/docstringify"
48
38
  urls.Source = "https://github.com/stefmolin/docstringify"
49
39
  scripts.docstringify = "docstringify.cli:main"
50
40
 
51
- [tool.setuptools.packages.find]
52
- where = [
53
- "src",
54
- ]
41
+ [dependency-groups]
42
+ dev = [ "pre-commit", { include-group = "test" } ]
55
43
 
56
- [tool.setuptools.dynamic]
57
- version = { attr = "docstringify.__version__" }
44
+ test = [
45
+ "pytest>=8.3.4",
46
+ "pytest-cov>=4.1.0",
47
+ "pytest-randomly>=3.12.0",
48
+ ]
58
49
 
59
50
  [tool.ruff]
60
51
  line-length = 88
@@ -96,6 +87,7 @@ lint.isort.known-first-party = [
96
87
  [tool.numpydoc_validation]
97
88
  checks = [
98
89
  "all", # report on all checks
90
+ "GL08", # use Docstringify to test for docstring presence instead
99
91
  "ES01", # but don't require an extended summary
100
92
  "EX01", # or examples
101
93
  "SA01", # or a see also section
@@ -106,6 +98,6 @@ exclude = [ # don't report on checks for these
106
98
  '\.__repr__$',
107
99
  '\.__str__$',
108
100
  ]
109
- override_SS05 = [ # override SS05 to allow docstrings starting with these words
110
- '^Process ',
101
+ override_SS05 = [ # allow docstrings to start with these words
102
+ '^Unambiguous ',
111
103
  ]
@@ -0,0 +1,10 @@
1
+ """
2
+ Flag missing docstrings and, optionally, generate them from signatures and
3
+ type annotations.
4
+ """
5
+
6
+ import importlib.metadata
7
+
8
+ __version__ = importlib.metadata.version(__name__)
9
+
10
+ __all__ = ['__version__']
@@ -0,0 +1,47 @@
1
+ """Docstring components."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Final, NamedTuple
6
+
7
+ NO_DEFAULT: Final = object()
8
+ """Sentinel value indicating that there is no default value. This is necessary because
9
+ ``None`` has a different meaning in certain contexts of the AST traversal."""
10
+
11
+ DESCRIPTION_PLACEHOLDER: Final[str] = '__description__'
12
+ """Docstring placeholder for description fields."""
13
+
14
+ PARAMETER_TYPE_PLACEHOLDER: Final[str] = '__type__'
15
+ """Docstring placeholder for the parameter type, when Docstringify can't determine it."""
16
+
17
+ RETURN_TYPE_PLACEHOLDER: Final[str] = '__return_type__'
18
+ """Docstring placeholder for the return type, when Docstringify can't determine it."""
19
+
20
+
21
+ class Parameter(NamedTuple):
22
+ """Information about an individual parameter to a function."""
23
+
24
+ name: str
25
+ """The name of the parameter."""
26
+
27
+ type_: str
28
+ """The parameter's data type."""
29
+
30
+ category: str | None
31
+ """The parameter's category, if there is one. This is used to pass additional
32
+ information, for example, to indicate that an argument is positional-only."""
33
+
34
+ default: str | NO_DEFAULT
35
+ """A string specifying the default value, if there is one, otherwise,
36
+ :const:`.NO_DEFAULT`."""
37
+
38
+
39
+ class Function(NamedTuple):
40
+ """Information about a function."""
41
+
42
+ parameters: tuple[Parameter, ...]
43
+ """Information about the function's parameters stored as :class:`.Parameter`
44
+ instances."""
45
+
46
+ return_type: str | None
47
+ """The return type for the function as a string, if present, otherwise, ``None``."""
@@ -0,0 +1,110 @@
1
+ """Base Docstringify traversal node."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import ast
6
+ from functools import partial
7
+ from typing import Callable, overload
8
+
9
+
10
+ class DocstringNode:
11
+ """
12
+ Base class for Docstringify traversal nodes.
13
+
14
+ Parameters
15
+ ----------
16
+ node : ast.Module | ast.ClassDef | ast.FunctionDef | ast.AsyncFunctionDef
17
+ AST node representing a module, class, or function.
18
+ module_name : str
19
+ The name of the module to which the node belongs.
20
+ source_code : str
21
+ The source code for the module from which ``node`` originates.
22
+ parent : DocstringNode | None, default=None
23
+ The parent node, if there is one.
24
+ """
25
+
26
+ @overload
27
+ def __init__(
28
+ self,
29
+ node: ast.Module,
30
+ module_name: str,
31
+ source_code: str,
32
+ parent: None = None,
33
+ ) -> None: ...
34
+
35
+ @overload
36
+ def __init__(
37
+ self,
38
+ node: ast.ClassDef | ast.FunctionDef | ast.AsyncFunctionDef,
39
+ module_name: str,
40
+ source_code: str,
41
+ parent: DocstringNode,
42
+ ) -> None: ...
43
+
44
+ def __init__(
45
+ self,
46
+ node: ast.Module | ast.ClassDef | ast.FunctionDef | ast.AsyncFunctionDef,
47
+ module_name: str,
48
+ source_code: str,
49
+ parent: DocstringNode | None = None,
50
+ ) -> None:
51
+ self.module_name: str = module_name
52
+ """The name of the module to which the node belongs."""
53
+
54
+ self.parent: DocstringNode | None = parent
55
+ """The parent node, if there is one."""
56
+
57
+ self.docstring_required: bool = True
58
+ """Whether the node requires a docstring."""
59
+
60
+ self.ast_node: (
61
+ ast.Module | ast.ClassDef | ast.FunctionDef | ast.AsyncFunctionDef
62
+ ) = node
63
+ """The AST node that represents the source code."""
64
+
65
+ self.name: str = getattr(node, 'name', self.module_name)
66
+ """The name of the node."""
67
+
68
+ self.get_source_segment: Callable[[ast.AST], str | None] = partial(
69
+ ast.get_source_segment, source_code
70
+ )
71
+ """Callable to get the source code for the AST node (:attr:`.ast_node`)."""
72
+
73
+ self.original_docstring_location: tuple[int, int] | None = (
74
+ None
75
+ if self.docstring is None
76
+ else (self.ast_node.body[0].lineno, self.ast_node.body[0].end_lineno)
77
+ )
78
+ """Start and end line of the docstring in the original file, if there was one,
79
+ otherwise, ``None``. This is necessary for the rewriting algorithm to exclude
80
+ lines containing "empty" docstrings from the file. Empty docstrings are empty
81
+ strings or strings containing only whitespace characters."""
82
+
83
+ @property
84
+ def docstring(self) -> str | None:
85
+ """
86
+ Get the docstring from the AST node.
87
+
88
+ Returns
89
+ -------
90
+ str | None
91
+ The docstring, if it exists.
92
+ """
93
+ docstring = ast.get_docstring(self.ast_node)
94
+ return docstring if docstring is None else docstring.strip()
95
+
96
+ @property
97
+ def fully_qualified_name(self) -> str:
98
+ """
99
+ Unambiguous name for the node.
100
+
101
+ Returns
102
+ -------
103
+ str
104
+ The fully-qualified name.
105
+ """
106
+ return (
107
+ f'{self.parent.fully_qualified_name}.{self.name}'
108
+ if self.parent
109
+ else self.name
110
+ )