smithy-lang / smithy-python

Smithy code generators and core modules for Python (in development)
Apache License 2.0
48 stars 10 forks source link

Use StrEnum for string enums #240

Closed JordonPhillips closed 6 months ago

JordonPhillips commented 6 months ago

This updates generated classes for string enums to use the StrEnum base that was introduced in 3.11. Members of classes inheriting from StrEnum can be used as strings for most purposes. They do, however, have a repr and a type that is not compatible. Since we aren't actually using them in the type signature or returning them, these aren't important.

This doesn't majorly change the way customers engage with the generated class, though it does remove the need to generate a values method to list known values.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.