Skip to content

Commit 9a44319

Browse files
committed
chore: use StrEnum from Python 3.11
Signed-off-by: Henry Schreiner <[email protected]>
1 parent e450e86 commit 9a44319

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
hooks:
2626
- id: mypy
2727
name: mypy 3.11 on cibuildwheel/
28-
exclude: ^cibuildwheel/resources/.*py|bin/generate_schema.py$
28+
exclude: ^cibuildwheel/resources/.*py$
2929
args: ["--python-version=3.11"]
3030
additional_dependencies: &mypy-dependencies
3131
- bracex

cibuildwheel/architecture.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from __future__ import annotations
22

3-
import functools
43
import platform as platform_module
54
import re
65
import shutil
76
import subprocess
87
import sys
98
from collections.abc import Set
10-
from enum import Enum
9+
from enum import StrEnum, auto
1110
from typing import Final, Literal, assert_never
1211

1312
from .typing import PlatformName
@@ -39,38 +38,28 @@ def _check_aarch32_el0() -> bool:
3938
return check.returncode == 0 and check.stdout.startswith("armv")
4039

4140

42-
@functools.total_ordering
43-
class Architecture(Enum):
44-
value: str
45-
41+
class Architecture(StrEnum):
4642
# mac/linux archs
47-
x86_64 = "x86_64"
43+
x86_64 = auto()
4844

4945
# linux archs
50-
i686 = "i686"
51-
aarch64 = "aarch64"
52-
ppc64le = "ppc64le"
53-
s390x = "s390x"
54-
armv7l = "armv7l"
46+
i686 = auto()
47+
aarch64 = auto()
48+
ppc64le = auto()
49+
s390x = auto()
50+
armv7l = auto()
5551

5652
# mac archs
57-
universal2 = "universal2"
58-
arm64 = "arm64"
53+
universal2 = auto()
54+
arm64 = auto()
5955

6056
# windows archs
61-
x86 = "x86"
62-
AMD64 = "AMD64"
63-
ARM64 = "ARM64"
57+
x86 = auto()
58+
AMD64 = auto()
59+
ARM64 = auto()
6460

6561
# WebAssembly
66-
wasm32 = "wasm32"
67-
68-
# Allow this to be sorted
69-
def __lt__(self, other: Architecture) -> bool:
70-
return self.value < other.value
71-
72-
def __str__(self) -> str:
73-
return self.name
62+
wasm32 = auto()
7463

7564
@staticmethod
7665
def parse_config(config: str, platform: PlatformName) -> set[Architecture]:

0 commit comments

Comments
 (0)