Skip to content

Commit 2166763

Browse files
authored
Merge pull request #163 from python-odin/development
Release 2.10rc2
2 parents 9a29fdd + bbe5c30 commit 2166763

File tree

8 files changed

+502
-378
lines changed

8 files changed

+502
-378
lines changed

.github/workflows/tests.yml

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
- name: Install dependencies
3131
run: |
3232
python -m pip install --upgrade pip poetry
33-
python -m pip wheel --use-pep517 "pyyaml (==6.0)"
3433
poetry install --all-extras --no-root
3534
3635
- name: Test with pytest

HISTORY

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2.10rc2
2+
=======
3+
4+
Changes
5+
-------
6+
7+
- Remove simplejson as a fallback. Is no longer required with Python 3.8 plus and
8+
has worse performance that the builtin json module.
9+
10+
Bugfix
11+
------
12+
13+
- ResourceOptions.abstract flag was not being set for abstract AnnotatedResrouces.
14+
15+
116
2.10rc1
217
=======
318

poetry.lock

+455-371
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "odin"
7-
version = "2.10rc1"
7+
version = "2.10rc2"
88
description = "Data-structure definition/validation/traversal, mapping and serialisation toolkit for Python"
99
authors = ["Tim Savage <tim@savage.company>"]
1010
license = "BSD-3-Clause"

src/odin/annotated_resource/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def __new__(
8585
new_meta = _new_meta_instance(
8686
meta_options_type, attrs.pop("Meta", None), new_class
8787
)
88+
new_meta.abstract = abstract
8889

8990
# Bail out early if we have already created this class.
9091
r = registration.get_resource(new_meta.resource_name)

src/odin/codecs/json_codec.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import datetime
2+
import json
23
import typing
34
import uuid
45

56
from odin import ResourceAdapter, bases, resources, serializers
67
from odin.exceptions import CodecDecodeError, CodecEncodeError
78
from odin.utils import getmeta
89

9-
try:
10-
import simplejson as json
11-
except ImportError:
12-
import json
13-
1410
LIST_TYPES = (bases.ResourceIterable, typing.ValuesView, typing.KeysView)
1511
JSON_TYPES = {
1612
datetime.date: serializers.date_iso_format,

tests/test_annotated_resources.py

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Library,
1212
Publisher,
1313
AltBook,
14+
LibraryBook
1415
)
1516

1617

@@ -51,6 +52,20 @@ def test_fields_are_inherited_from_parent_resources(self):
5152
"publisher",
5253
]
5354

55+
def test_abstract_option_is_set_for_abstract_resources(self):
56+
target = getmeta(LibraryBook)
57+
58+
actual = target.abstract
59+
60+
assert actual is True
61+
62+
def test_abstract_option_is_clear_for_non_abstract_resources(self):
63+
target = getmeta(Book)
64+
65+
actual = target.abstract
66+
67+
assert actual is False
68+
5469
def test_cached_properties_work_as_expected(self):
5570
target = Publisher(name="Super Pub")
5671

tests/test_resources.py

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Library,
1919
Subscriber,
2020
AltBook,
21+
LibraryBook
2122
)
2223

2324

@@ -241,6 +242,19 @@ def test_shadow_fields_are_identified(self):
241242
assert isinstance(actual, tuple)
242243
assert [f.name for f in actual] == ["title"]
243244

245+
def test_abstract_option_is_set_for_abstract_resources(self):
246+
target = getmeta(LibraryBook)
247+
248+
actual = target.abstract
249+
250+
assert actual is True
251+
252+
def test_abstract_option_is_clear_for_non_abstract_resources(self):
253+
target = getmeta(Book)
254+
255+
actual = target.abstract
256+
257+
assert actual is False
244258

245259
class TestConstructionMethods:
246260
def test_build_object_graph_empty_dict_no_clean(self):

0 commit comments

Comments
 (0)