docstring-tailor 0.3.0__tar.gz → 0.3.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 (85) hide show
  1. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/PKG-INFO +7 -2
  2. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/README.md +6 -1
  3. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/makefile +1 -1
  4. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/pyproject.toml +1 -1
  5. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/cli_config.py +0 -1
  6. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/main.py +12 -4
  7. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/renderer/base_renderer.py +10 -6
  8. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/uv.lock +1 -1
  9. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/.gitignore +0 -0
  10. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/LICENSE +0 -0
  11. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/__init__.py +0 -0
  12. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/constants.py +0 -0
  13. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/docstring_visitor.py +0 -0
  14. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/ir_model.py +0 -0
  15. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/parser/indentation_based/google_docstring_parser.py +0 -0
  16. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/parser/indentation_based/indentation_based_parser.py +0 -0
  17. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/parser/indentation_based/numpy_docstring_parser.py +0 -0
  18. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/parser/indentation_based/structured_list_parser.py +0 -0
  19. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/parser/parser_factory.py +0 -0
  20. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/renderer/google_renderer.py +0 -0
  21. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/renderer/numpy_renderer.py +0 -0
  22. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/renderer/renderer_factory.py +0 -0
  23. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/utils/__init__.py +0 -0
  24. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/utils/utils_cli.py +0 -0
  25. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/utils/utils_file_system.py +0 -0
  26. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/utils/utils_formatting.py +0 -0
  27. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/utils/utils_keyword_translation.py +0 -0
  28. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/utils/utils_list_detection.py +0 -0
  29. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/utils/utils_parsing.py +0 -0
  30. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/src/docstring_tailor/utils/utils_printing.py +0 -0
  31. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/temp.md +0 -0
  32. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/cases/__init__.py +0 -0
  33. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/cases/config_model.py +0 -0
  34. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/cases/formatting_cases.py +0 -0
  35. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/class_docstring/class_docstring_100.py +0 -0
  36. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/class_docstring/class_docstring_60.py +0 -0
  37. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/class_docstring/class_docstring_80.py +0 -0
  38. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/code_block_multiple/code_block_multiple_80.py +0 -0
  39. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/code_block_multiple/code_block_multiple_blank_lines.py +0 -0
  40. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/code_block_singular/code_block_singular_80.py +0 -0
  41. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/code_block_singular/code_block_singular_blank_lines.py +0 -0
  42. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/code_repl_multiple/code_repl_multiple_80.py +0 -0
  43. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/code_repl_multiple/code_repl_multiple_blank_lines.py +0 -0
  44. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/code_repl_singular/code_repl_singular_80.py +0 -0
  45. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/code_repl_singular/code_repl_singular_blank_lines.py +0 -0
  46. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/empty/empty_80.py +0 -0
  47. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/empty/empty_blank_lines.py +0 -0
  48. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/empty/empty_no_space.py +0 -0
  49. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/named_paragraph_code_block/named_paragraph_code_block_80.py +0 -0
  50. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/named_paragraph_code_block/named_paragraph_code_block_blank_lines.py +0 -0
  51. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/named_paragraph_code_repl/named_paragraph_code_repl_80.py +0 -0
  52. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/named_paragraph_code_repl/named_paragraph_code_repl_blank_lines.py +0 -0
  53. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/named_paragraph_paragraph/named_paragraph_paragraph_100.py +0 -0
  54. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/named_paragraph_paragraph/named_paragraph_paragraph_60.py +0 -0
  55. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/named_paragraph_paragraph/named_paragraph_paragraph_80.py +0 -0
  56. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/named_paragraph_paragraph/named_paragraph_paragraph_wrong_input.py +0 -0
  57. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_and_simple_list/paragraph_and_simple_list_100.py +0 -0
  58. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_and_simple_list/paragraph_and_simple_list_60.py +0 -0
  59. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_and_simple_list/paragraph_and_simple_list_80.py +0 -0
  60. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_and_simple_list/paragraph_and_simple_list_wrong_input.py +0 -0
  61. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_multi_line/paragraph_multi_line_100.py +0 -0
  62. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_multi_line/paragraph_multi_line_60.py +0 -0
  63. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_multi_line/paragraph_multi_line_80.py +0 -0
  64. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_multi_line/paragraph_multi_line_wrong_input.py +0 -0
  65. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_one_line/paragraph_one_line_100.py +0 -0
  66. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_one_line/paragraph_one_line_60.py +0 -0
  67. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_one_line/paragraph_one_line_80.py +0 -0
  68. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/paragraph_one_line/paragraph_one_line_wrong_input.py +0 -0
  69. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/simple_list/simple_list_100.py +0 -0
  70. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/simple_list/simple_list_60.py +0 -0
  71. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/simple_list/simple_list_80.py +0 -0
  72. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/simple_list/simple_list_wrong_input.py +0 -0
  73. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/structured_list/structured_list_100.py +0 -0
  74. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/structured_list/structured_list_60.py +0 -0
  75. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/structured_list/structured_list_80.py +0 -0
  76. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/docstring_elements/structured_list/structured_list_wrong_input.py +0 -0
  77. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/function_docstring/function_docstring_100.py +0 -0
  78. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/function_docstring/function_docstring_60.py +0 -0
  79. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/function_docstring/function_docstring_80.py +0 -0
  80. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/module_docstring/module_docstring_100.py +0 -0
  81. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/module_docstring/module_docstring_60.py +0 -0
  82. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/module_docstring/module_docstring_80.py +0 -0
  83. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/fixtures/readme_examples/readme_examples.py +0 -0
  84. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/test_docstring_tailor.py +0 -0
  85. {docstring_tailor-0.3.0 → docstring_tailor-0.3.1}/tests/utils/utils_testing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstring-tailor
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Formats Python docstrings to PEP 257 style with configurable line length.
5
5
  Author-email: Auke Bruinsma <afbruinsma@gmail.com>
6
6
  License: MIT License
@@ -556,7 +556,11 @@ Steps:
556
556
 
557
557
  ### 60 characters per line — The Minimalist Monk 🧘
558
558
 
559
- You believe every character has a purpose and every extra column is a personal failure 😤. You keep your docstrings short, your functions tiny, and your emotional attachment to whitespace surprisingly strong. You don't need room to explain your code because your code should be obvious. If a sentence doesn't fit in 60 characters, you simply rewrite the sentence until it does. Brevity is not a preference for you. Brevity is a lifestyle.
559
+ You believe every character has a purpose and every extra column is a personal failure 😤. You keep your docstrings short, your functions tiny, and your emotional attachment to whitespace surprisingly strong. Variable names? Anything longer than two characters is wasteful bloat — x, y, z, and i are sufficient for any problem. Docstrings are memory theft; everything the code needs to say should be obvious from context or inferred through pure spiritual understanding 🙏. Why document when you could just make the code so minimalist that it transcends the need for explanation? Your motto: if it takes more than 60 characters to explain, the explanation itself is the bug, not the code.
560
+
561
+ ### 79 characters per line — The Precision Tuner ⚙️
562
+
563
+ You didn't choose 79 characters; you derived it through first principles and a spreadsheet. You read every formatter's GitHub issues, every style guide's rationale, and you have strong opinions about why 80 is overrated but 78 is cowardice 😤. You've A/B tested readability on three different monitors, measured your own eye-tracking data, and lost sleep over whether \n counts toward the limit or not. You configure your linter to lint your linter, and you have a .editorconfig file that is longer than most people's actual code 📋. You know exactly why PEP 8 suggested 79 and you've defended this choice at dinner parties with the fervor of someone protecting their firstborn child 🛡️. You don't just use docstring_tailor; you've benchmarked it against seven alternatives and created a spreadsheet ranking their consistency. Your line length is not a preference—it's a thesis 📊. You sleep well knowing that you have optimized, and the universe is in perfect order, exactly 79 characters wide.
560
564
 
561
565
  ### 80 characters per line — The Digital Archaeologist 🦖
562
566
 
@@ -605,6 +609,7 @@ You don't wrap text because wrapping is a skill issue. You let photons travel un
605
609
  | `0.2.0` | 2026-06-07 | Feature update | <ul><li>Implemented the `detect-lists` parameter, adding support for unordered and ordered (numbered) lists in docstrings. When enabled, list structures are detected automatically and each list item is formatted onto its own line.</li><li>Introduced a declarative golden-file test framework for formatter validation. Test cases are now generated from parametrized templates using Cartesian-product expansion, significantly reducing boilerplate and improving scalability for configuration coverage.</li><li>Expanded this `README.md` with the 'API Overview', 'Release Notes', 'Example docstrings' and 'Roadmap' sections.</li><li>Test coverage: 75%</li></ul> |
606
610
  | `0.2.1` | 2026-06-11 | Feature update | <ul><li>Added the `-V`/`--version` command to the CLI.</li><li>Added the `--exclude` command to the CLI.</li><li>Added the `--diff` command to the CLI.</li><li>Added the 'Demo' part to to the `README.md`.</ul> |
607
611
  | `0.3.0` | 2026-07-20 | Feature update & bug fixes | <ul><li>Introduced a style-agnostic intermediate representation (IR) model and refactored parsing into an abstract base class hierarchy. Google and NumPy docstrings now parse into the same IR via `IndentationBasedParser` subclasses, enabling lossless conversion between styles. Structured list parsing is delegated to style-specific implementations to handle syntactic differences (Google's inline `name (type):` vs. NumPy's `name : type` on separate lines).</li><li>Refactored rendering to match the parser architecture: `DocstringRendererBase` (ABC) with style-specific subclasses that implement two hooks — section header formatting (Google's `Args:` vs. NumPy's `Parameters` + underline) and section body indentation rules (confirmed against numpy's own docstrings to keep bodies flush with headers, unlike Google). Keyword translation between styles happens automatically during conversion.</li><li>Code sections and Python REPL blocks now also can be created outside the 'Example(s)' section.</li><li>Fixed a bug when codeblock sections contain blank lines.</li><li>Fixed a bug when the docstring starts immediately with an (un)ordered list.</li><li>Removed `detect-lists` as CLI parameter, because the logic should always be applied if the docstring contains (un)ordered lists.</li><li>Changed behaviour for empty docstrings so that it consistent with Ruff.</li></ul> |
612
+ | `0.3.1` | 2026-07-21 | Small fixes | <ul><li>The `style` parameter does not have a default argument anymore, instead it always has to be configured explicitly by the user.</li><li>Fixed a bug where one-line docstrings inside indented scopes (e.g. class or method bodies) were wrapped to multiple lines prematurely, due to indentation being counted twice when checking against the configured line length.</li> <li>Added an exception, consistent with Ruff, allowing a one-line docstring to exceed the configured line length by up to 3 characters when only the closing triple quotes would otherwise be pushed onto their own line. This prevents docstring_tailor and Ruff from repeatedly reformatting the same docstring back and forth when both are run as pre-commit hooks.</li></ul> |
608
613
 
609
614
  ## Roadmap
610
615
 
@@ -523,7 +523,11 @@ Steps:
523
523
 
524
524
  ### 60 characters per line — The Minimalist Monk 🧘
525
525
 
526
- You believe every character has a purpose and every extra column is a personal failure 😤. You keep your docstrings short, your functions tiny, and your emotional attachment to whitespace surprisingly strong. You don't need room to explain your code because your code should be obvious. If a sentence doesn't fit in 60 characters, you simply rewrite the sentence until it does. Brevity is not a preference for you. Brevity is a lifestyle.
526
+ You believe every character has a purpose and every extra column is a personal failure 😤. You keep your docstrings short, your functions tiny, and your emotional attachment to whitespace surprisingly strong. Variable names? Anything longer than two characters is wasteful bloat — x, y, z, and i are sufficient for any problem. Docstrings are memory theft; everything the code needs to say should be obvious from context or inferred through pure spiritual understanding 🙏. Why document when you could just make the code so minimalist that it transcends the need for explanation? Your motto: if it takes more than 60 characters to explain, the explanation itself is the bug, not the code.
527
+
528
+ ### 79 characters per line — The Precision Tuner ⚙️
529
+
530
+ You didn't choose 79 characters; you derived it through first principles and a spreadsheet. You read every formatter's GitHub issues, every style guide's rationale, and you have strong opinions about why 80 is overrated but 78 is cowardice 😤. You've A/B tested readability on three different monitors, measured your own eye-tracking data, and lost sleep over whether \n counts toward the limit or not. You configure your linter to lint your linter, and you have a .editorconfig file that is longer than most people's actual code 📋. You know exactly why PEP 8 suggested 79 and you've defended this choice at dinner parties with the fervor of someone protecting their firstborn child 🛡️. You don't just use docstring_tailor; you've benchmarked it against seven alternatives and created a spreadsheet ranking their consistency. Your line length is not a preference—it's a thesis 📊. You sleep well knowing that you have optimized, and the universe is in perfect order, exactly 79 characters wide.
527
531
 
528
532
  ### 80 characters per line — The Digital Archaeologist 🦖
529
533
 
@@ -572,6 +576,7 @@ You don't wrap text because wrapping is a skill issue. You let photons travel un
572
576
  | `0.2.0` | 2026-06-07 | Feature update | <ul><li>Implemented the `detect-lists` parameter, adding support for unordered and ordered (numbered) lists in docstrings. When enabled, list structures are detected automatically and each list item is formatted onto its own line.</li><li>Introduced a declarative golden-file test framework for formatter validation. Test cases are now generated from parametrized templates using Cartesian-product expansion, significantly reducing boilerplate and improving scalability for configuration coverage.</li><li>Expanded this `README.md` with the 'API Overview', 'Release Notes', 'Example docstrings' and 'Roadmap' sections.</li><li>Test coverage: 75%</li></ul> |
573
577
  | `0.2.1` | 2026-06-11 | Feature update | <ul><li>Added the `-V`/`--version` command to the CLI.</li><li>Added the `--exclude` command to the CLI.</li><li>Added the `--diff` command to the CLI.</li><li>Added the 'Demo' part to to the `README.md`.</ul> |
574
578
  | `0.3.0` | 2026-07-20 | Feature update & bug fixes | <ul><li>Introduced a style-agnostic intermediate representation (IR) model and refactored parsing into an abstract base class hierarchy. Google and NumPy docstrings now parse into the same IR via `IndentationBasedParser` subclasses, enabling lossless conversion between styles. Structured list parsing is delegated to style-specific implementations to handle syntactic differences (Google's inline `name (type):` vs. NumPy's `name : type` on separate lines).</li><li>Refactored rendering to match the parser architecture: `DocstringRendererBase` (ABC) with style-specific subclasses that implement two hooks — section header formatting (Google's `Args:` vs. NumPy's `Parameters` + underline) and section body indentation rules (confirmed against numpy's own docstrings to keep bodies flush with headers, unlike Google). Keyword translation between styles happens automatically during conversion.</li><li>Code sections and Python REPL blocks now also can be created outside the 'Example(s)' section.</li><li>Fixed a bug when codeblock sections contain blank lines.</li><li>Fixed a bug when the docstring starts immediately with an (un)ordered list.</li><li>Removed `detect-lists` as CLI parameter, because the logic should always be applied if the docstring contains (un)ordered lists.</li><li>Changed behaviour for empty docstrings so that it consistent with Ruff.</li></ul> |
579
+ | `0.3.1` | 2026-07-21 | Small fixes | <ul><li>The `style` parameter does not have a default argument anymore, instead it always has to be configured explicitly by the user.</li><li>Fixed a bug where one-line docstrings inside indented scopes (e.g. class or method bodies) were wrapped to multiple lines prematurely, due to indentation being counted twice when checking against the configured line length.</li> <li>Added an exception, consistent with Ruff, allowing a one-line docstring to exceed the configured line length by up to 3 characters when only the closing triple quotes would otherwise be pushed onto their own line. This prevents docstring_tailor and Ruff from repeatedly reformatting the same docstring back and forth when both are run as pre-commit hooks.</li></ul> |
575
580
 
576
581
  ## Roadmap
577
582
 
@@ -45,7 +45,7 @@ git:
45
45
 
46
46
  # Run full workflow: format, type-check, test, clean, commit
47
47
  all:
48
- uv run src/docstring_tailor/main.py format --line-length 80
48
+ uv run src/docstring_tailor/main.py format --style google --line-length 80
49
49
  make ruff
50
50
  make ty
51
51
  make pytest
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "docstring-tailor"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  description = "Formats Python docstrings to PEP 257 style with configurable line length."
5
5
  authors = [{ name = "Auke Bruinsma", email = "afbruinsma@gmail.com" }]
6
6
  license = { file = "LICENSE" }
@@ -17,7 +17,6 @@ class DocstringStyle(str, Enum):
17
17
 
18
18
 
19
19
  SUPPORTED_STYLES = {DocstringStyle.google, DocstringStyle.numpy}
20
- DEFAULT_STYLE = DocstringStyle.google
21
20
 
22
21
  # Argument: '--line-length'
23
22
  LINE_LENGTH_MIN: int = 30
@@ -16,7 +16,6 @@ import typer
16
16
 
17
17
  from docstring_tailor.cli_config import (
18
18
  DEFAULT_PATHS,
19
- DEFAULT_STYLE,
20
19
  LINE_LENGTH_DEFAULT,
21
20
  LINE_LENGTH_MAX,
22
21
  LINE_LENGTH_MIN,
@@ -198,9 +197,18 @@ def format_command(
198
197
  resolved_paths, resolved_line_length, resolved_exclude, file_config = (
199
198
  _resolve_common_options(paths=paths, line_length=line_length, exclude=exclude)
200
199
  )
201
- resolved_style = style or DocstringStyle(
202
- file_config.get("style", DEFAULT_STYLE.value)
203
- )
200
+
201
+ resolved_style = style or file_config.get("style")
202
+
203
+ if resolved_style is None:
204
+ typer.echo(
205
+ "Error: Docstring style not specified. "
206
+ "Pass --style on the command line or set 'style' in your config file "
207
+ "(pyproject.toml or docstring_tailor.toml)."
208
+ )
209
+ raise typer.Exit(code=1)
210
+
211
+ resolved_style = DocstringStyle(resolved_style)
204
212
 
205
213
  _validate_supported_style(resolved_style)
206
214
 
@@ -552,10 +552,11 @@ class DocstringRendererBase(ABC):
552
552
  immediately without attempting a render.
553
553
 
554
554
  1. Determines the raw content: empty string, or the sole Paragraph's
555
- text.
556
- 2. Normalizes internal whitespace to single spaces.
557
- 3. Rejects the one-line rendering if the delimited content exceeds the
558
- wrap width.
555
+ text. 2. Normalizes internal whitespace to single spaces. 3. Rejects the
556
+ one-line rendering if the total physical line length exceeds the
557
+ configured line length by more than DOCSTRING_DELIMITER_LENGTH
558
+ characters. This allows up to 3 characters of overage (the closing
559
+ \"\"\") for Ruff compatibility in pre-commit hooks.
559
560
 
560
561
  Args:
561
562
  ir (list[DocstringNode]): Fully parsed and typed IR from a parser.
@@ -563,7 +564,8 @@ class DocstringRendererBase(ABC):
563
564
  Returns:
564
565
  one_line (str | None): The rendered one-line docstring including
565
566
  triple-quote delimiters, or None if the IR does not qualify or
566
- is too long to fit.
567
+ exceeds the line length by more than DOCSTRING_DELIMITER_LENGTH
568
+ characters.
567
569
  """
568
570
  if not ir:
569
571
  content = ""
@@ -579,7 +581,9 @@ class DocstringRendererBase(ABC):
579
581
  + 2 * DOCSTRING_DELIMITER_LENGTH
580
582
  )
581
583
 
582
- if total_length > self._wrap_width:
584
+ # Allow up to DOCSTRING_DELIMITER_LENGTH characters of overage (the
585
+ # closing """) for Ruff compatibility in pre-commit hooks.
586
+ if total_length > self._line_length + DOCSTRING_DELIMITER_LENGTH:
583
587
  return None
584
588
 
585
589
  one_line = DOCSTRING_DELIMITER + normalized + DOCSTRING_DELIMITER
@@ -119,7 +119,7 @@ toml = [
119
119
 
120
120
  [[package]]
121
121
  name = "docstring-tailor"
122
- version = "0.2.2"
122
+ version = "0.3.1"
123
123
  source = { editable = "." }
124
124
  dependencies = [
125
125
  { name = "libcst" },