gh-124412: Add helpers for converting annotations to source format by JelleZijlstra · Pull Request #124551 · python/cpython
Can you rebase this so the changes from #124479 are no longer included in it?
|
|
||
|
|
||
| def annotations_to_source(annotations): | ||
| """Convert an annotation dict containing values to approximately the SOURCE format.""" |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"approximately the SOURCE format" 😆
Comment on lines 245 to 247
| if isinstance(obj, tuple): | ||
| # Special case for `repr` of types with `ParamSpec`: | ||
| return '[' + ', '.join(_type_repr(t) for t in obj) + ']' |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a case we don't want in value_to_source?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it's specifically for the internals of Callable and doesn't make sense in general. (Notice that it represents tuples with list syntax.)
emilyemorehouse added a commit to lysnikolaou/cpython that referenced this pull request
Sep 26, 2024This 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