Re: [PATCH 09/26] rv/rvgen: replace inline NotImplemented with decorator
From: Nam Cao <hidden>
Date: 2026-01-22 14:57:45
Also in:
lkml
Wander Lairson Costa [off-list ref] writes:
Replace inline NotImplementedError raises with a dedicated decorator in the ltl2ba module. The previous implementation used explicit raise statements inside abstract method bodies for BinaryOp and UnaryOp classes, which required maintaining identical boilerplate across seven different methods that need to be overridden by subclasses. All stub methods in generator.py have been converted from returning strings to using the decorator with ellipsis function bodies, which is the recommended Python style for marking incomplete interface methods. This ensures that any attempt to use unimplemented functionality fails fast with a clear exception rather than silently propagating string values through the code. The new @not_implemented decorator consolidates this pattern into a single reusable definition that clearly marks abstract methods while reducing code duplication. The decorator creates a wrapper that raises NotImplementedError with the function name, providing the same runtime behavior with improved maintainability. Method bodies now use the ellipsis literal instead of pass statements, which is the preferred Python convention for stub methods according to PEP 8. Signed-off-by: Wander Lairson Costa <redacted>
Reviewed-by: Nam Cao <redacted>