format-docstring 0.2.0__tar.gz → 0.2.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 (107) hide show
  1. {format_docstring-0.2.0 → format_docstring-0.2.1}/.pre-commit-config.yaml +5 -0
  2. {format_docstring-0.2.0 → format_docstring-0.2.1}/AGENTS.md +13 -8
  3. {format_docstring-0.2.0 → format_docstring-0.2.1}/CHANGELOG.md +7 -0
  4. {format_docstring-0.2.0 → format_docstring-0.2.1}/PKG-INFO +1 -1
  5. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/line_wrap_numpy.py +17 -2
  6. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring.egg-info/PKG-INFO +1 -1
  7. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring.egg-info/SOURCES.txt +4 -2
  8. {format_docstring-0.2.0 → format_docstring-0.2.1}/pyproject.toml +1 -1
  9. format_docstring-0.2.1/tests/test_data/end_to_end/numpy/signature_dont_sync_raises.txt +48 -0
  10. format_docstring-0.2.0/tests/test_data/end_to_end/numpy/returns_signature_sync.txt → format_docstring-0.2.1/tests/test_data/end_to_end/numpy/signature_sync_returns.txt +57 -0
  11. format_docstring-0.2.1/tests/test_data/end_to_end/numpy/signature_sync_yields.txt +103 -0
  12. {format_docstring-0.2.0 → format_docstring-0.2.1}/.github/workflows/python-package.yml +0 -0
  13. {format_docstring-0.2.0 → format_docstring-0.2.1}/.github/workflows/python-publish.yml +0 -0
  14. {format_docstring-0.2.0 → format_docstring-0.2.1}/.gitignore +0 -0
  15. {format_docstring-0.2.0 → format_docstring-0.2.1}/.pre-commit-hooks.yaml +0 -0
  16. {format_docstring-0.2.0 → format_docstring-0.2.1}/LICENSE +0 -0
  17. {format_docstring-0.2.0 → format_docstring-0.2.1}/README.md +0 -0
  18. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/__init__.py +0 -0
  19. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/base_fixer.py +0 -0
  20. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/config.py +0 -0
  21. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/docstring_rewriter.py +0 -0
  22. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/line_wrap_google.py +0 -0
  23. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/line_wrap_utils.py +0 -0
  24. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/main_jupyter.py +0 -0
  25. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring/main_py.py +0 -0
  26. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring.egg-info/dependency_links.txt +0 -0
  27. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring.egg-info/entry_points.txt +0 -0
  28. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring.egg-info/requires.txt +0 -0
  29. {format_docstring-0.2.0 → format_docstring-0.2.1}/format_docstring.egg-info/top_level.txt +0 -0
  30. {format_docstring-0.2.0 → format_docstring-0.2.1}/muff.toml +0 -0
  31. {format_docstring-0.2.0 → format_docstring-0.2.1}/requirements.dev +0 -0
  32. {format_docstring-0.2.0 → format_docstring-0.2.1}/setup.cfg +0 -0
  33. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/__init__.py +0 -0
  34. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/helpers.py +0 -0
  35. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_base_fixer.py +0 -0
  36. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_config.py +0 -0
  37. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/README.md +0 -0
  38. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/colon_spacing_fix.txt +0 -0
  39. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/contents_that_are_not_wrapped.txt +0 -0
  40. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/default_value_standardization.txt +0 -0
  41. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/empty_lines_are_respected.txt +0 -0
  42. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/examples_section.txt +0 -0
  43. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/existing_linebreaks_should_not_be_respected.txt +0 -0
  44. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/fix_rst_backticks.txt +0 -0
  45. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/four_level_nested_classes.txt +0 -0
  46. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/indent_four_levels_16_spaces_width_10.txt +0 -0
  47. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/indent_misaligned_all.txt +0 -0
  48. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/indent_two_levels_8_spaces.txt +0 -0
  49. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/line_length_2.txt +0 -0
  50. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/mismatched_underlines.txt +0 -0
  51. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/mismatched_underlines_one_dash.txt +0 -0
  52. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/mismatched_underlines_two_dashes.txt +0 -0
  53. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/module_level_docstring.txt +0 -0
  54. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/new_lines_before_and_after.txt +0 -0
  55. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/no_format_docstring_comment.txt +0 -0
  56. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/param_signature_without_type.txt +0 -0
  57. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/parameters_returns_raises_wrapping.txt +0 -0
  58. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/returns_signature_and_description.txt +0 -0
  59. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/section_headings_with_colons.txt +0 -0
  60. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/section_title_fixed.txt +0 -0
  61. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/sections_notes_examples.txt +0 -0
  62. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/signature_line_is_not_wrapped.txt +0 -0
  63. /format_docstring-0.2.0/tests/test_data/end_to_end/numpy/parameter_signature_sync.txt → /format_docstring-0.2.1/tests/test_data/end_to_end/numpy/signature_sync_parameters.txt +0 -0
  64. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/single_line_docstring.txt +0 -0
  65. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/texts_are_rewrapped.txt +0 -0
  66. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/end_to_end/numpy/very_long_unbreakable_word.txt +0 -0
  67. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/integration_test/numpy/after.ipynb +0 -0
  68. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/integration_test/numpy/after.py +0 -0
  69. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/integration_test/numpy/after_50.ipynb +0 -0
  70. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/integration_test/numpy/after_50.py +0 -0
  71. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/integration_test/numpy/before.ipynb +0 -0
  72. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/integration_test/numpy/before.py +0 -0
  73. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/jupyter/before.ipynb +0 -0
  74. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/jupyter/verbose_before.ipynb +0 -0
  75. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/README.md +0 -0
  76. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/colon_spacing_fix.txt +0 -0
  77. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/contents_that_are_not_wrapped.txt +0 -0
  78. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/default_value_standardization.txt +0 -0
  79. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/empty_lines_are_respected.txt +0 -0
  80. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/examples_section.txt +0 -0
  81. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/existing_linebreaks_should_not_be_respected.txt +0 -0
  82. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/fix_rst_backticks.txt +0 -0
  83. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/indent_four_levels_16_spaces_width_10.txt +0 -0
  84. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/indent_two_levels_8_spaces.txt +0 -0
  85. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/line_length_2.txt +0 -0
  86. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/mismatched_underlines.txt +0 -0
  87. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/mismatched_underlines_one_dash.txt +0 -0
  88. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/mismatched_underlines_two_dashes.txt +0 -0
  89. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/module_level_docstring.txt +0 -0
  90. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/param_signature_without_type.txt +0 -0
  91. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/parameters_returns_raises_wrapping.txt +0 -0
  92. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/returns_signature_and_description.txt +0 -0
  93. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/section_headings_with_colons.txt +0 -0
  94. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/section_title_fixed.txt +0 -0
  95. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/sections_notes_examples.txt +0 -0
  96. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/signature_line_is_not_wrapped.txt +0 -0
  97. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/texts_are_rewrapped.txt +0 -0
  98. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/line_wrap/numpy/very_long_unbreakable_word.txt +0 -0
  99. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_data/playground.py +0 -0
  100. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_docstring_rewriter.py +0 -0
  101. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_line_wrap_google.py +0 -0
  102. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_line_wrap_numpy.py +0 -0
  103. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_line_wrap_utils.py +0 -0
  104. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_main_jupyter.py +0 -0
  105. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_main_py.py +0 -0
  106. {format_docstring-0.2.0 → format_docstring-0.2.1}/tests/test_playground.py +0 -0
  107. {format_docstring-0.2.0 → format_docstring-0.2.1}/tox.ini +0 -0
@@ -57,6 +57,11 @@ repos:
57
57
  rev: 0.0.11
58
58
  hooks:
59
59
  - id: markdown-toc-creator
60
+ - repo: https://github.com/jsh9/markdown-heading-numbering
61
+ rev: 0.1.0
62
+ hooks:
63
+ - id: markdown-heading-numbering
64
+ exclude: ^CHANGELOG\.md$
60
65
  - repo: local
61
66
  hooks:
62
67
  - id: format-docstring
@@ -3,7 +3,7 @@
3
3
  This guide briefs coding agents working on `format-docstring`. Use it to get
4
4
  oriented before making changes.
5
5
 
6
- ## Quick Snapshot
6
+ ## 1. Quick Snapshot
7
7
 
8
8
  - Formats NumPy-style docstrings (with experimental Google support) in `.py`
9
9
  files and Jupyter notebooks while preserving surrounding code.
@@ -13,7 +13,7 @@ oriented before making changes.
13
13
  `jupyter-notebook-parser`, and `tomli/tomllib` for configuration loading.
14
14
  - Version is sourced dynamically in `format_docstring/__init__.py`.
15
15
 
16
- ## Repository Layout
16
+ ## 2. Repository Layout
17
17
 
18
18
  - `format_docstring/main_py.py` – Click CLI for Python files; validates input
19
19
  and delegates to `PythonFileFixer`.
@@ -33,7 +33,7 @@ oriented before making changes.
33
33
  - `tests/` – Pytest suite with fixture-driven cases in `tests/test_data/`; see
34
34
  `tests/helpers.py` for fixture loading helpers.
35
35
 
36
- ## Implementation Notes
36
+ ## 3. Implementation Notes
37
37
 
38
38
  - `docstring_rewriter.fix_src` parses with `ast.parse`, collects docstring
39
39
  literals, and rewrites source slices using absolute offsets from
@@ -44,6 +44,8 @@ oriented before making changes.
44
44
  redundant `, optional`, and forward references keep their original quoting.
45
45
  - Return annotations are likewise projected into `Returns`/`Yields` sections,
46
46
  mirroring tuple element splits when the docstring already enumerates them.
47
+ - `Raises` section entries are treated like signature lines in the NumPy
48
+ wrapper so exception names stay untouched while descriptions wrap.
47
49
  - Wrapping honors NumPy section heuristics, rST constructs, code fences,
48
50
  `Examples` prompts, and literal blocks introduced by `::`.
49
51
  - `_normalize_signature_segment` flattens multiline annotations via
@@ -57,7 +59,7 @@ oriented before making changes.
57
59
  - Notebook fixer round-trips JSON via `json.dump(..., indent=1)` and rewrites
58
60
  cells only when content changes, preserving magics with `reconstruct_source`.
59
61
 
60
- ## Configuration
62
+ ## 4. Configuration
61
63
 
62
64
  - User-facing configuration lives under `[tool.format_docstring]` inside
63
65
  `pyproject.toml` and supports `line_length`, `docstring_style`, `exclude`,
@@ -68,7 +70,7 @@ oriented before making changes.
68
70
  - Default exclude pattern is `\.git|\.tox|\.pytest_cache`; tests tweak it as
69
71
  needed.
70
72
 
71
- ## Development Workflow
73
+ ## 5. Development Workflow
72
74
 
73
75
  - Install: `pip install -e .` for the project,
74
76
  `pip install -r requirements.dev` for tooling.
@@ -83,17 +85,20 @@ oriented before making changes.
83
85
  `format-docstring-jupyter --help`.
84
86
  - Pre-commit: `pre-commit run -a`.
85
87
 
86
- ## Testing Notes
88
+ ## 6. Testing Notes
87
89
 
88
90
  - Fixture files under `tests/test_data/line_wrap` and
89
91
  `tests/test_data/end_to_end` use `LINE_LENGTH: <int>` headers followed by
90
92
  `BEFORE`/`AFTER` sections split by `**********`.
93
+ - Regression fixture
94
+ `tests/test_data/end_to_end/numpy/signature_dont_sync_raises.txt` guards
95
+ against mutating exception names in `Raises` blocks.
91
96
  - `tests/test_playground.py` focuses on regression snippets;
92
97
  `tests/test_config.py` exercises config discovery and CLI overrides.
93
98
  - When modifying wrapping rules, update both the helper (`line_wrap_utils.py`)
94
99
  and the corresponding expectation files in `tests/test_data/`.
95
100
 
96
- ## Style Guidance
101
+ ## 7. Style Guidance
97
102
 
98
103
  - Formatting rules mirror `muff.toml` (line length 79, single quotes, NumPy
99
104
  docstring convention). Respect these when adding code.
@@ -101,7 +106,7 @@ oriented before making changes.
101
106
  content, and add regression cases whenever handling around literal sections
102
107
  or tables changes.
103
108
 
104
- ## What is a "signature line"?
109
+ ## 8. What is a "signature line"?
105
110
 
106
111
  They are the lines in the docstring where input and return args are defined,
107
112
  for example, in this docstring:
@@ -6,6 +6,13 @@ The format is based on
6
6
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
7
7
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [0.2.1] - 2025-10-20
10
+
11
+ - Fixed
12
+ - A bug where raised exceptions in docstrings are incorrectly changed
13
+ - Full diff
14
+ - https://github.com/jsh9/format-docstring/compare/0.2.0...0.2.1
15
+
9
16
  ## [0.2.0] - 2025-10-20
10
17
 
11
18
  - Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: format-docstring
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A Python formatter to wrap/adjust docstring lines
5
5
  Author-email: jsh9 <25124332+jsh9@users.noreply.github.com>
6
6
  Maintainer-email: jsh9 <25124332+jsh9@users.noreply.github.com>
@@ -71,7 +71,7 @@ def wrap_docstring_numpy(
71
71
  'attribute', # tolerate typo
72
72
  'attribute:',
73
73
  }
74
- SECTION_RETURNS = {
74
+ SECTION_RETURNS_YIELDS = {
75
75
  'returns',
76
76
  'returns:',
77
77
  'return', # tolerate typo
@@ -80,6 +80,8 @@ def wrap_docstring_numpy(
80
80
  'yields:',
81
81
  'yield', # tolerate typo
82
82
  'yield:',
83
+ }
84
+ SECTION_RAISES = {
83
85
  'raises',
84
86
  'raises:',
85
87
  'raise', # tolerate typo
@@ -183,7 +185,7 @@ def wrap_docstring_numpy(
183
185
  continue
184
186
 
185
187
  # Returns/Yields sections
186
- if section_lower_case in SECTION_RETURNS:
188
+ if section_lower_case in SECTION_RETURNS_YIELDS:
187
189
  if line.strip() == '':
188
190
  temp_out.append(line)
189
191
  i += 1
@@ -234,6 +236,19 @@ def wrap_docstring_numpy(
234
236
  i += 1
235
237
  continue
236
238
 
239
+ # Raises section
240
+ if section_lower_case in SECTION_RAISES:
241
+ if line.strip() == '':
242
+ temp_out.append(line)
243
+ i += 1
244
+ continue
245
+
246
+ # Treat top-level lines as signatures
247
+ if indent_length <= leading_indent: # type: ignore[operator]
248
+ temp_out.append(line)
249
+ i += 1
250
+ continue
251
+
237
252
  # Examples or any other section
238
253
  collect_to_temp_output(temp_out, line)
239
254
  i += 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: format-docstring
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A Python formatter to wrap/adjust docstring lines
5
5
  Author-email: jsh9 <25124332+jsh9@users.noreply.github.com>
6
6
  Maintainer-email: jsh9 <25124332+jsh9@users.noreply.github.com>
@@ -58,14 +58,16 @@ tests/test_data/end_to_end/numpy/module_level_docstring.txt
58
58
  tests/test_data/end_to_end/numpy/new_lines_before_and_after.txt
59
59
  tests/test_data/end_to_end/numpy/no_format_docstring_comment.txt
60
60
  tests/test_data/end_to_end/numpy/param_signature_without_type.txt
61
- tests/test_data/end_to_end/numpy/parameter_signature_sync.txt
62
61
  tests/test_data/end_to_end/numpy/parameters_returns_raises_wrapping.txt
63
62
  tests/test_data/end_to_end/numpy/returns_signature_and_description.txt
64
- tests/test_data/end_to_end/numpy/returns_signature_sync.txt
65
63
  tests/test_data/end_to_end/numpy/section_headings_with_colons.txt
66
64
  tests/test_data/end_to_end/numpy/section_title_fixed.txt
67
65
  tests/test_data/end_to_end/numpy/sections_notes_examples.txt
66
+ tests/test_data/end_to_end/numpy/signature_dont_sync_raises.txt
68
67
  tests/test_data/end_to_end/numpy/signature_line_is_not_wrapped.txt
68
+ tests/test_data/end_to_end/numpy/signature_sync_parameters.txt
69
+ tests/test_data/end_to_end/numpy/signature_sync_returns.txt
70
+ tests/test_data/end_to_end/numpy/signature_sync_yields.txt
69
71
  tests/test_data/end_to_end/numpy/single_line_docstring.txt
70
72
  tests/test_data/end_to_end/numpy/texts_are_rewrapped.txt
71
73
  tests/test_data/end_to_end/numpy/very_long_unbreakable_word.txt
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "format-docstring"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "A Python formatter to wrap/adjust docstring lines"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -0,0 +1,48 @@
1
+ LINE_LENGTH: 79
2
+
3
+ **********
4
+ def func1() -> Any:
5
+ """
6
+ Do something.
7
+
8
+ This test case is to make sure the raised exceptions are not modified by
9
+ this formatter.
10
+
11
+ Returns
12
+ -------
13
+ Any
14
+
15
+ Raises
16
+ ------
17
+ ValueError
18
+ When value is wrong. This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very long line.
19
+ IOError
20
+ When IO is wrong. This is a very very very very very very very very very very very very very very very very very very very very very very very very very very very long line.
21
+ """
22
+ pass
23
+
24
+ **********
25
+
26
+ def func1() -> Any:
27
+ """
28
+ Do something.
29
+
30
+ This test case is to make sure the raised exceptions are not modified by
31
+ this formatter.
32
+
33
+ Returns
34
+ -------
35
+ Any
36
+
37
+ Raises
38
+ ------
39
+ ValueError
40
+ When value is wrong. This is a very very very very very very very very
41
+ very very very very very very very very very very very very very very
42
+ very very very very very long line.
43
+ IOError
44
+ When IO is wrong. This is a very very very very very very very very
45
+ very very very very very very very very very very very very very very
46
+ very very very very very long line.
47
+ """
48
+ pass
@@ -84,6 +84,35 @@ def custom_return_type_2() -> tuple['MyType1', "MyType2"]:
84
84
  """
85
85
  pass
86
86
 
87
+
88
+ def with_return_var_name_1() -> str:
89
+ """
90
+ Do something
91
+
92
+ Returns
93
+ -------
94
+ result:float
95
+ The result
96
+ """
97
+ pass
98
+
99
+
100
+ def with_return_var_name_2() -> tuple[str, int, int]:
101
+ """
102
+ Do something
103
+
104
+ Returns
105
+ -------
106
+ name:
107
+ The name
108
+ index :bool
109
+ The index
110
+ status: str
111
+ The status
112
+ """
113
+ pass
114
+
115
+
87
116
  **********
88
117
  from typing import List
89
118
 
@@ -167,3 +196,31 @@ def custom_return_type_2() -> tuple['MyType1', "MyType2"]:
167
196
  Integer
168
197
  """
169
198
  pass
199
+
200
+
201
+ def with_return_var_name_1() -> str:
202
+ """
203
+ Do something
204
+
205
+ Returns
206
+ -------
207
+ result : str
208
+ The result
209
+ """
210
+ pass
211
+
212
+
213
+ def with_return_var_name_2() -> tuple[str, int, int]:
214
+ """
215
+ Do something
216
+
217
+ Returns
218
+ -------
219
+ name : str
220
+ The name
221
+ index : int
222
+ The index
223
+ status : int
224
+ The status
225
+ """
226
+ pass
@@ -0,0 +1,103 @@
1
+ LINE_LENGTH: 79
2
+
3
+ **********
4
+ from collections.abc import Generator, Iterator
5
+
6
+
7
+ def yield_numbers() -> Iterator[int]:
8
+ """
9
+ Yield numbers.
10
+
11
+ Yields
12
+ ------
13
+ str
14
+ Should match annotation.
15
+ """
16
+ yield 1
17
+
18
+
19
+ def yield_named() -> Generator[int, None, None]:
20
+ """
21
+ Yield named.
22
+
23
+ Yields
24
+ ------
25
+ result : str
26
+ Should match annotation.
27
+ """
28
+ yield 1
29
+
30
+
31
+ def yield_custom_type_1() -> Iterator['MyType1']:
32
+ """
33
+ Yield custom type.
34
+
35
+ Yields
36
+ ------
37
+ str
38
+ """
39
+ yield 'value'
40
+
41
+
42
+ def yield_custom_type_2() -> Iterator[tuple['MyType1', "MyType2"]]:
43
+ """
44
+ Yield another custom type.
45
+
46
+ Yields
47
+ ------
48
+ str
49
+ Combined values.
50
+ """
51
+ yield 'value'
52
+ yield 1
53
+
54
+ **********
55
+ from collections.abc import Generator, Iterator
56
+
57
+
58
+ def yield_numbers() -> Iterator[int]:
59
+ """
60
+ Yield numbers.
61
+
62
+ Yields
63
+ ------
64
+ Iterator[int]
65
+ Should match annotation.
66
+ """
67
+ yield 1
68
+
69
+
70
+ def yield_named() -> Generator[int, None, None]:
71
+ """
72
+ Yield named.
73
+
74
+ Yields
75
+ ------
76
+ result : Generator[int, None, None]
77
+ Should match annotation.
78
+ """
79
+ yield 1
80
+
81
+
82
+ def yield_custom_type_1() -> Iterator['MyType1']:
83
+ """
84
+ Yield custom type.
85
+
86
+ Yields
87
+ ------
88
+ Iterator['MyType1']
89
+ """
90
+ yield 'value'
91
+
92
+
93
+ def yield_custom_type_2() -> Iterator[tuple['MyType1', "MyType2"]]:
94
+ """
95
+ Yield another custom type.
96
+
97
+ Yields
98
+ ------
99
+ Iterator[tuple['MyType1', "MyType2"]]
100
+ Combined values.
101
+ """
102
+ yield 'value'
103
+ yield 1