Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ba7b80b

Browse files
committed
PEP 685: Fix grammar & clarity issues, improve phrasing & avoid rep
1 parent d58495e commit ba7b80b

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

pep-0685.rst

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ name "must be a valid Python identifier".
2828
letter, digit, or any one of ``.``, ``-``, or ``_`` after the initial character.
2929
Otherwise, there is no other `PyPA specification
3030
<https://packaging.python.org/en/latest/specifications/>`_
31-
which outlines how extra names should be written or normalization for comparison.
31+
which outlines how extra names should be written or normalized for comparison.
3232
Due to the amount of packaging-related code in existence,
3333
it is important to evaluate current practices by the community and
34-
standardize on one that doesn't break most code, while being
34+
standardize on one that doesn't break most existing code, while being
3535
something tool authors can agree to following.
3636

37-
The issue of there being no standard was brought forward by an
37+
The issue of there being no consistent standard was brought forward by an
3838
`initial discussion <https://discuss.python.org/t/7614>`__
3939
noting that the extra ``adhoc-ssl`` was not considered equal to the name
4040
``adhoc_ssl`` by pip 22.
@@ -47,21 +47,23 @@ Rationale
4747

4848
re.sub(r"[-_.]+", "-", name).lower()
4949

50-
This collapses any run of the substitution character down to a single
51-
character,
52-
e.g. ``---`` gets collapsed down to ``-``.
53-
This does **not** produce a valid Python identifier as specified by
50+
This collapses any run of the characters ``-``, ``_`` and ``.``
51+
down to a single ``-``.
52+
For example, ``---`` ``.`` and ``__`` all get converted to just ``-``.
53+
This does **not** produce a valid Python identifier, per
5454
the core metadata 2.2 specification for extra names.
5555

56-
`Setuptools 60 does normalization <https://github.com/pypa/setuptools/blob/b2f7b8f92725c63b164d5776f85e67cc560def4e/pkg_resources/__init__.py#L1324-L1330>`__
56+
`Setuptools 60 performs normalization <https://github.com/pypa/setuptools/blob/b2f7b8f92725c63b164d5776f85e67cc560def4e/pkg_resources/__init__.py#L1324-L1330>`__
5757
via::
5858

5959
re.sub(r'[^A-Za-z0-9-.]+', '_', name).lower()
6060

61-
The use of an underscore/``_`` differs from PEP 503's use of a
62-
hyphen/``-``.
63-
Runs of ``.`` and ``-``, unlike PEP 503, do **not** get collapsed,
64-
e.g. ``..`` stays the same.
61+
The use of an underscore/``_`` differs from PEP 503's use of a hyphen/``-``,
62+
and it also normalizes characters outside of those allowed by :pep`508`.
63+
Runs of ``.`` and ``-``, unlike PEP 503, do **not** get normalized to one ``_``,
64+
e.g. ``..`` stays the same. To note, this is inconsistent with this function's
65+
docstring, which *does* specify that all non-alphanumeric characters
66+
(which would include ``-`` and ``.``) are normalized and collapsed.
6567

6668
For pip 22, its
6769
`"extra normalisation behaviour is quite convoluted and erratic" <pip-erratic_>`__,
@@ -96,7 +98,7 @@ name is provided as appropriate for the specified core metadata version.
9698
If an older core metadata version is specified and the name would be
9799
invalid with newer core metadata versions,
98100
tools SHOULD warn the user.
99-
Tools SHOULD warn users when an invalid extra name is read and not use
101+
Tools SHOULD warn users when an invalid extra name is read and SHOULD not use
100102
the name to avoid ambiguity.
101103
Tools MAY raise an error instead of a warning when reading an
102104
invalid name, if they so desire.
@@ -105,21 +107,20 @@ invalid name, if they so desire.
105107
Backwards Compatibility
106108
=======================
107109

108-
Moving to :pep:`503` normalization and :pep:`508` name acceptance, it
110+
Moving to :pep:`503` normalization and :pep:`508` name acceptance,
109111
allows for all preexisting, valid names to continue to be valid.
110112

111113
Based on `research looking at a collection of wheels on PyPI <pypi-results_>`__,
112-
the risk of extra name clashes is limited to 73 clashes when considering
113-
even invalid names,
114+
the risk of extra name clashes is limited to 73 instances when considering
115+
all extras names on PyPI, valid or not (not just those within a single package)
114116
while *only* looking at valid names leads to only 3 clashes:
115117

116118
* ``dev-test``: ``dev_test``, ``dev-test``, ``dev.test``
117119
* ``dev-lint``: ``dev-lint``, ``dev.lint``, ``dev_lint``
118120
* ``apache-beam``: ``apache-beam``, ``apache.beam``
119121

120122
By requiring tools writing core metadata to only record the normalized name,
121-
the issue of preexisting, invalid extra names should be diminished over
122-
time.
123+
the issue of preexisting, invalid extra names should diminish over time.
123124

124125
.. _pypi-results: https://discuss.python.org/t/14141/17
125126

@@ -128,7 +129,7 @@ Security Implications
128129
=====================
129130

130131
It is possible that for a distribution that has conflicting extra names, a
131-
tool ends up installing distributions that somehow weaken the security
132+
tool ends up installing dependencies that somehow weaken the security
132133
of the system.
133134
This is only hypothetical and if it were to occur,
134135
it would probably be more of a security concern for the distributions
@@ -149,7 +150,7 @@ Reference Implementation
149150

150151
No reference implementation is provided aside from the code above,
151152
but the expectation is the `packaging project`_ will provide a
152-
function in its ``packaging.utils`` that will implement extra name
153+
function in its ``packaging.utils`` module that will implement extra name
153154
normalization.
154155
It will also implement extra name comparisons appropriately.
155156
Finally, if the project ever gains the ability to write out metadata,
@@ -162,17 +163,12 @@ Rejected Ideas
162163
Using setuptools 60's normalization
163164
-----------------------------------
164165

165-
Initially, this PEP proposed following setuptools to try to minimize
166-
backwards-compatibility issues.
167-
But after checking various wheels on PyPI,
166+
Initially, this PEP proposed using setuptools ``safe_extra()`` for normalization
167+
to try to minimize backwards-compatibility issues.
168+
However, after checking various wheels on PyPI,
168169
it became clear that standardizing **all** naming on :pep:`508` and
169-
:pep:`503` semantics was easier and better long-term.
170-
171-
172-
Open Issues
173-
===========
174-
175-
N/A
170+
:pep:`503` semantics was easier and better long-term,
171+
while causing minimal backwards compatibility issues.
176172

177173

178174
Copyright

0 commit comments

Comments
 (0)