Fix errors reported by new version of mypy
Fix the following errors: ``` osbuild/util/lvm2.py:117: error: Only instance methods can be decorated with @property osbuild/api.py:50: error: Only instance methods can be decorated with @property osbuild/sources.py:85: error: Only instance methods can be decorated with @property ``` Chaining of `@classmethod` and `@property` has been deprecated since Python 3.11 with a note that chaining didn't work correctly in some cases. Relevant links: https://github.com/python/mypy/issues/13746 https://docs.python.org/3.11/whatsnew/3.11.html#language-builtins Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
c59c5c31de
commit
bf3e096735
3 changed files with 11 additions and 22 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,10 +113,7 @@ class CStruct:
|
|||
class Header:
|
||||
"""Abstract base class for all headers"""
|
||||
|
||||
@property
|
||||
@classmethod
|
||||
@abc.abstractmethod
|
||||
def struct(cls) -> Union[struct.Struct, CStruct]:
|
||||
struct: ClassVar[Union[struct.Struct, CStruct]]
|
||||
"""Definition of the underlying struct data"""
|
||||
|
||||
def __init__(self, data):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue