Skip to content

Commit 1fbf444

Browse files
committed
Merge remote-tracking branch 'origin/development' into development
# Conflicts: # poetry.lock
2 parents 7ed2c31 + 801e34b commit 1fbf444

7 files changed

Lines changed: 43 additions & 9 deletions

File tree

.github/workflows/tests.yml

Lines changed: 0 additions & 1 deletion
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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
2.10rc1
2-
=======
1+
2.10
2+
====
33

44
Changes
55
-------
66

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+
710
- Simplify the internals of the Resource metaclass to make it easier to understand
811
and maintain. Greater sharing of code between Resource and AnnotatedResource
912

@@ -19,6 +22,12 @@ Changes
1922
resource.
2023

2124

25+
Bugfix
26+
------
27+
28+
- ResourceOptions.abstract flag was not being set for abstract AnnotatedResrouces.
29+
30+
2231
2.9
2332
===
2433

pyproject.toml

Lines changed: 1 addition & 1 deletion
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.10"
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def __new__(
8686
new_meta = _new_meta_instance(
8787
meta_options_type, attrs.pop("Meta", None), new_class
8888
)
89+
new_meta.abstract = abstract
8990

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

src/odin/codecs/json_codec.py

Lines changed: 1 addition & 5 deletions
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

Lines changed: 15 additions & 0 deletions
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

Lines changed: 14 additions & 0 deletions
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)