diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-03-27 11:12:48 +0100 | 
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-03-27 11:14:23 +0100 | 
| commit | 93bae8213b21d23a6de2c40e5bb50ad723ad70a8 (patch) | |
| tree | 4ae1f2726fb94edfd02b86cf2a08ad605bcf183f /setuptools | |
| parent | cd9e7ac6e2e9d62c71f823a1df6de8fb6d734141 (diff) | |
| download | python-setuptools-git-93bae8213b21d23a6de2c40e5bb50ad723ad70a8.tar.gz | |
Improve error/warning messages
Diffstat (limited to 'setuptools')
| -rw-r--r-- | setuptools/config/_apply_pyprojecttoml.py | 7 | ||||
| -rw-r--r-- | setuptools/config/pyprojecttoml.py | 8 | ||||
| -rw-r--r-- | setuptools/tests/config/test_apply_pyprojecttoml.py | 2 | 
3 files changed, 10 insertions, 7 deletions
diff --git a/setuptools/config/_apply_pyprojecttoml.py b/setuptools/config/_apply_pyprojecttoml.py index 2a046a78..421368af 100644 --- a/setuptools/config/_apply_pyprojecttoml.py +++ b/setuptools/config/_apply_pyprojecttoml.py @@ -332,13 +332,16 @@ _PREVIOUSLY_DEFINED = {  class _WouldIgnoreField(UserWarning): -    """Inform users that ``pyproject.toml`` would overwrite previously defined metadata. +    """Inform users that ``pyproject.toml`` would overwrite previously defined metadata:      !!\n\n      ##############################################      # field would be ignored by `pyproject.toml` #      ############################################## -    `{field} = {value!r}` seems to be defined outside of `pyproject.toml`. +    The following seems to be defined outside of `pyproject.toml`: + +    `{field} = {value!r}` +      According to the spec (see the link bellow), however, setuptools CANNOT      consider this value unless {field!r} is listed as `dynamic`. diff --git a/setuptools/config/pyprojecttoml.py b/setuptools/config/pyprojecttoml.py index d4e1460c..a712a258 100644 --- a/setuptools/config/pyprojecttoml.py +++ b/setuptools/config/pyprojecttoml.py @@ -285,9 +285,9 @@ class _ConfigExpander:          previous = _PREVIOUSLY_DEFINED[field](dist)          if not previous and not self.ignore_option_errors:              msg = ( -                f"No configuration found for dynamic {field!r}. " -                "Some fields need to be specified via `tool.setuptools.dynamic` " -                "others must be specified via the equivalent attribute in `setup.py`." +                f"No configuration found for dynamic {field!r}.\n" +                "Some dynamic fields need to be specified via `tool.setuptools.dynamic`" +                "\nothers must be specified via the equivalent attribute in `setup.py`."              )              raise OptionError(msg) @@ -400,7 +400,7 @@ class _ExperimentalProjectMetadata(UserWarning):  class _InvalidFile(UserWarning): -    """Inform users that the given `pyproject.toml` is experimental. +    """Inform users that the given `pyproject.toml` is experimental:      !!\n\n      ############################      # Invalid `pyproject.toml` # diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index 42ec0f71..c09ff3e6 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -228,7 +228,7 @@ class TestPresetField:          """          pyproject = self.pyproject(tmp_path, [])          dist = makedist(tmp_path, **{attr: value}) -        msg = f"{field}.*seems to be defined outside of .pyproject.toml." +        msg = re.compile(f"defined outside of `pyproject.toml`:.*{field}", re.S)          with pytest.warns(_WouldIgnoreField, match=msg):              dist = pyprojecttoml.apply_configuration(dist, pyproject)  | 
