File: enumTools.py

package info (click to toggle)
fonttools 4.61.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,584 kB
  • sloc: python: 145,091; xml: 103; makefile: 24
file content (23 lines) | stat: -rw-r--r-- 502 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Enum-related utilities, including backports for older Python versions."""

from __future__ import annotations

from enum import Enum


__all__ = ["StrEnum"]

# StrEnum is only available in Python 3.11+
try:
    from enum import StrEnum
except ImportError:

    class StrEnum(str, Enum):
        """
        Minimal backport of Python 3.11's StrEnum for older versions.

        An Enum where all members are also strings.
        """

        def __str__(self) -> str:
            return self.value