| 1 |
From f6407d79049b53df222c832c84a7fad5d328b448 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Jean-Paul Calderone <[email protected]> |
| 3 |
Date: Mon, 13 Feb 2023 08:11:18 -0500 |
| 4 |
Subject: [PATCH 1/3] Remove the explicit `random` parameter from |
| 5 |
`setlist.shuffle` |
| 6 |
|
| 7 |
Instead, accept any arguments ``random.shuffle`` accepts. Prior to Python |
| 8 |
3.11 this was `random` but Python 3.9 deprecated this feature and Python 3.11 |
| 9 |
removed it. |
| 10 |
|
| 11 |
https://github.com/python/cpython/issues/84645 |
| 12 |
|
| 13 |
Accepting `*args, **kwargs` makes the signature compatible with whatever |
| 14 |
Python runtime happens to be in use. |
| 15 |
--- |
| 16 |
collections_extended/setlists.py | 7 +++---- |
| 17 |
1 file changed, 3 insertions(+), 4 deletions(-) |
| 18 |
|
| 19 |
--- a/collections_extended/setlists.py |
| 20 |
+++ b/collections_extended/setlists.py |
| 21 |
@@ -564,14 +564,13 @@ |
| 22 |
return self |
| 23 |
|
| 24 |
# New methods |
| 25 |
- def shuffle(self, random=None): |
| 26 |
+ def shuffle(self, *args, **kwargs): |
| 27 |
"""Shuffle all of the elements in self in place. |
| 28 |
|
| 29 |
Args: |
| 30 |
- random: A function returning a random float in [0.0, 1.0). If none |
| 31 |
- is passed, the default from `random.shuffle` will be used. |
| 32 |
+ An arguments accepted by ``random.shuffle`` |
| 33 |
""" |
| 34 |
- random_.shuffle(self._list, random=random) |
| 35 |
+ random_.shuffle(self._list, *args, **kwargs) |
| 36 |
for i, elem in enumerate(self._list): |
| 37 |
self._dict[elem] = i |
| 38 |
|
| 39 |
--- a/collections_extended/indexed_dict.py |
| 40 |
+++ b/collections_extended/indexed_dict.py |
| 41 |
@@ -136,8 +136,8 @@ |
| 42 |
else: |
| 43 |
raise |
| 44 |
key2, value2 = self._list.pop(index) |
| 45 |
- assert key is key2 |
| 46 |
- assert value is value2 |
| 47 |
+ assert key == key2, f"{key!r} != {key2!r}" |
| 48 |
+ assert value is value2, f"{value} is not {value2}" |
| 49 |
|
| 50 |
return index, value |
| 51 |
|
| 52 |
--- a/pyproject.toml |
| 53 |
+++ b/pyproject.toml |
| 54 |
@@ -26,6 +26,7 @@ |
| 55 |
"Programming Language :: Python :: 3.8", |
| 56 |
"Programming Language :: Python :: 3.9", |
| 57 |
"Programming Language :: Python :: 3.10", |
| 58 |
+ "Programming Language :: Python :: 3.11", |
| 59 |
"Programming Language :: Python :: Implementation :: PyPy", |
| 60 |
"Topic :: Software Development", |
| 61 |
"Topic :: Software Development :: Libraries", |