fix: fix annotated typing#1692
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1692 +/- ##
==========================================
+ Coverage 99.57% 99.59% +0.01%
==========================================
Files 23 23
Lines 5678 5681 +3
==========================================
+ Hits 5654 5658 +4
+ Misses 24 23 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
| class _WithAnnotatedDecorator(Protocol): | ||
| """The signature-preserving decorator ``with_annotated(...)`` returns (generic per call).""" | ||
|
|
||
| def __call__(self, fn: "Callable[_CommandParams, _CommandReturn]", /) -> "Callable[_CommandParams, _CommandReturn]": ... |
There was a problem hiding this comment.
Unnecessary string annotations for Callable can cause type variable binding issues.
Since Callable, _CommandParams, and _CommandReturn are already defined, there is no need to use string forward references here. Unquoted types ensure better compatibility and correct type variable binding across different type checkers (like mypy or pyright).
Recommend:
def __call__(self, fn: Callable[_CommandParams, _CommandReturn], /) -> Callable[_CommandParams, _CommandReturn]:| return handler, subcmd_name, parser_builder | ||
|
|
||
|
|
||
| _CommandParams = ParamSpec("_CommandParams") |
There was a problem hiding this comment.
Recommend adding a brief bug fix blurb to the CHANGELOG.md file about fixing type hinting for this stuff.
close #1684