Skip to content

Commit

Permalink
Add one-line summary to some warnings (#3328)
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed May 18, 2022
2 parents b416443 + 3eba1cb commit 344512a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/3328.misc.rst
@@ -0,0 +1 @@
Include a first line summary to some of the existing multi-line warnings.
5 changes: 4 additions & 1 deletion setuptools/command/build_py.py
Expand Up @@ -256,6 +256,7 @@ class _IncludePackageDataAbuse:
"""Inform users that package or module is included as 'data file'"""

MESSAGE = """\
Installing {importable!r} as data is deprecated, please list it in `packages`.
!!\n\n
############################
# Package would be ignored #
Expand All @@ -266,7 +267,9 @@ class _IncludePackageDataAbuse:
therefore is considered deprecated).
Please make sure that {importable!r} is included as a package by using
setuptools' `packages` configuration field or the proper discovery methods.
setuptools' `packages` configuration field or the proper discovery methods
(for example by using `find_namespace_packages(...)`/`find_namespace:`
instead of `find_packages(...)`/`find:`).
You can read more about "package discovery" and "data files" on setuptools
documentation page.
Expand Down
3 changes: 2 additions & 1 deletion setuptools/command/dist_info.py
Expand Up @@ -54,7 +54,8 @@ def _version(version: str) -> str:
try:
return str(packaging.version.Version(v)).replace("-", "_")
except packaging.version.InvalidVersion:
msg = f"""!!\n\n
msg = f"""Invalid version: {version!r}.
!!\n\n
###################
# Invalid version #
###################
Expand Down
8 changes: 5 additions & 3 deletions setuptools/config/_apply_pyprojecttoml.py
Expand Up @@ -341,7 +341,10 @@ def _acessor(obj):


class _WouldIgnoreField(UserWarning):
"""Inform users that ``pyproject.toml`` would overwrite previously defined metadata:
"""Inform users that ``pyproject.toml`` would overwrite previous metadata."""

MESSAGE = """\
{field!r} defined outside of `pyproject.toml` would be ignored.
!!\n\n
##########################################################################
# configuration would be ignored/result in error due to `pyproject.toml` #
Expand Down Expand Up @@ -369,5 +372,4 @@ class _WouldIgnoreField(UserWarning):
@classmethod
def message(cls, field, value):
from inspect import cleandoc
msg = "\n".join(cls.__doc__.splitlines()[1:])
return cleandoc(msg.format(field=field, value=value))
return cleandoc(cls.MESSAGE.format(field=field, value=value))
5 changes: 2 additions & 3 deletions setuptools/config/pyprojecttoml.py
Expand Up @@ -418,7 +418,7 @@ class _ExperimentalProjectMetadata(UserWarning):


class _InvalidFile(UserWarning):
"""Inform users that the given `pyproject.toml` is experimental:
"""The given `pyproject.toml` file is invalid and would be ignored.
!!\n\n
############################
# Invalid `pyproject.toml` #
Expand All @@ -436,5 +436,4 @@ class _InvalidFile(UserWarning):
@classmethod
def message(cls):
from inspect import cleandoc
msg = "\n".join(cls.__doc__.splitlines()[1:])
return cleandoc(msg)
return cleandoc(cls.__doc__)

0 comments on commit 344512a

Please sign in to comment.