Skip to content

Commit 07a7bee

Browse files
committed
Merge branch 'release/3.5.1'
2 parents 5ed3147 + 544d13e commit 07a7bee

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

python_utils/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
)
88
__url__: str = 'https://github.com/WoLpH/python-utils'
99
# Omit type info due to automatic versioning script
10-
__version__ = '3.5.0'
10+
__version__ = '3.5.1'

python_utils/containers.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
DT = types.Dict[KT, VT]
1515
KT_cast = types.Optional[types.Callable[[Any], KT]]
1616
VT_cast = types.Optional[types.Callable[[Any], VT]]
17+
HT = types.TypeVar('HT', bound=types.Hashable)
1718

1819
# Using types.Union instead of | since Python 3.7 doesn't fully support it
1920
DictUpdateArgs = types.Union[
@@ -173,7 +174,7 @@ def values(self) -> Generator[VT, None, None]: # type: ignore
173174
yield self._value_cast(value)
174175

175176

176-
class UniqueList(types.List[VT]):
177+
class UniqueList(types.List[HT]):
177178
'''
178179
A list that only allows unique values. Duplicate values are ignored by
179180
default, but can be configured to raise an exception instead.
@@ -207,11 +208,11 @@ class UniqueList(types.List[VT]):
207208
ValueError: Duplicate value: 4
208209
'''
209210

210-
_set: set[VT]
211+
_set: set[HT]
211212

212213
def __init__(
213214
self,
214-
*args: VT,
215+
*args: HT,
215216
on_duplicate: types.Literal['raise', 'ignore'] = 'ignore',
216217
):
217218
self.on_duplicate = on_duplicate
@@ -220,7 +221,7 @@ def __init__(
220221
for arg in args:
221222
self.append(arg)
222223

223-
def insert(self, index: types.SupportsIndex, value: VT) -> None:
224+
def insert(self, index: types.SupportsIndex, value: HT) -> None:
224225
if value in self._set:
225226
if self.on_duplicate == 'raise':
226227
raise ValueError('Duplicate value: %s' % value)
@@ -230,7 +231,7 @@ def insert(self, index: types.SupportsIndex, value: VT) -> None:
230231
self._set.add(value)
231232
super().insert(index, value)
232233

233-
def append(self, value: VT) -> None:
234+
def append(self, value: HT) -> None:
234235
if value in self._set:
235236
if self.on_duplicate == 'raise':
236237
raise ValueError('Duplicate value: %s' % value)
@@ -244,11 +245,11 @@ def __contains__(self, item):
244245
return item in self._set
245246

246247
@types.overload
247-
def __setitem__(self, indices: types.SupportsIndex, values: VT) -> None:
248+
def __setitem__(self, indices: types.SupportsIndex, values: HT) -> None:
248249
...
249250

250251
@types.overload
251-
def __setitem__(self, indices: slice, values: types.Iterable[VT]) -> None:
252+
def __setitem__(self, indices: slice, values: types.Iterable[HT]) -> None:
252253
...
253254

254255
def __setitem__(self, indices, values) -> None:

tox.ini

+5-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ deps = -r{toxinidir}/_python_utils_tests/requirements.txt
4444
commands = mypy {posargs}
4545

4646
[testenv:docs]
47+
changedir =
4748
basepython = python3
49+
deps = -r{toxinidir}/docs/requirements.txt
50+
allowlist_externals =
51+
rm
52+
mkdir
4853
whitelist_externals =
4954
rm
5055
cd
@@ -56,5 +61,4 @@ commands =
5661
sphinx-apidoc -o docs/ python_utils
5762
rm -f docs/modules.rst
5863
sphinx-build -n -W -b html -d docs/_build/doctrees docs docs/_build/html {posargs}
59-
deps = -r{toxinidir}/docs/requirements.txt
6064

0 commit comments

Comments
 (0)