Skip to content

Commit

Permalink
Merge pull request #163 from python-odin/development
Browse files Browse the repository at this point in the history
Release 2.10rc2
  • Loading branch information
timsavage committed Mar 27, 2024
2 parents 9a29fdd + bbe5c30 commit 2166763
Show file tree
Hide file tree
Showing 8 changed files with 502 additions and 378 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip poetry
python -m pip wheel --use-pep517 "pyyaml (==6.0)"
poetry install --all-extras --no-root
- name: Test with pytest
Expand Down
15 changes: 15 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2.10rc2
=======

Changes
-------

- Remove simplejson as a fallback. Is no longer required with Python 3.8 plus and
has worse performance that the builtin json module.

Bugfix
------

- ResourceOptions.abstract flag was not being set for abstract AnnotatedResrouces.


2.10rc1
=======

Expand Down
826 changes: 455 additions & 371 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "odin"
version = "2.10rc1"
version = "2.10rc2"
description = "Data-structure definition/validation/traversal, mapping and serialisation toolkit for Python"
authors = ["Tim Savage <tim@savage.company>"]
license = "BSD-3-Clause"
Expand Down
1 change: 1 addition & 0 deletions src/odin/annotated_resource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __new__(
new_meta = _new_meta_instance(
meta_options_type, attrs.pop("Meta", None), new_class
)
new_meta.abstract = abstract

# Bail out early if we have already created this class.
r = registration.get_resource(new_meta.resource_name)
Expand Down
6 changes: 1 addition & 5 deletions src/odin/codecs/json_codec.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import datetime
import json
import typing
import uuid

from odin import ResourceAdapter, bases, resources, serializers
from odin.exceptions import CodecDecodeError, CodecEncodeError
from odin.utils import getmeta

try:
import simplejson as json
except ImportError:
import json

LIST_TYPES = (bases.ResourceIterable, typing.ValuesView, typing.KeysView)
JSON_TYPES = {
datetime.date: serializers.date_iso_format,
Expand Down
15 changes: 15 additions & 0 deletions tests/test_annotated_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Library,
Publisher,
AltBook,
LibraryBook
)


Expand Down Expand Up @@ -51,6 +52,20 @@ def test_fields_are_inherited_from_parent_resources(self):
"publisher",
]

def test_abstract_option_is_set_for_abstract_resources(self):
target = getmeta(LibraryBook)

actual = target.abstract

assert actual is True

def test_abstract_option_is_clear_for_non_abstract_resources(self):
target = getmeta(Book)

actual = target.abstract

assert actual is False

def test_cached_properties_work_as_expected(self):
target = Publisher(name="Super Pub")

Expand Down
14 changes: 14 additions & 0 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Library,
Subscriber,
AltBook,
LibraryBook
)


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

def test_abstract_option_is_set_for_abstract_resources(self):
target = getmeta(LibraryBook)

actual = target.abstract

assert actual is True

def test_abstract_option_is_clear_for_non_abstract_resources(self):
target = getmeta(Book)

actual = target.abstract

assert actual is False

class TestConstructionMethods:
def test_build_object_graph_empty_dict_no_clean(self):
Expand Down

0 comments on commit 2166763

Please sign in to comment.