Skip to content

Commit 344512a

Browse files
committed
Add one-line summary to some warnings (#3328)
2 parents b416443 + 3eba1cb commit 344512a

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

changelog.d/3328.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Include a first line summary to some of the existing multi-line warnings.

setuptools/command/build_py.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class _IncludePackageDataAbuse:
256256
"""Inform users that package or module is included as 'data file'"""
257257

258258
MESSAGE = """\
259+
Installing {importable!r} as data is deprecated, please list it in `packages`.
259260
!!\n\n
260261
############################
261262
# Package would be ignored #
@@ -266,7 +267,9 @@ class _IncludePackageDataAbuse:
266267
therefore is considered deprecated).
267268
268269
Please make sure that {importable!r} is included as a package by using
269-
setuptools' `packages` configuration field or the proper discovery methods.
270+
setuptools' `packages` configuration field or the proper discovery methods
271+
(for example by using `find_namespace_packages(...)`/`find_namespace:`
272+
instead of `find_packages(...)`/`find:`).
270273
271274
You can read more about "package discovery" and "data files" on setuptools
272275
documentation page.

setuptools/command/dist_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def _version(version: str) -> str:
5454
try:
5555
return str(packaging.version.Version(v)).replace("-", "_")
5656
except packaging.version.InvalidVersion:
57-
msg = f"""!!\n\n
57+
msg = f"""Invalid version: {version!r}.
58+
!!\n\n
5859
###################
5960
# Invalid version #
6061
###################

setuptools/config/_apply_pyprojecttoml.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ def _acessor(obj):
341341

342342

343343
class _WouldIgnoreField(UserWarning):
344-
"""Inform users that ``pyproject.toml`` would overwrite previously defined metadata:
344+
"""Inform users that ``pyproject.toml`` would overwrite previous metadata."""
345+
346+
MESSAGE = """\
347+
{field!r} defined outside of `pyproject.toml` would be ignored.
345348
!!\n\n
346349
##########################################################################
347350
# configuration would be ignored/result in error due to `pyproject.toml` #
@@ -369,5 +372,4 @@ class _WouldIgnoreField(UserWarning):
369372
@classmethod
370373
def message(cls, field, value):
371374
from inspect import cleandoc
372-
msg = "\n".join(cls.__doc__.splitlines()[1:])
373-
return cleandoc(msg.format(field=field, value=value))
375+
return cleandoc(cls.MESSAGE.format(field=field, value=value))

setuptools/config/pyprojecttoml.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class _ExperimentalProjectMetadata(UserWarning):
418418

419419

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

0 commit comments

Comments
 (0)