Skip to content

Commit f1af4a7

Browse files
authored
PEP 691: touch up (#2668)
1 parent d51fe24 commit f1af4a7

1 file changed

Lines changed: 27 additions & 33 deletions

File tree

‎pep-0691.rst‎

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ return data, whose interpretation is defined by the version of that data, and th
144144
serialized into the target serialization format.
145145

146146

147+
.. _json-serialization:
148+
147149
JSON Serialization
148150
------------------
149151

@@ -217,13 +219,14 @@ Project Detail
217219
~~~~~~~~~~~~~~
218220

219221
The format of this URL is ``/<project>/`` where the ``<project>`` is replaced by the
220-
:pep:`503` normalized name for that project, so a project named "Holy_Grail" would
221-
have a URL like ``/holy-grail/``.
222+
:pep:`503` normalized name for that project, so a project named "Silly_Walk" would
223+
have a URL like ``/silly-walk/``.
224+
225+
This URL must respond with a JSON encoded dictionary that has three keys:
222226

223-
This URL must respond with a JSON encoded dictionary that has three keys, ``name``,
224-
which represents the normalized name of the project, ``files``. The ``files`` key is
225-
a list of dictionaries, each one representing an individual file. Finally the ``meta``
226-
key which is the general response metadata described earlier.
227+
- ``name``: The normalized name of the project.
228+
- ``files``: A list of dictionaries, each one representing an individual file.
229+
- ``meta``: The general response metadata as `described earlier <json-serialization_>`__.
227230

228231
Each individual file dictionary has the following keys:
229232

@@ -236,7 +239,7 @@ Each individual file dictionary has the following keys:
236239

237240
The ``hashes`` dictionary **MUST** be present, even if no hashes are available
238241
for the file, however it is **HIGHLY** recommended that at least one secure,
239-
guaranteed to be available hash is always included.
242+
guaranteed-to-be-available hash is always included.
240243

241244
By default, any hash algorithm available via `hashlib
242245
<https://docs.python.org/3/library/hashlib.html>`_ (specifically any that can
@@ -254,11 +257,12 @@ Each individual file dictionary has the following keys:
254257
- ``dist-info-metadata``: An **optional** key that indicates
255258
that metadata for this file is available, via the same location as specified in
256259
:pep:`658` (``{file_url}.metadata``). Where this is present, it **MUST** be
257-
boolean to indicate if the file has an associated metadata file, or a dictionary
258-
mapping hash names to a hex encoded digest of the metadata's hash.
260+
either a boolean to indicate if the file has an associated metadata file, or a
261+
dictionary mapping hash names to a hex encoded digest of the metadata's hash.
259262

260-
When this is a dictionary of hashes, then all the same requirements and
261-
recommendations as the ``hashes`` key hold true for this key as well.
263+
When this is a dictionary of hashes instead of a boolean, then all the same
264+
requirements and recommendations as the ``hashes`` key hold true for this key as
265+
well.
262266

263267
If this key is missing then the metadata file may or may not exist. If the key
264268
value is truthy, then the metadata file is present, and if it is falsey then it
@@ -267,11 +271,12 @@ Each individual file dictionary has the following keys:
267271
It is recommended that servers make the hashes of the metadata file available if
268272
possible.
269273
- ``gpg-sig``: An **optional** key that acts a boolean to indicate if the file has
270-
an associated GPG signature or not. If this key does not exist, then the signature
271-
may or may not exist.
272-
- ``yanked``: An **optional** key which may be a boolean to indicate if the file
273-
has been yanked, or a non empty, but otherwise arbitrary, string to indicate that
274-
a file has been yanked with a specific reason. If the ``yanked`` key is present
274+
an associated GPG signature or not. The URL for the signature file follows what
275+
is specified in :pep:`503` (``{file_url}.asc``). If this key does not exist, then
276+
the signature may or may not exist.
277+
- ``yanked``: An **optional** key which may be either a boolean to indicate if the
278+
file has been yanked, or a non empty, but otherwise arbitrary, string to indicate
279+
that a file has been yanked with a specific reason. If the ``yanked`` key is present
275280
and is a truthy value, then it **SHOULD** be interpreted as indicating that the
276281
file pointed to by the ``url`` field has been "Yanked" as per :pep:`592`.
277282

@@ -417,7 +422,7 @@ content type over another, they may use the ``Accept`` header's
417422
syntax.
418423

419424
This allows a client to specify a priority for a specific entry in their
420-
``Accept`` header, by append a ``;q=`` followed by a value between ``0`` and
425+
``Accept`` header, by appending a ``;q=`` followed by a value between ``0`` and
421426
``1`` inclusive, with up to 3 decimal digits. When interpreting this value,
422427
an entry with a higher quality has priority over an entry with a lower quality,
423428
and any entry without a quality present will default to a quality of ``1``.
@@ -607,14 +612,15 @@ It is recommended that servers:
607612
long as they're receiving non trivial traffic that uses the HTML responses.
608613

609614
- When encountering an ``Accept`` header that does not contain any content types
610-
that it knows how to work with, should not ever return a ``300 Multiple Choice``
611-
response, and it should be preferred to return a ``406 Not Acceptable`` response.
615+
that it knows how to work with, the server should not ever return a
616+
``300 Multiple Choice`` response, and instead return a ``406 Not Acceptable``
617+
response.
612618

613619
- However, if choosing to use the endpoint configuration, you should prefer to
614620
return a ``200 OK`` response in the expected content type for that endpoint.
615621

616-
- When selecting an acceptable version, should choose the highest version that
617-
the client supports, with the most expressive/featureful serialization format,
622+
- When selecting an acceptable version, the server should choose the highest version
623+
that the client supports, with the most expressive/featureful serialization format,
618624
taking into account the specificity of the client requests as well as any
619625
quality priority values they have expressed, and it should only use the
620626
``text/html`` content type as a last resort.
@@ -694,18 +700,6 @@ so if there's some new piece of data that an installer might need, future PEPs c
694700
easily make that available.
695701

696702

697-
Why is the root URL a dictionary instead of a list?
698-
---------------------------------------------------
699-
700-
The most natural direct translation of the root URL being a list of links is to turn
701-
it into a list of objects. However, stepping back, that's not the most natural way
702-
to actually represent this data. This was a result of a HTML limitation that we had to
703-
work around. With a list (either of ``<a>`` tags, or objects) there's nothing stopping
704-
you from listing the same project twice and other unwanted patterns.
705-
706-
A dictionary also allows for an average of constant-time access given the project name.
707-
708-
709703
Why include the filename when the URL has it already?
710704
-----------------------------------------------------
711705

0 commit comments

Comments
 (0)