chore: use StrEnum from Python 3.11
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
committed by
Henry Schreiner
parent
63a7c44b7f
commit
2f62696400
@@ -25,7 +25,7 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
name: mypy 3.11 on cibuildwheel/
|
name: mypy 3.11 on cibuildwheel/
|
||||||
exclude: ^cibuildwheel/resources/.*py|bin/generate_schema.py$
|
exclude: ^cibuildwheel/resources/.*py$
|
||||||
args: ["--python-version=3.11"]
|
args: ["--python-version=3.11"]
|
||||||
additional_dependencies: &mypy-dependencies
|
additional_dependencies: &mypy-dependencies
|
||||||
- bracex
|
- bracex
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import functools
|
|
||||||
import platform as platform_module
|
import platform as platform_module
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from collections.abc import Set
|
from collections.abc import Set
|
||||||
from enum import Enum
|
from enum import StrEnum, auto
|
||||||
from typing import Final, Literal, assert_never
|
from typing import Final, Literal, assert_never
|
||||||
|
|
||||||
from .typing import PlatformName
|
from .typing import PlatformName
|
||||||
@@ -39,38 +38,28 @@ def _check_aarch32_el0() -> bool:
|
|||||||
return check.returncode == 0 and check.stdout.startswith("armv")
|
return check.returncode == 0 and check.stdout.startswith("armv")
|
||||||
|
|
||||||
|
|
||||||
@functools.total_ordering
|
class Architecture(StrEnum):
|
||||||
class Architecture(Enum):
|
|
||||||
value: str
|
|
||||||
|
|
||||||
# mac/linux archs
|
# mac/linux archs
|
||||||
x86_64 = "x86_64"
|
x86_64 = auto()
|
||||||
|
|
||||||
# linux archs
|
# linux archs
|
||||||
i686 = "i686"
|
i686 = auto()
|
||||||
aarch64 = "aarch64"
|
aarch64 = auto()
|
||||||
ppc64le = "ppc64le"
|
ppc64le = auto()
|
||||||
s390x = "s390x"
|
s390x = auto()
|
||||||
armv7l = "armv7l"
|
armv7l = auto()
|
||||||
|
|
||||||
# mac archs
|
# mac archs
|
||||||
universal2 = "universal2"
|
universal2 = auto()
|
||||||
arm64 = "arm64"
|
arm64 = auto()
|
||||||
|
|
||||||
# windows archs
|
# windows archs
|
||||||
x86 = "x86"
|
x86 = auto()
|
||||||
AMD64 = "AMD64"
|
AMD64 = "AMD64"
|
||||||
ARM64 = "ARM64"
|
ARM64 = "ARM64"
|
||||||
|
|
||||||
# WebAssembly
|
# WebAssembly
|
||||||
wasm32 = "wasm32"
|
wasm32 = auto()
|
||||||
|
|
||||||
# Allow this to be sorted
|
|
||||||
def __lt__(self, other: Architecture) -> bool:
|
|
||||||
return self.value < other.value
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_config(config: str, platform: PlatformName) -> set[Architecture]:
|
def parse_config(config: str, platform: PlatformName) -> set[Architecture]:
|
||||||
|
|||||||
Reference in New Issue
Block a user