diff --git a/osbuild/api.py b/osbuild/api.py index 40daf8f6..08880136 100644 --- a/osbuild/api.py +++ b/osbuild/api.py @@ -8,7 +8,7 @@ import sys import tempfile import threading import traceback -from typing import Dict, Optional +from typing import ClassVar, Dict, Optional from .util import jsoncomm from .util.types import PathLike @@ -40,6 +40,9 @@ class BaseAPI(abc.ABC): call `_message.` """ + endpoint: ClassVar[str] + """The name of the API endpoint""" + def __init__(self, socket_address: Optional[PathLike] = None): self.socket_address = socket_address self.barrier = threading.Barrier(2) @@ -47,12 +50,6 @@ class BaseAPI(abc.ABC): self.thread = None self._socketdir = None - @property - @classmethod - @abc.abstractmethod - def endpoint(cls): - """The name of the API endpoint""" - @abc.abstractmethod def _message(self, msg: Dict, fds: jsoncomm.FdSet, sock: jsoncomm.Socket): """Called for a new incoming message diff --git a/osbuild/sources.py b/osbuild/sources.py index 7d2c43f4..fadb58d4 100644 --- a/osbuild/sources.py +++ b/osbuild/sources.py @@ -4,8 +4,7 @@ import contextlib import json import os import tempfile -from abc import abstractmethod -from typing import Dict, Tuple +from typing import ClassVar, Dict, Tuple from . import host from .objectstore import ObjectStore @@ -55,6 +54,9 @@ class SourceService(host.Service): max_workers = 1 + content_type: ClassVar[str] + """The content type of the source.""" + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.cache = None @@ -82,12 +84,6 @@ class SourceService(host.Service): for _ in executor.map(self.fetch_one, *zip(*transformed)): pass - @property - @classmethod - @abstractmethod - def content_type(cls): - """The content type of the source.""" - @staticmethod def load_items(fds): with os.fdopen(fds.steal(0)) as f: diff --git a/osbuild/util/lvm2.py b/osbuild/util/lvm2.py index 11414051..05677230 100644 --- a/osbuild/util/lvm2.py +++ b/osbuild/util/lvm2.py @@ -18,7 +18,6 @@ LVM2 sources[1], specifically: [1] https://github.com/lvmteam/lvm2 (commit 8801a86) """ -import abc import binascii import io import json @@ -27,7 +26,7 @@ import re import struct import sys from collections import OrderedDict -from typing import BinaryIO, Dict, List, Union +from typing import BinaryIO, ClassVar, Dict, List, Union PathLike = Union[str, bytes, os.PathLike] @@ -114,11 +113,8 @@ class CStruct: class Header: """Abstract base class for all headers""" - @property - @classmethod - @abc.abstractmethod - def struct(cls) -> Union[struct.Struct, CStruct]: - """Definition of the underlying struct data""" + struct: ClassVar[Union[struct.Struct, CStruct]] + """Definition of the underlying struct data""" def __init__(self, data): self.data = data