aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2023-01-15 13:28:11 -0800
committerArthur Zamarin <arthurzam@gentoo.org>2023-02-02 21:59:11 +0200
commitc36abcbef28a151c464ed3176672a5cac4aa2b24 (patch)
treed134e2e694a85a4e4356fbf75046b50e7e50ae28
parentrefactor(config): Remove ConfigHint/configurable positional arg support (diff)
downloadpkgcore-c36abcbef28a151c464ed3176672a5cac4aa2b24.tar.gz
pkgcore-c36abcbef28a151c464ed3176672a5cac4aa2b24.tar.bz2
pkgcore-c36abcbef28a151c464ed3176672a5cac4aa2b24.zip
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@gmail.com> Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/pkgcore/config/central.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/pkgcore/config/central.py b/src/pkgcore/config/central.py
index b142963b..12853836 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: