Repository navigation
Keep the type of params as written - #158
Merged
Merged
Conversation
A param's type loses its optional mark and default when they are split off: "int, optional" becomes type_name "int" and is_optional True. A linter comparing the docstring with an annotation needs what was written, so every param now keeps it as raw_type_name. It is None where no type was written. Compose still writes the type from type_name, is_optional and default.
rr-
force-pushed
the
rework/19-raw-type
branch
from
November 6, 2026 16:38
83ea7cd to
432016d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every style splits the optional mark and the default off a param's type. Once that happens, nobody can tell what the docstring actually said:
Users who compare a docstring against the code, like linters checking types against annotations, need the original text. pydoclint's fork of this library added the same field for Numpydoc. Here it covers all four styles:
:param str? x:and:type x: int, optionalx (int, optional):x : int, optional@type x: int, optionalraw_type_nameis None when no type is written. Return types are never split, so returns don't get the field. Compose still builds the type fromtype_name,is_optionalanddefault, so composed output stays the same.Case files show
raw_type_nameonly where it differs fromtype_name. That adds 478 lines to 167 case files: 137 corpus, 11 numpydoc, 9 google, 6 epydoc, 3 rest, 1 auto. By command: 289parse numpydoc, 163parse google, 18parse epydoc, 7parse rest, 1parse auto. No existing line changes.Parity against main, with the new field ignored: 0 of 29,074 docstrings differ.
Bench on 3.8: parse is 0.99–1.01x of main.