summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2023-08-23 10:58:17 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-09-13 08:30:21 +0200
commitfe19b33e2f76045617067dd5123041ae4d3a91ee (patch)
tree4246376602ed64f24ae4a4a2537ce5f0f88cc8a5 /docs
parent170b0a47b09d735132bcfdcc9b303397eb03b34b (diff)
Modernized enumeration helpers on Python 3.11+.
- use @enum.property https://docs.python.org/3/library/enum.html#enum.property - use @enum.nonmember Using @property on an enum class does not yield the expected result. do_not_call_in_templates attribute works because a @property instance is truthy. We can make this a literal True value as expected by using @enum.nonmember in Python 3.11+. https://docs.python.org/3/library/enum.html#enum.nonmember - used enum.IntEnum/StrEnum Python 3.11+ has ReprEnum which uses int.__str__() and str.__str__() for __str__() in the `IntEnum` and `StrEnum` subclasses. We can emulate that for Python < 3.11. https://docs.python.org/3/library/enum.html#enum.ReprEnum https://docs.python.org/3/library/enum.html#enum.IntEnum https://docs.python.org/3/library/enum.html#enum.StrEnum
Diffstat (limited to 'docs')
0 files changed, 0 insertions, 0 deletions