You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this would be useful in typing-extensions too, so let's backport it.
I don't like the name very much though, and it might look even more confusing outside of annotationlib. We can still change it in CPython too, suggestions welcome.
type_repr is the established name for this, so I'd go with that. I think I would avoid use of "value"? (It makes more sense in PEP 649 context, but this function will get used in all kinds of places)
Been looking at this backporting issue and the name discussion. I agree that value_to_string isn't ideal – especially outside the original annotationlib context. Plus, I've run into naming collisions with similar helper functions in the past, so picking something more specific definitely makes sense.
type_repr seems like the best option to me too. It clearly conveys what the function does and as @hauntsaninja pointed out, it's already a somewhat established convention.
So, I'd suggest backporting the function with the name type_repr. Here’s a quick sketch of what the backported function could look like:
Activity
srittau commentedon Mar 20, 2025
Some suggestions:
type_namepretty_type_nameformat_type_nametype_reprhauntsaninja commentedon Mar 21, 2025
type_repris the established name for this, so I'd go with that. I think I would avoid use of "value"? (It makes more sense in PEP 649 context, but this function will get used in all kinds of places)Mizokuiam commentedon Mar 23, 2025
Been looking at this backporting issue and the name discussion. I agree that
value_to_stringisn't ideal – especially outside the originalannotationlibcontext. Plus, I've run into naming collisions with similar helper functions in the past, so picking something more specific definitely makes sense.type_reprseems like the best option to me too. It clearly conveys what the function does and as @hauntsaninja pointed out, it's already a somewhat established convention.So, I'd suggest backporting the function with the name
type_repr. Here’s a quick sketch of what the backported function could look like:Should be pretty straightforward to integrate. Let me know if anything comes up.
Add backport for `annotationlib.type_repr`
Add backport for `annotationlib.type_repr` (#641)