* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/scripts/
@ 2024-12-04 19:20 Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2024-12-04 19:20 UTC (permalink / raw
To: gentoo-commits
commit: 16790e10f1823aad3872b84db68978135c051202
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 4 18:45:45 2024 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Dec 4 19:19:31 2024 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=16790e10
fix argument parsing with Python 3.12.8
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
src/pkgcheck/scripts/argparse_actions.py | 8 +++++++-
src/pkgcheck/scripts/pkgcheck_scan.py | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/pkgcheck/scripts/argparse_actions.py b/src/pkgcheck/scripts/argparse_actions.py
index 02053cf9..4507e10f 100644
--- a/src/pkgcheck/scripts/argparse_actions.py
+++ b/src/pkgcheck/scripts/argparse_actions.py
@@ -216,7 +216,13 @@ class ChecksetArgs(arghparse.CommaSeparatedNegations):
args.append(f"--checks={checks}")
keywords = ",".join(enabled_keywords | {f"-{x}" for x in disabled_keywords})
args.append(f"--keywords={keywords}")
- parser._parse_known_args(args, namespace)
+ # Python 3.12.8 introduced obligatory intermixed arg. The same
+ # commit adds _parse_known_args2 function, so use that to determine
+ # if we need to pass that.
+ if hasattr(parser, "_parse_known_args2"):
+ parser._parse_known_args(args, namespace, intermixed=False)
+ else:
+ parser._parse_known_args(args, namespace)
class ScopeArgs(arghparse.CommaSeparatedNegations):
diff --git a/src/pkgcheck/scripts/pkgcheck_scan.py b/src/pkgcheck/scripts/pkgcheck_scan.py
index 7c11f810..7e554aab 100644
--- a/src/pkgcheck/scripts/pkgcheck_scan.py
+++ b/src/pkgcheck/scripts/pkgcheck_scan.py
@@ -375,7 +375,13 @@ def _setup_scan(parser, namespace, args):
patch("pkgcheck.scripts.argparse_actions.ChecksetArgs.__call__", lambda *a, **k: None),
patch("pkgcheck.scripts.argparse_actions.ExitArgs.__call__", lambda *a, **k: None),
):
- namespace, _ = parser._parse_known_args(args, namespace)
+ # Python 3.12.8 introduced obligatory intermixed arg. The same
+ # commit adds _parse_known_args2 function, so use that to determine
+ # if we need to pass that.
+ if hasattr(parser, "_parse_known_args2"):
+ namespace, _ = parser._parse_known_args(args, namespace, intermixed=False)
+ else:
+ namespace, _ = parser._parse_known_args(args, namespace)
# Get the current working directory for repo detection and restriction
# creation, fallback to the root dir if it's be removed out from under us.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/scripts/
@ 2023-06-29 15:41 Arthur Zamarin
0 siblings, 0 replies; 3+ messages in thread
From: Arthur Zamarin @ 2023-06-29 15:41 UTC (permalink / raw
To: gentoo-commits
commit: 5f1dc5c1d7e2c26cb7ce3353782d472e65a287c3
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 29 15:38:08 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 29 15:38:08 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=5f1dc5c1
scan: fix unknown exit checkset during initial config load
Similar to previous fix, `--exit`` also can accept checksets which come
from args, so we also need to "escape" failures of ExitArgs.
Follows: a2358d60680611d7cbe07068440031c3c6e68f31
Resolves: https://github.com/pkgcore/pkgcheck/issues/594
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/scripts/pkgcheck_scan.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/pkgcheck/scripts/pkgcheck_scan.py b/src/pkgcheck/scripts/pkgcheck_scan.py
index b83f569f..c04ff329 100644
--- a/src/pkgcheck/scripts/pkgcheck_scan.py
+++ b/src/pkgcheck/scripts/pkgcheck_scan.py
@@ -371,7 +371,9 @@ def _setup_scan(parser, namespace, args):
# have to be parsed twice, will probably require a custom snakeoil
# arghparse method.
# parse command line args to override config defaults
- with patch("pkgcheck.scripts.argparse_actions.ChecksetArgs.__call__", lambda *a, **k: None):
+ with patch(
+ "pkgcheck.scripts.argparse_actions.ChecksetArgs.__call__", lambda *a, **k: None
+ ), patch("pkgcheck.scripts.argparse_actions.ExitArgs.__call__", lambda *a, **k: None):
namespace, _ = parser._parse_known_args(args, namespace)
# Get the current working directory for repo detection and restriction
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/scripts/
@ 2023-05-11 18:08 Arthur Zamarin
0 siblings, 0 replies; 3+ messages in thread
From: Arthur Zamarin @ 2023-05-11 18:08 UTC (permalink / raw
To: gentoo-commits
commit: a2358d60680611d7cbe07068440031c3c6e68f31
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu May 11 18:01:53 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu May 11 18:01:53 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=a2358d60
scan: fix unknown checkset during initial config load
The config load is performed in multiple stages:
1. parse `--config` path
2. load bundled config
3. load user & system configs
4. parse cmd args (needed for repo and targets)
5. load repo's config
6. parse full cmd args
The problem is that the checkset is parsed during stage 4, which means
it hasn't loaded the repo's config yet. While a more correct solution
would be to parse only needed args during stage 4, it wasn't simple
since the targets collect everything, including cmd args. So instead
this just patches temporarily to not fail upon unknown checksets.
Resolves: https://github.com/pkgcore/pkgcheck/issues/576
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/scripts/pkgcheck_scan.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/pkgcheck/scripts/pkgcheck_scan.py b/src/pkgcheck/scripts/pkgcheck_scan.py
index 9abfe2b5..b83f569f 100644
--- a/src/pkgcheck/scripts/pkgcheck_scan.py
+++ b/src/pkgcheck/scripts/pkgcheck_scan.py
@@ -2,6 +2,7 @@ import argparse
import os
import shlex
from contextlib import ExitStack
+from unittest.mock import patch
from pkgcore import const as pkgcore_const
from pkgcore.repository import errors as repo_errors
@@ -370,7 +371,8 @@ def _setup_scan(parser, namespace, args):
# have to be parsed twice, will probably require a custom snakeoil
# arghparse method.
# parse command line args to override config defaults
- namespace, _ = parser._parse_known_args(args, namespace)
+ with patch("pkgcheck.scripts.argparse_actions.ChecksetArgs.__call__", lambda *a, **k: None):
+ namespace, _ = parser._parse_known_args(args, namespace)
# Get the current working directory for repo detection and restriction
# creation, fallback to the root dir if it's be removed out from under us.
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-04 19:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 19:20 [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/scripts/ Michał Górny
-- strict thread matches above, loose matches on Subject: below --
2023-06-29 15:41 Arthur Zamarin
2023-05-11 18:08 Arthur Zamarin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox