[PATCH fedrq] backends: adjust type-checking for Reldep lists
Export this patch
Reldep is currently not represented by an abstract class. The
recommended way to use them is just to call `str()` on whatever the
backend returns. At least, we can type it as `Any` and use `Collection`
which is more specific than `Iterable`.
---
src/fedrq/backends/base/__init__.py | 20 +++++++++----------
.../backends/libdnf5/backend/__init__.py | 20 +++++++++----------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/fedrq/backends/base/__init__.py b/src/fedrq/backends/base/__init__.py
index 42b9e87..31e7307 100644
--- a/src/fedrq/backends/base/__init__.py
+++ b/src/fedrq/backends/base/__init__.py
@@ -7,7 +7,7 @@ import abc
import dataclasses
import importlib.resources
import logging
-from collections.abc import Callable, Collection, Iterable, Iterator
+from collections.abc import Callable, Collection, Iterable, Iterator, Sequence
from datetime import date
from typing import TYPE_CHECKING, Any, Generic, Optional, Protocol, TypeVar
from warnings import warn
@@ -105,35 +105,35 @@ class PackageCompat(metaclass=abc.ABCMeta): # pragma: no cover
@property
@abc.abstractmethod
- def provides(self) -> Iterable: ...
+ def provides(self) -> Collection[Any]: ...
@property
@abc.abstractmethod
- def requires(self) -> Iterable: ...
+ def requires(self) -> Collection[Any]: ...
@property
@abc.abstractmethod
- def recommends(self) -> Iterable: ...
+ def recommends(self) -> Collection[Any]: ...
@property
@abc.abstractmethod
- def suggests(self) -> Iterable: ...
+ def suggests(self) -> Collection[Any]: ...
@property
@abc.abstractmethod
- def supplements(self) -> Iterable: ...
+ def supplements(self) -> Collection[Any]: ...
@property
@abc.abstractmethod
- def enhances(self) -> Iterable: ...
+ def enhances(self) -> Collection[Any]: ...
@property
@abc.abstractmethod
- def obsoletes(self) -> Iterable: ...
+ def obsoletes(self) -> Collection[Any]: ...
@property
@abc.abstractmethod
- def conflicts(self) -> Iterable: ...
+ def conflicts(self) -> Collection[Any]: ...
@property
@abc.abstractmethod
@@ -161,7 +161,7 @@ class PackageCompat(metaclass=abc.ABCMeta): # pragma: no cover
@property
@abc.abstractmethod
- def files(self) -> Iterable[str]: ...
+ def files(self) -> Sequence[str]: ...
@property
@abc.abstractmethod
diff --git a/src/fedrq/backends/libdnf5/backend/__init__.py b/src/fedrq/backends/libdnf5/backend/__init__.py
index f836091..2729c67 100644
--- a/src/fedrq/backends/libdnf5/backend/__init__.py
+++ b/src/fedrq/backends/libdnf5/backend/__init__.py
@@ -14,7 +14,7 @@ import logging
import sys
import typing as t
import warnings
-from collections.abc import Collection, Iterable, Iterator
+from collections.abc import Collection, Iterable, Iterator, Sequence
from datetime import datetime as DT
from datetime import timezone as TZ
from enum import Enum
@@ -564,35 +564,35 @@ class Package(libdnf5.rpm.Package, PackageCompat):
return self.get_install_size()
@property
- def provides(self) -> Iterable[Reldep5]:
+ def provides(self) -> Collection[Reldep5]:
return self.get_provides()
@property
- def requires(self) -> Iterable[Reldep5]:
+ def requires(self) -> Collection[Reldep5]:
return self.get_requires()
@property
- def recommends(self) -> Iterable[Reldep5]:
+ def recommends(self) -> Collection[Reldep5]:
return self.get_recommends()
@property
- def suggests(self) -> Iterable[Reldep5]:
+ def suggests(self) -> Collection[Reldep5]:
return self.get_suggests()
@property
- def supplements(self) -> Iterable[Reldep5]:
+ def supplements(self) -> Collection[Reldep5]:
return self.get_supplements()
@property
- def enhances(self) -> Iterable[Reldep5]:
+ def enhances(self) -> Collection[Reldep5]:
return self.get_enhances()
@property
- def obsoletes(self) -> Iterable[Reldep5]:
+ def obsoletes(self) -> Collection[Reldep5]:
return self.get_obsoletes()
@property
- def conflicts(self) -> Iterable[Reldep5]:
+ def conflicts(self) -> Collection[Reldep5]:
return self.get_conflicts()
@property
@@ -622,7 +622,7 @@ class Package(libdnf5.rpm.Package, PackageCompat):
return reason_str
@property
- def files(self) -> Iterable[str]:
+ def files(self) -> Sequence[str]:
return self.get_files()
@property
--
2.45.2
fedrq/patches: SUCCESS in 1m46s
[backends: adjust type-checking for Reldep lists][0] from [Maxwell G][1]
[0]: https://lists.sr.ht/~gotmax23/fedrq/patches/54309
[1]: mailto:maxwell@gtmx.me
✓ #1294868 SUCCESS fedrq/patches/epel9.yml https://builds.sr.ht/~gotmax23/job/1294868
✓ #1294870 SUCCESS fedrq/patches/mockbuild.yml https://builds.sr.ht/~gotmax23/job/1294870
✓ #1294869 SUCCESS fedrq/patches/main.yml https://builds.sr.ht/~gotmax23/job/1294869
✓ #1294871 SUCCESS fedrq/patches/test.yml https://builds.sr.ht/~gotmax23/job/1294871
Applied!