Skip to content

Commit 524ced0

Browse files
authored
Merge pull request #217 from python-desert/2022-09-22
2 parents 0464892 + 92de73e commit 524ced0

File tree

5 files changed

+54
-34
lines changed

5 files changed

+54
-34
lines changed

CHANGELOG.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
1+
2022.09.22 (2022-09-22)
2+
-----------------------
3+
4+
5+
Backward-incompatible Changes
6+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7+
8+
- Update all project dependencies and fix all deprecated warnings. Python 3.6
9+
support was dropped to allow updating deprecated dependencies.
10+
`#161 <https://github.com/python-desert/desert/issues/161>`_
11+
12+
13+
Changes
14+
^^^^^^^
15+
16+
- It is now possible to use `type-variant generics`_ in your dataclasses, such as ``Sequence``
17+
or ``MutableSequence`` instead of ``List``, ``Mapping`` instead of ``Dict``, etc.
18+
19+
This allows you to hide implementation details from users of your dataclasses. If a field
20+
in your dataclass works just as fine with a tuple as a list, you no longer need to force
21+
your users to pass in a ``list`` just to satisfy type checkers.
22+
23+
For example, by using ``Mapping`` or ``MutableMapping``, users can pass ``OrderedDict`` to
24+
a ``Dict`` attribute without MyPy complaining.
25+
26+
.. code-block:: python
27+
28+
@dataclass
29+
class OldWay:
30+
str_list: List[str]
31+
num_map: Dict[str, float]
32+
33+
34+
# MyPy will reject this even though Marshmallow works just fine. If you use
35+
# type-variant generics, MyPy will accept this code.
36+
instance = OldClass([], collections.ChainMap(MY_DEFAULTS))
37+
38+
39+
@dataclass
40+
class NewWay:
41+
str_list: List[str] # Type-invariants still work
42+
num_map: MutableMapping[str, float] # Now generics do too
43+
44+
45+
.. _type-variant generics: https://mypy.readthedocs.io/en/stable/generics.html
46+
47+
`#140 <https://github.com/python-desert/desert/issues/140>`_
48+
49+
50+
----
51+
52+
153
2020.11.18 (2020-11-18)
254
-----------------------
355

changelog.d/140.change.rst

Lines changed: 0 additions & 30 deletions
This file was deleted.

changelog.d/161.breaking.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ known_first_party = desert
2929
default_section = THIRDPARTY
3030
forced_separate = test_desert
3131
skip = migrations
32-
known_third_party=attr,marshmallow,pytest,setuptools,typing_inspect
32+
known_third_party=_pytest,attr,marshmallow,pytest,setuptools,typing_extensions,typing_inspect
3333
extend_skip =
3434
.flake8
3535
dev-requirements.in

src/desert/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2020.11.18"
1+
__version__ = "2022.09.22"

0 commit comments

Comments
 (0)