Skip to content

Commit bfe4693

Browse files
committed
Merge branch 'release/3.5.2'
2 parents 07a7bee + e204544 commit bfe4693

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
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.1'
10+
__version__ = '3.5.2'

python_utils/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
types,
1313
)
1414
from .aio import acount
15+
from .containers import CastedDict, LazyCastedDict, UniqueList
1516
from .converters import remap, scale_1024, to_float, to_int, to_str, to_unicode
1617
from .decorators import listify, set_attributes
1718
from .exceptions import raise_exception, reraise
@@ -70,4 +71,7 @@
7071
'raise_exception',
7172
'Logged',
7273
'LoggerBase',
74+
'CastedDict',
75+
'LazyCastedDict',
76+
'UniqueList',
7377
]

python_utils/containers.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import abc
42
import typing
53
from typing import Any, Generator
@@ -9,11 +7,17 @@
97
if typing.TYPE_CHECKING:
108
import _typeshed # noqa: F401
119

10+
#: A type alias for a type that can be used as a key in a dictionary.
1211
KT = types.TypeVar('KT')
12+
#: A type alias for a type that can be used as a value in a dictionary.
1313
VT = types.TypeVar('VT')
14+
#: A type alias for a dictionary with keys of type KT and values of type VT.
1415
DT = types.Dict[KT, VT]
16+
#: A type alias for the casted type of a dictionary key.
1517
KT_cast = types.Optional[types.Callable[[Any], KT]]
18+
#: A type alias for the casted type of a dictionary value.
1619
VT_cast = types.Optional[types.Callable[[Any], VT]]
20+
#: A type alias for the hashable values of the `UniqueList`
1721
HT = types.TypeVar('HT', bound=types.Hashable)
1822

1923
# Using types.Union instead of | since Python 3.7 doesn't fully support it
@@ -61,7 +65,7 @@ class CastedDict(CastedDictBase[KT, VT]):
6165
Note that you can specify the types for mypy and type hinting with:
6266
CastedDict[int, int](int, int)
6367
64-
>>> d = CastedDict(int, int)
68+
>>> d: CastedDict[int, int] = CastedDict(int, int)
6569
>>> d[1] = 2
6670
>>> d['3'] = '4'
6771
>>> d.update({'5': '6'})
@@ -105,7 +109,7 @@ class LazyCastedDict(CastedDictBase[KT, VT]):
105109
Note that you can specify the types for mypy and type hinting with:
106110
LazyCastedDict[int, int](int, int)
107111
108-
>>> d = LazyCastedDict(int, int)
112+
>>> d: LazyCastedDict[int, int] = LazyCastedDict(int, int)
109113
>>> d[1] = 2
110114
>>> d['3'] = '4'
111115
>>> d.update({'5': '6'})
@@ -159,7 +163,9 @@ def __getitem__(self, key: Any) -> VT:
159163

160164
return value
161165

162-
def items(self) -> Generator[tuple[KT, VT], None, None]: # type: ignore
166+
def items( # type: ignore
167+
self,
168+
) -> Generator[types.Tuple[KT, VT], None, None]:
163169
if self._value_cast is None:
164170
yield from super().items()
165171
else:
@@ -208,7 +214,7 @@ class UniqueList(types.List[HT]):
208214
ValueError: Duplicate value: 4
209215
'''
210216

211-
_set: set[HT]
217+
_set: types.Set[HT]
212218

213219
def __init__(
214220
self,

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ commands =
6060
mkdir -p docs/_static
6161
sphinx-apidoc -o docs/ python_utils
6262
rm -f docs/modules.rst
63-
sphinx-build -n -W -b html -d docs/_build/doctrees docs docs/_build/html {posargs}
63+
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html {posargs}
6464

0 commit comments

Comments
 (0)