Skip to content

Commit 2f566e3

Browse files
Arm backend: Normalize enum signatures in API manifest (pytorch#19361)
Normalize Enum subclass signatures in the Arm public API manifest generator so the output stays stable across Python versions. Use a fixed `(*values)` signature for enum entries instead of relying on `inspect.signature()` for `EnumMeta.__call__`, and update the checked-in manifest snapshot to match. Signed-off-by: Sebastian Larsson <sebastian.larsson@arm.com>
1 parent 345977a commit 2f566e3

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

backends/arm/public_api_manifests/api_manifest_running.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ signature = "EthosUCompileSpec(target: str, system_config: str | None = None, me
2222

2323
[python.EthosUCompileSpec.DebugMode]
2424
kind = "enum"
25-
signature = "EthosUCompileSpec.DebugMode(value, names=None, *, module=None, qualname=None, type=None, start=1)"
25+
signature = "EthosUCompileSpec.DebugMode(*values)"
2626

2727
[python.EthosUCompileSpec.__eq__]
2828
kind = "function"
@@ -106,7 +106,7 @@ signature = "VgfCompileSpec(tosa_spec: executorch.backends.arm.tosa.specificatio
106106

107107
[python.VgfCompileSpec.DebugMode]
108108
kind = "enum"
109-
signature = "VgfCompileSpec.DebugMode(value, names=None, *, module=None, qualname=None, type=None, start=1)"
109+
signature = "VgfCompileSpec.DebugMode(*values)"
110110

111111
[python.VgfCompileSpec.__eq__]
112112
kind = "function"

backends/arm/scripts/generate_public_api_manifest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def _api_kind(obj: object) -> str:
6060

6161

6262
def _api_signature(path: str, obj: object) -> str:
63+
if inspect.isclass(obj) and issubclass(obj, enum.Enum):
64+
# EnumMeta.__call__ renders differently across Python versions.
65+
return f"{path}(*values)"
6366
try:
6467
return f"{path}{inspect.signature(cast(Any, obj))}"
6568
except (TypeError, ValueError):

0 commit comments

Comments
 (0)