From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/config/
Date: Thu, 2 Feb 2023 20:10:35 +0000 (UTC) [thread overview]
Message-ID: <1675367951.c36abcbef28a151c464ed3176672a5cac4aa2b24.arthurzam@gentoo> (raw)
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:
next reply other threads:[~2023-02-02 20:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 20:10 Arthur Zamarin [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-02-05 18:16 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/config/ Arthur Zamarin
2023-02-02 20:10 Arthur Zamarin
2023-01-17 20:50 Arthur Zamarin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1675367951.c36abcbef28a151c464ed3176672a5cac4aa2b24.arthurzam@gentoo \
--to=arthurzam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox