[elbe-devel] [PATCH 04/10] elbepack: packers: implement abstract methods through abc

Thomas Weißschuh thomas.weissschuh at linutronix.de
Fri Feb 28 14:25:09 CET 2025


The "abc" module utilities validate that all abstract methods are implemented.
Replace the custom runtime validation with it.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/packers.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/elbepack/packers.py b/elbepack/packers.py
index d9eaec8ac280b2b98166aefa4e70a10a76db6d7a..505de5cca0b249aa0aecac6689e83bbc1fc28b74 100644
--- a/elbepack/packers.py
+++ b/elbepack/packers.py
@@ -2,16 +2,18 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 # SPDX-FileCopyrightText: 2019 Linutronix GmbH
 
+import abc
 import os
 import subprocess
 
 from elbepack.shellhelper import do
 
 
-class Packer:
+class Packer(abc.ABC):
 
+    @abc.abstractmethod
     def pack_file(self, _builddir, _fname):
-        raise NotImplementedError('abstract method called')
+        ...
 
 
 class NoPacker(Packer):

-- 
2.48.1



More information about the elbe-devel mailing list