Skip to content

Commit 22b24c2

Browse files
authored
Tin/import cattrs (#203)
* Import cattrs first pass * More import cattrs * Update test_preconf * Update docs * Remove prints * Fix check-wheel-contents
1 parent a0e56f4 commit 22b24c2

33 files changed

+139
-29
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ jobs:
6363
- name: "List result"
6464
run: "ls -l dist"
6565
- name: "Check wheel contents"
66-
run: "check-wheel-contents dist/*.whl"
66+
run: "check-wheel-contents --toplevel cattr,cattrs dist/*.whl"
6767
- name: "Check long_description"
6868
run: "python -m twine check dist/*"

HISTORY.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ History
33
=======
44
1.10.0 (UNRELEASED)
55
-------------------
6-
* Add PEP 563 (string annotations) for dataclasses.
6+
* Add PEP 563 (string annotations) support for dataclasses.
77
(`#195 <https://github.com/python-attrs/cattrs/issues/195>`_)
88
* Fix handling of dictionaries with string Enum keys for bson, orjson, and tomlkit.
99
* Rename the ``cattr.gen.make_dict_unstructure_fn.omit_if_default`` parameter to ``_cattrs_omit_if_default``, for consistency. The ``omit_if_default`` parameters to ``GenConverter`` and ``override`` are unchanged.
10+
* Following the changes in ``attrs`` 21.3.0, add a ``cattrs`` package mirroring the existing ``cattr`` package. Both package names may be used as desired, and the ``cattr`` package isn't going away.
1011

1112
1.9.0 (2021-12-06)
1213
------------------

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ repository = "https://github.com/python-attrs/cattrs"
1717
documentation = "https://cattrs.readthedocs.io/en/latest/"
1818
keywords = ["attrs", "serialization", "dataclasses"]
1919
packages = [
20-
{ include = "cattr", from = "src" }
20+
{ include = "cattr", from = "src" },
21+
{ include = "cattrs", from = "src" },
2122
]
2223
readme = "README.rst"
2324

File renamed without changes.

src/cattr/converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def _unstructure_union(self, obj):
360360
def _structure_error(self, _, cl):
361361
"""At the bottom of the condition stack, we explode if we can't handle it."""
362362
msg = (
363-
"Unsupported type: {0}. Register a structure hook for "
363+
"Unsupported type: {0!r}. Register a structure hook for "
364364
"it.".format(cl)
365365
)
366366
raise StructureHandlerNotFoundError(msg, type_=cl)

src/cattr/gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
is_bare,
2626
is_generic,
2727
)
28-
from .generics import deep_copy_with
28+
from ._generics import deep_copy_with
2929

3030
if TYPE_CHECKING: # pragma: no cover
3131
from cattr.converters import Converter

src/cattrs/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from cattr import (
2+
Converter,
3+
GenConverter,
4+
UnstructureStrategy,
5+
converters,
6+
disambiguators,
7+
dispatch,
8+
errors,
9+
gen,
10+
global_converter,
11+
override,
12+
preconf,
13+
register_structure_hook,
14+
register_structure_hook_func,
15+
register_unstructure_hook,
16+
register_unstructure_hook_func,
17+
structure,
18+
structure_attrs_fromdict,
19+
structure_attrs_fromtuple,
20+
unstructure,
21+
)
22+
23+
__all__ = (
24+
"Converter",
25+
"converters",
26+
"disambiguators",
27+
"dispatch",
28+
"errors",
29+
"gen",
30+
"GenConverter",
31+
"global_converter",
32+
"override",
33+
"preconf",
34+
"register_structure_hook_func",
35+
"register_structure_hook",
36+
"register_unstructure_hook_func",
37+
"register_unstructure_hook",
38+
"structure_attrs_fromdict",
39+
"structure_attrs_fromtuple",
40+
"structure",
41+
"unstructure",
42+
"UnstructureStrategy",
43+
)

src/cattrs/converters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from cattr.converters import Converter, GenConverter, UnstructureStrategy
2+
3+
__all__ = ["Converter", "GenConverter", "UnstructureStrategy"]

src/cattrs/disambiguators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from cattr.disambiguators import create_uniq_field_dis_func
2+
3+
__all__ = ["create_uniq_field_dis_func"]

src/cattrs/dispatch.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from cattr.dispatch import FunctionDispatch, MultiStrategyDispatch
2+
3+
__all__ = ["FunctionDispatch", "MultiStrategyDispatch"]

0 commit comments

Comments
 (0)