Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add one-line summary to some warnings #3328

Merged
merged 6 commits into from May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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:`).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this clarification!


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__)