From b0515ff9d94e7f6edeca7ac24fc871e092c44953 Mon Sep 17 00:00:00 2001 From: Blazej Michalik Date: Fri, 6 May 2022 15:56:02 +0200 Subject: [PATCH 1/2] Document exceptions raised by functions in utils --- docs/utils.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/utils.rst b/docs/utils.rst index 192def74..ec6d1f1e 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -63,6 +63,8 @@ Reference instance of :class:`~packaging.tags.Tag`. :param str filename: The name of the wheel file. + :raises packaging.utils.InvalidWheelFilename: If the filename in question + does not follow conventions outlined in `PEP 427`_. .. doctest:: @@ -87,6 +89,9 @@ Reference represented by an instance of :class:`~packaging.version.Version`. :param str filename: The name of the sdist file. + :raises packaging.utils.InvalidSdistFilename: If the filename does not end + with an sdist extension (``.zip`` or ``.tar.gz``), or if it does not + contain a dash separating the name and the version of the distribution. .. doctest:: @@ -99,3 +104,4 @@ Reference True .. _Source distribution format: https://packaging.python.org/specifications/source-distribution-format/#source-distribution-file-name +.. _`PEP 427`: https://peps.python.org/pep-0427/#file-name-convention From 5839a3f3ef8a578da6712837c3ad71a2919c1867 Mon Sep 17 00:00:00 2001 From: Blazej Michalik Date: Mon, 9 May 2022 23:25:40 +0200 Subject: [PATCH 2/2] Document InvalidWheelFilename and InvalidSdistFilename Also applied suggestions from code review Co-authored-by: Brett Cannon --- docs/utils.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/utils.rst b/docs/utils.rst index ec6d1f1e..7a4c2f74 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -63,7 +63,7 @@ Reference instance of :class:`~packaging.tags.Tag`. :param str filename: The name of the wheel file. - :raises packaging.utils.InvalidWheelFilename: If the filename in question + :raises InvalidWheelFilename: If the filename in question does not follow conventions outlined in `PEP 427`_. .. doctest:: @@ -89,7 +89,7 @@ Reference represented by an instance of :class:`~packaging.version.Version`. :param str filename: The name of the sdist file. - :raises packaging.utils.InvalidSdistFilename: If the filename does not end + :raises InvalidSdistFilename: If the filename does not end with an sdist extension (``.zip`` or ``.tar.gz``), or if it does not contain a dash separating the name and the version of the distribution. @@ -103,5 +103,14 @@ Reference >>> ver == Version('1.0') True + +.. exception:: InvalidWheelFilename + + Raised when a file name for a wheel is invalid. + +.. exception:: InvalidSdistFilename + + Raised when a source distribution file name is considered invalid. + .. _Source distribution format: https://packaging.python.org/specifications/source-distribution-format/#source-distribution-file-name .. _`PEP 427`: https://peps.python.org/pep-0427/#file-name-convention