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:
Tomáš Hozza 2023-04-11 14:38:49 +02:00 committed by Tomáš Hozza
parent c59c5c31de
commit bf3e096735
3 changed files with 11 additions and 22 deletions

View file

@ -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