From f6407d79049b53df222c832c84a7fad5d328b448 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Mon, 13 Feb 2023 08:11:18 -0500 Subject: [PATCH 1/3] Remove the explicit `random` parameter from `setlist.shuffle` Instead, accept any arguments ``random.shuffle`` accepts. Prior to Python 3.11 this was `random` but Python 3.9 deprecated this feature and Python 3.11 removed it. https://github.com/python/cpython/issues/84645 Accepting `*args, **kwargs` makes the signature compatible with whatever Python runtime happens to be in use. --- collections_extended/setlists.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/collections_extended/setlists.py +++ b/collections_extended/setlists.py @@ -564,14 +564,13 @@ return self # New methods - def shuffle(self, random=None): + def shuffle(self, *args, **kwargs): """Shuffle all of the elements in self in place. Args: - random: A function returning a random float in [0.0, 1.0). If none - is passed, the default from `random.shuffle` will be used. + An arguments accepted by ``random.shuffle`` """ - random_.shuffle(self._list, random=random) + random_.shuffle(self._list, *args, **kwargs) for i, elem in enumerate(self._list): self._dict[elem] = i --- a/collections_extended/indexed_dict.py +++ b/collections_extended/indexed_dict.py @@ -136,8 +136,8 @@ else: raise key2, value2 = self._list.pop(index) - assert key is key2 - assert value is value2 + assert key == key2, f"{key!r} != {key2!r}" + assert value is value2, f"{value} is not {value2}" return index, value --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development", "Topic :: Software Development :: Libraries",