%pyproject_save_files: Expand the namespace error message, also display it with /

This commit is contained in:
Miro Hrončok 2021-09-08 23:09:54 +02:00
parent 6bbba680f4
commit 27cff80a5f
2 changed files with 20 additions and 9 deletions

View File

@ -6,7 +6,7 @@ License: MIT
# Keep the version at zero and increment only release # Keep the version at zero and increment only release
Version: 0 Version: 0
Release: 46%{?dist} Release: 47%{?dist}
# Macro files # Macro files
Source001: macros.pyproject Source001: macros.pyproject
@ -113,6 +113,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
%license LICENSE %license LICENSE
%changelog %changelog
* Thu Sep 09 2021 Miro Hrončok <mhroncok@redhat.com> - 0-47
- %%pyproject_save_files: Expand the namespace error message, also display it with /
* Fri Jul 23 2021 Miro Hrončok <miro@hroncok.cz> - 0-46 * Fri Jul 23 2021 Miro Hrončok <miro@hroncok.cz> - 0-46
- %%pyproject_buildrequires now fails when it encounters an invalid requirement - %%pyproject_buildrequires now fails when it encounters an invalid requirement
- Fixes: rhbz#1983053 - Fixes: rhbz#1983053

View File

@ -381,16 +381,25 @@ def parse_varargs(varargs):
>>> parse_varargs(['mod', 'mod.*']) >>> parse_varargs(['mod', 'mod.*'])
Traceback (most recent call last): Traceback (most recent call last):
... ...
ValueError: Attempted to use a namespaced package with dot in the glob: mod.*. ... ValueError: Attempted to use a namespaced package with . in the glob: mod.*. ...
>>> parse_varargs(['my.bad', '+bad']) >>> parse_varargs(['my.bad', '+bad'])
Traceback (most recent call last): Traceback (most recent call last):
... ...
ValueError: Attempted to use a namespaced package with dot in the glob: my.bad. ... ValueError: Attempted to use a namespaced package with . in the glob: my.bad. ...
>>> parse_varargs(['mod/submod'])
Traceback (most recent call last):
...
ValueError: Attempted to use a namespaced package with / in the glob: mod/submod. ...
""" """
include_auto = False include_auto = False
globs = set() globs = set()
namespace_error_template = (
"Attempted to use a namespaced package with {symbol} in the glob: {arg}. "
"That is not (yet) supported. Use {top} instead and see "
"https://bugzilla.redhat.com/1935266 for details."
)
for arg in varargs: for arg in varargs:
if arg.startswith("+"): if arg.startswith("+"):
if arg == "+auto": if arg == "+auto":
@ -399,11 +408,10 @@ def parse_varargs(varargs):
raise ValueError(f"Invalid argument: {arg}") raise ValueError(f"Invalid argument: {arg}")
elif "." in arg: elif "." in arg:
top, *_ = arg.partition(".") top, *_ = arg.partition(".")
msg = ( raise ValueError(namespace_error_template.format(symbol=".", arg=arg, top=top))
f"Attempted to use a namespaced package with dot in the glob: {arg}. " elif "/" in arg:
f"That is not (yet) supported. Use {top} instead and/or file a Bugzilla explaining your use case." top, *_ = arg.partition("/")
) raise ValueError(namespace_error_template.format(symbol="/", arg=arg, top=top))
raise ValueError(msg)
else: else:
globs.add(arg) globs.add(arg)