We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
目前业务代码中使用 blue_krill.data_types.enum.StructuredEnum 的枚举类,大量使用 int, str 作为 mixin, 以便在编写业务逻辑时,无需使用 .value 即可进行比较,字符串格式化(format / f-string),例子如下:
blue_krill.data_types.enum.StructuredEnum
.value
class StoreType(str, StructuredEnum): S3 = EnumField("s3") BKREPO = EnumField("bkrepo") class PluginRole(int, StructuredEnum): ADMINISTRATOR = EnumField(2) DEVELOPER = EnumField(3)
但是在 Python 3.11 中,基础 Enum 的 str() 行为发生了变化,例如:
from enum import Enum class Foo(str, Enum): BAR = "bar" # Python 3.10 f"{Foo.BAR}" # > bar # Python 3.11 f"{Foo.BAR}" # > Foo.BAR
由于 blue_krill 需要兼容存量的非 3.11+ 的项目,不能直接替换基础的 OrigEnum,需要评估如何处理
相关链接:
str
int
The text was updated successfully, but these errors were encountered:
遵循 3.11 中内置 enum 模块的使用标准,并参考其实现,提供 StrStructuredEnum / IntStructuredEnum 两个类,行为类似内置模块的 StrEnum 和 IntEnum 怎么样?
ref:
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
目前业务代码中使用
blue_krill.data_types.enum.StructuredEnum
的枚举类,大量使用 int, str 作为 mixin,以便在编写业务逻辑时,无需使用
.value
即可进行比较,字符串格式化(format / f-string),例子如下:但是在 Python 3.11 中,基础 Enum 的 str() 行为发生了变化,例如:
由于 blue_krill 需要兼容存量的非 3.11+ 的项目,不能直接替换基础的 OrigEnum,需要评估如何处理
相关链接:
str
orint
Mixin Breaking Change in Python 3.11 python/cpython#100458The text was updated successfully, but these errors were encountered: