commit: c36abcbef28a151c464ed3176672a5cac4aa2b24
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Sun Jan 15 21:28:11 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Feb 2 19:59:11 2023 +0000
URL:
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=c36abcbe
refactor(config): simplify render_prepends signature.
The flatten argument is purely type specific, and there are no
users of this function beyond one internal site. Thus simplify
the API (to make typing easier), and to make future refactoring easier.
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/config/central.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/pkgcore/config/central.py b/src/pkgcore/config/central.py
index b142963b4..128538364 100644
--- a/src/pkgcore/config/central.py
+++ b/src/pkgcore/config/central.py
@@ -8,6 +8,7 @@ __all__ = (
"ConfigManager",
)
+import typing
import weakref
from collections import defaultdict, deque, namedtuple
from itertools import chain
@@ -75,7 +76,7 @@ class _ConfigStack(defaultdict):
return val
return None
- def render_prepends(self, manager, key, type_name, flatten=True):
+ def render_prepends(self, manager, key: str, type_name: str) ->
list[typing.Any]:
results = []
# keep in mind that the sequence we get is a top -> bottom walk of the
config
# as such for this operation we have to reverse it when building the
content-
@@ -94,7 +95,7 @@ class _ConfigStack(defaultdict):
if append:
results += [append]
- if flatten:
+ if type_name != "str":
results = chain.from_iterable(results)
return list(results)
@@ -544,9 +545,7 @@ class ConfigManager:
typename = typename[5:]
if typename.startswith("refs:") or typename in ("list", "str"):
- result = config_stack.render_prepends(
- self, key, typename, flatten=(typename != "str")
- )
+ result = config_stack.render_prepends(self, key, typename)
if typename == "str":
result = " ".join(result)
else: