stripe-python icon indicating copy to clipboard operation
stripe-python copied to clipboard

Create a type alias for `stripe.TaxId.type` and others

Open hofrob opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

I want to re-use the long list of VAT types for my internal methods. Currently, they are copy pasted throughout the library. This means there's no way to just re-use them as a type alias.

Describe the solution you'd like

Create a typing.TypeAlias with the string literals and expose it.

Describe alternatives you've considered

Creating a type alias from the existing class properties did not work. This might be because of my limited understanding of how type hints can be re-used or extracted from external libraries.

Additional context

No response

hofrob avatar May 08 '24 11:05 hofrob

It might make sense to rewrite these methods to use StrEnums instead.

hofrob avatar May 08 '24 12:05 hofrob

Thanks for flagging! This is something I'll look into.

xavdid-stripe avatar May 08 '24 20:05 xavdid-stripe

@hofrob Can you tell us more about your use case here? You're correct that it's not easy to extract that type, but it's something we can probably surface.

xavdid-stripe avatar May 09 '24 20:05 xavdid-stripe