Skip to content

Commit 2a86924

Browse files
authored
Merge branch 'main' into ww/tp-discovery-pep
2 parents 60ba4b5 + 8dd1b2c commit 2a86924

12 files changed

Lines changed: 2395 additions & 454 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ peps/pep-0800.rst @JelleZijlstra
679679
peps/pep-0801.rst @warsaw
680680
peps/pep-0802.rst @AA-Turner
681681
peps/pep-0803.rst @encukou
682+
peps/pep-0804.rst @pradyunsg
682683
peps/pep-0807.rst @dstufft
683684
# ...
684685
peps/pep-2026.rst @hugovk

peps/pep-0351.rst

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ It is conceivable that third party objects also have similar mutable
3838
and immutable counterparts, and it would be useful to have a standard
3939
protocol for conversion of such objects.
4040

41-
sets.Set objects expose a "protocol for automatic conversion to
42-
immutable" so that you can create sets.Sets of sets.Sets. :pep:`218`
41+
``sets.Set`` objects expose a "protocol for automatic conversion to
42+
immutable" so that you can create ``sets.Set``'s of ``sets.Set``'s. :pep:`218`
4343
deliberately dropped this feature from built-in sets. This PEP
4444
advances that the feature is still useful and proposes a standard
4545
mechanism for its support.
@@ -48,22 +48,24 @@ mechanism for its support.
4848
Proposal
4949
========
5050

51-
It is proposed that a new built-in function called freeze() is added.
51+
It is proposed that a new built-in function called ``freeze()`` is added.
5252

53-
If freeze() is passed an immutable object, as determined by hash() on
54-
that object not raising a TypeError, then the object is returned
53+
If ``freeze()`` is passed an immutable object, as determined by ``hash()`` on
54+
that object not raising a ``TypeError``, then the object is returned
5555
directly.
5656

57-
If freeze() is passed a mutable object (i.e. hash() of that object
58-
raises a TypeError), then freeze() will call that object's
59-
__freeze__() method to get an immutable copy. If the object does not
60-
have a __freeze__() method, then a TypeError is raised.
57+
If ``freeze()`` is passed a mutable object (i.e. ``hash()`` of that object
58+
raises a ``TypeError``), then ``freeze()`` will call that object's
59+
``__freeze__()`` method to get an immutable copy. If the object does not
60+
have a ``__freeze__()`` method, then a ``TypeError`` is raised.
6161

6262

6363
Sample implementations
6464
======================
6565

66-
Here is a Python implementation of the freeze() built-in::
66+
Here is a Python implementation of the ``freeze()`` built-in:
67+
68+
.. code-block:: python
6769
6870
def freeze(obj):
6971
try:
@@ -73,9 +75,11 @@ Here is a Python implementation of the freeze() built-in::
7375
freezer = getattr(obj, '__freeze__', None)
7476
if freezer:
7577
return freezer()
76-
raise TypeError('object is not freezable')``
78+
raise TypeError('object is not freezable')
79+
80+
Here are some code samples which show the intended semantics:
7781

78-
Here are some code samples which show the intended semantics::
82+
.. code-block:: python
7983
8084
class xset(set):
8185
def __freeze__(self):
@@ -104,6 +108,8 @@ Here are some code samples which show the intended semantics::
104108
def __freeze__(self):
105109
return imdict(self)
106110
111+
.. code-block:: python-console
112+
107113
>>> s = set([1, 2, 3])
108114
>>> {s: 4}
109115
Traceback (most recent call last):
@@ -140,9 +146,9 @@ Reference implementation
140146
========================
141147

142148
Patch 1335812_ provides the C implementation of this feature. It adds the
143-
freeze() built-in, along with implementations of the __freeze__()
149+
``freeze()`` built-in, along with implementations of the ``__freeze__()``
144150
method for lists and sets. Dictionaries are not easily freezable in
145-
current Python, so an implementation of dict.__freeze__() is not
151+
current Python, so an implementation of ``dict.__freeze__()`` is not
146152
provided yet.
147153

148154
.. _1335812: http://sourceforge.net/tracker/index.php?func=detail&aid=1335812&group_id=5470&atid=305470
@@ -155,11 +161,11 @@ Open issues
155161
- Should dicts and sets automatically freeze their mutable keys?
156162

157163
- Should we support "temporary freezing" (perhaps with a method called
158-
__congeal__()) a la __as_temporarily_immutable__() in sets.Set?
164+
``__congeal__()``) a la ``__as_temporarily_immutable__()`` in ``sets.Set``?
159165

160-
- For backward compatibility with sets.Set, should we support
161-
__as_immutable__()? Or should __freeze__() just be renamed to
162-
__as_immutable__()?
166+
- For backward compatibility with ``sets.Set``, should we support
167+
``__as_immutable__()``? Or should ``__freeze__()`` just be renamed to
168+
``__as_immutable__()``?
163169

164170

165171
Copyright

peps/pep-0518.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ the ``pyproject.toml`` file will be::
164164

165165
[build-system]
166166
# Minimum requirements for the build system to execute.
167-
requires = ["setuptools", "wheel"] # PEP 508 specifications.
167+
requires = ["setuptools"] # PEP 508 specifications.
168168

169-
Because the use of setuptools and wheel are so expansive in the
169+
Because the use of setuptools is so expansive in the
170170
community at the moment, build tools are expected to use the example
171171
configuration file above as their default semantics when a
172172
``pyproject.toml`` file is not present.

peps/pep-0679.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Status: Draft
77
Type: Standards Track
88
Created: 07-Jan-2022
99
Python-Version: 3.15
10-
Post-History: `10-Jan-2022 <https://discuss.python.org/t/pep-679-allow-parentheses-in-assert-statements/13003>`__
10+
Post-History: `08-Sep-2025 <https://discuss.python.org/t/pep-679-new-assert-statement-syntax-with-parentheses/103634>`__,
11+
`10-Jan-2022 <https://discuss.python.org/t/pep-679-allow-parentheses-in-assert-statements/13003>`__
1112

1213

1314
Abstract
@@ -132,10 +133,10 @@ specification.
132133
(Note that, without the warning specification the pure parser implementation is
133134
a small grammar change [#previmp]_).
134135
To raise the warning, the compiler must
135-
be aware of the new syntax, which means that a flag would be necessary as
136-
otherwise the information is lost during parsing.
137-
As such, the AST of an :keyword:`assert` would look like so,
138-
with a ``paren_syntax`` flag::
136+
be aware of the new syntax, this means that an optional flag would be necessary
137+
as otherwise the information is lost during parsing.
138+
As such, the AST of an :keyword:`assert` with parentheses would look like so,
139+
with a ``paren_syntax=1`` flag::
139140

140141
>>> print(ast.dump(ast.parse('assert(True, "Error message")'), indent=4))
141142
Module(
@@ -145,8 +146,6 @@ with a ``paren_syntax`` flag::
145146
msg=Constant(value='Error message'),
146147
paren_syntax=1)])
147148

148-
The flag would be removed in 3.18 along with the :exc:`SyntaxWarning`.
149-
150149

151150
Implementing in the compiler
152151
----------------------------

0 commit comments

Comments
 (0)