py-serializable Documentation

This Pythonic-library can be used to magically handle serialization of your Python Objects to JSON or XML and de-serialization from JSON or XML back to Pythonic Object instances.

This library relies upon your Python Classes utilising the @property decorator and can optionally take additional configuration which allows you to control how a class is (de-)serialized.

See also:

Getting Started

Let’s work a simple example together.

I have a two Python classes that together I use to model Books. They are Book and Chapter, and they are defined as follows:

class Chapter:

    def __init__(self, *, number: int, title: str) -> None:
        self._number = number
        self._title = title

    @property
    def number(self) -> int:
        return self._number

    @property
    def title(self) -> str:
        return self._title

class Book:

    def __init__(self, *, title: str, isbn: str, edition: int, publish_date: date, authors: Iterable[str],
                 chapters: Optional[Iterable[Chapter]] = None) -> None:
        self._title = title
        self._isbn = isbn
        self._edition = edition
        self._publish_date = publish_date
        self._authors = set(authors)
        self.chapters = chapters or []

    @property
    def title(self) -> str:
        return self._title

    @property
    def isbn(self) -> str:
        return self._isbn

    @property
    def edition(self) -> int:
        return self._edition

    @property
    def publish_date(self) -> date:
        return self._publish_date

    @property
    def authors(self) -> Set[str]:
        return self._authors

    @property
    def chapters(self) -> List[Chapter]:
        return self._chapters

    @chapters.setter
    def chapters(self, chapters: Iterable[Chapter]) -> None:
        self._chapters = list(chapters)

To make a class serializable to/from JSON or XML, the class must be annotated with the decorator serializable.serializable_class.

By simply modifying the classes above, we make them (de-)serializable with this library (albeit with some default behaviour implied!).

This makes our classes:

import serializable

@serializable.serializable_class
class Chapter:

    def __init__(self, *, number: int, title: str) -> None:
        self._number = number
        self._title = title

    @property
    def number(self) -> int:
        return self._number

    @property
    def title(self) -> str:
        return self._title

@serializable.serializable_class
class Book:

    def __init__(self, *, title: str, isbn: str, edition: int, publish_date: date, authors: Iterable[str],
                 chapters: Optional[Iterable[Chapter]] = None) -> None:
        self._title = title
        self._isbn = isbn
        self._edition = edition
        self._publish_date = publish_date
        self._authors = set(authors)
        self.chapters = chapters or []

    @property
    def title(self) -> str:
        return self._title

    @property
    def isbn(self) -> str:
        return self._isbn

    @property
    def edition(self) -> int:
        return self._edition

    @property
    def publish_date(self) -> date:
        return self._publish_date

    @property
    def authors(self) -> Set[str]:
        return self._authors

    @property
    def chapters(self) -> List[Chapter]:
        return self._chapters

    @chapters.setter
    def chapters(self, chapters: Iterable[Chapter]) -> None:
        self._chapters = list(chapters)

At this point, we can serialize an instance of Book to JSON as follows:

book = Book(title="My Book", isbn="999-888777666555", edition=1, publish_date=datetime.utcnow(), authors=['me'])
print(book.as_json())

which outputs:

{
    "title": "My Book",
    "isbn": "999-888777666555",
    "edition": 1,
    "publishDate": "2022-08-10",
    "authors": [
        "me"
    ]
}

We could also serialized to XML as follows:

print(book.as_xml())

which outputs:

<?xml version="1.0" encoding="UTF-8"?>
<book>
    <title>My Book</title>
    <isbn>999-888777666555</isbn>
    <edition>1</edition>
    <publishDate>2022-08-10</publishDate>
    <author>me</author>
</book>

Customising Serialization

There are various scenarios whereby you may want to have more control over the structure (particularly in XML) that is generated when serializing an object, and thus understanding how to deserialize JSON or XML back to an object.

This library provides a number of meta methods that you can override in your Python classes to achieve this.

Property Name Mappings

You can directly control mapping of property names for properties in a Class by adding the decorators serializable.json_name() or serializable.xml_name().

For example, you might have a property called isbn in your class, but when serialized to JSON it should be called isbn_number.

To implement this mapping, you would alter your class as follows adding the serializable.json_name() decorator to the isbn property:

@serializable.serializable_class
class Book:

    def __init__(self, title: str, isbn: str, publish_date: date, authors: Iterable[str],
        ...

    @property
    @serializable.json_name('isbn_number')
    def isbn(self) -> str:
        return self._isbn

Excluding Property from Serialization

Properties can be ignored during deserialization by including them in the serializable.serializable_class() annotation as per the following example.

A typical use case for this might be where a JSON schema is referenced, but this is not part of the constructor for the class you are deserializing to.

@serializable.serializable_class(ignore_during_deserialization=['$schema'])
class Book:
  ...

Handling None Values

By default, None values will lead to a Property being excluded from the serialization process to keep the output as concise as possible. There are many cases (and schemas) where this is however not the required behaviour.

You can force a Property to be serialized even when the value is None by annotating as follows:

@serializable.include_none
def email(self) -> Optional[str]:
    return self._email

Customised Property Serialization

This feature allows you to handle, for example, serialization of datetime.date Python objects to and from strings.

Depending on your use case, the string format could vary, and thus this library makes no assumptions. We have provided an some example helpers for (de-)serializing dates and datetimes.

To define a custom serializer for a property, add the serializable.type_mapping() decorator to the property. For example, to have a property named created be use the serializable.helpers.Iso8601Date helper you would add the following method to your class:

@serializable.serializable_class
class Book:

    def __init__(self, title: str, isbn: str, publish_date: date, authors: Iterable[str],
        ...

    @property
    @serializable.type_mapping(Iso8601Date)
    def publish_date(self) -> date:
        return self._publish_date

Writing Custom Property Serializers

You can write your own custom property serializer. The only requirements are that it must extend serializable.helpers.BaseHelper and therefore implement the serialize() and deserialize() class methods.

For examples, see serializable.helpers.

Serializing Lists & Sets

Particularly in XML, there are many ways that properties which return Lists or Sets could be represented. We can handle this by adding the decorator serializable.xml_array() to the appropriate property in your class.

For example, given a Property that returns Set[Chapter], this could be serialized in one of a number of ways:

Example 1: Nested list under a property name in JSON
 {
     "chapters": [
         { /* chapter 1 here... */ },
         { /* chapter 2 here... */ },
         // etc...
     ]
 }
Example 2: Nested list under a property name in XML
 <chapters>
     <chapter><!-- chapter 1 here... --></chapter>
     <chapter><!-- chapter 2 here... --></chapter>
     <!-- etc... -->
 </chapters>
Example 3: Collapsed list under a (potentially singular of the) property name in XML
 <chapter><!-- chapter 1 here... --></chapter>
 <chapter><!-- chapter 2 here... --></chapter>

As we have only identified one possible structure for JSON at this time, the implementation of only affects XML (de-)serialization at this time.

For Example 2, you would add the following to your class:

@property
@serializable.xml_array(XmlArraySerializationType.NESTED, 'chapter')
def chapters(self) -> List[Chapter]:
    return self._chapters

For Example 3, you would add the following to your class:

@property
@serializable.xml_array(XmlArraySerializationType.FLAT, 'chapter')
def chapters(self) -> List[Chapter]:
    return self._chapters

Further examples are available in our unit tests.

Serialization Views

Many object models can be serialized to and from multiple versions of a schema or different schemas. In py-serialization we refer to these as Views.

By default all Properties will be included in the serialization process, but this can be customised based on the View.

Defining Views

A View is a class that extends serializable.ViewType and you should create classes as required in your implementation.

For example:

from serializable import ViewType

class SchemaVersion1(ViewType):
   pass

Property Inclusion

Properties can be annotated with the Views for which they should be included.

For example:

@property
@serializable.view(SchemaVersion1)
def address(self) -> Optional[str]:
    return self._address

Handling None Values

Further to the above, you can vary the None value per View as follows:

@property
@serializable.include_none(SchemaVersion2)
@serializable.include_none(SchemaVersion3, "RUBBISH")
def email(self) -> Optional[str]:
    return self._email

The above example will result in None when serializing with the View SchemaVersion2, but the value RUBBISH when serializing to the View SchemaVersion3 when email is not set.

Serializing For a View

To serialized for a specific View, include the View when you perform the serialisation.

JSON Example
 ThePhoenixProject.as_json(view_=SchemaVersion1)
XML Example
 ThePhoenixProject.as_xml(view_=SchemaVersion1)

XML Element Ordering

Some XML schemas utilise sequence which requires elements to be in a prescribed order.

You can control the order properties are serialized to elements in XML by utilising the serializable.xml_sequence() decorator. The default sort order applied to properties is 100 (where lower is earlier in the sequence).

In the example below, the isbn property will be output first.

@property
@serializable.xml_sequence(1)
def isbn(self) -> str:
    return self._isbn

Property Name Formatting

By default, py-serializable uses it’s serializable.formatters.CamelCasePropertyNameFormatter formatter for translating actual Python property names to element names in either JSON or XML.

py-serializable includes a number of name formatters out of the box, but you can also create your own if required.

Included Formatters

py-serializable includes three common formatters out of the box.

  1. Camel Case Formatter: serializable.formatters.CamelCasePropertyNameFormatter (the default)

  2. Kebab Case Formatter: serializable.formatters.KebabCasePropertyNameFormatter

  3. Snake Case Formatter: serializable.formatters.SnakeCasePropertyNameFormatter

A summary of how these differ is included in the below table.

Python Property Name

Camel Case

Kebab Case

Snake Case

books

books

books

books

big_book

bigBook

big-book

big_book

a_very_big_book

aVeryBigBook

a-very-big-book

a_very_big_book

Changing the Formatter

You can change the formatter being used by easily. The example below changes the formatter to be Snake Case.

from serializable.formatters import CurrentFormatter, SnakeCasePropertyNameFormatter

CurrentFormatter.formatter = SnakeCasePropertyNameFormatter

Custom Formatters

If none of the included formatters work for you, why not write your own?

The only requirement is that it extends serializable.formatters.BaseNameFormatter!

Examples

Models used in Unit Tests

  1# encoding: utf-8
  2
  3# This file is part of py-serializable
  4#
  5# Licensed under the Apache License, Version 2.0 (the "License");
  6# you may not use this file except in compliance with the License.
  7# You may obtain a copy of the License at
  8#
  9#     http://www.apache.org/licenses/LICENSE-2.0
 10#
 11# Unless required by applicable law or agreed to in writing, software
 12# distributed under the License is distributed on an "AS IS" BASIS,
 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14# See the License for the specific language governing permissions and
 15# limitations under the License.
 16#
 17# SPDX-License-Identifier: Apache-2.0
 18# Copyright (c) Paul Horton. All Rights Reserved.
 19
 20import re
 21from datetime import date
 22from decimal import Decimal
 23from enum import Enum, unique
 24from typing import Any, Dict, Iterable, List, Optional, Set, Type
 25from uuid import UUID, uuid4
 26
 27import serializable
 28from serializable import ViewType, XmlArraySerializationType
 29from serializable.helpers import BaseHelper, Iso8601Date
 30
 31"""
 32Model classes used in unit tests and examples.
 33"""
 34
 35
 36class SchemaVersion1(ViewType):
 37    pass
 38
 39
 40class SchemaVersion2(ViewType):
 41    pass
 42
 43
 44class SchemaVersion3(ViewType):
 45    pass
 46
 47
 48class SchemaVersion4(ViewType):
 49    pass
 50
 51
 52SCHEMAVERSION_MAP: Dict[int, Type[ViewType]] = {
 53    1: SchemaVersion1,
 54    2: SchemaVersion2,
 55    3: SchemaVersion3,
 56    4: SchemaVersion4,
 57}
 58
 59
 60class ReferenceReferences(BaseHelper):
 61
 62    @classmethod
 63    def serialize(cls, o: Any) -> Set[str]:
 64        if isinstance(o, set):
 65            return set(map(lambda i: str(i.ref), o))
 66
 67        raise ValueError(f'Attempt to serialize a non-set: {o.__class__}')
 68
 69    @classmethod
 70    def deserialize(cls, o: Any) -> Set['BookReference']:
 71        print(f'Deserializing {o} ({type(o)})')
 72        references: Set['BookReference'] = set()
 73        if isinstance(o, list):
 74            for v in o:
 75                references.add(BookReference(ref=v))
 76            return references
 77
 78        raise ValueError(f'Attempt to deserialize a non-set: {o.__class__}')
 79
 80
 81class TitleMapper(BaseHelper):
 82
 83    @classmethod
 84    def json_serialize(cls, o: str) -> str:
 85        return f'{{J}} {o}'
 86
 87    @classmethod
 88    def json_deserialize(cls, o: str) -> str:
 89        return re.sub(r'^\{J} ', '', o)
 90
 91    @classmethod
 92    def xml_serialize(cls, o: str) -> str:
 93        return f'{{X}} {o}'
 94
 95    @classmethod
 96    def xml_deserialize(cls, o: str) -> str:
 97        return re.sub(r'^\{X} ', '', o)
 98
 99
100@serializable.serializable_class
101class Chapter:
102
103    def __init__(self, *, number: int, title: str) -> None:
104        self._number = number
105        self._title = title
106
107    @property
108    def number(self) -> int:
109        return self._number
110
111    @property
112    def title(self) -> str:
113        return self._title
114
115    def __eq__(self, other: Any) -> bool:
116        if isinstance(other, Chapter):
117            return hash(other) == hash(self)
118        return False
119
120    def __hash__(self) -> int:
121        return hash((self.number, self.title))
122
123
124@serializable.serializable_class
125class Publisher:
126
127    def __init__(self, *, name: str, address: Optional[str] = None, email: Optional[str] = None) -> None:
128        self._name = name
129        self._address = address
130        self._email = email
131
132    @property
133    def name(self) -> str:
134        return self._name
135
136    @property
137    @serializable.view(SchemaVersion2)
138    @serializable.view(SchemaVersion4)
139    def address(self) -> Optional[str]:
140        return self._address
141
142    @property
143    @serializable.include_none(SchemaVersion2)
144    @serializable.include_none(SchemaVersion3, 'RUBBISH')
145    def email(self) -> Optional[str]:
146        return self._email
147
148    def __eq__(self, other: object) -> bool:
149        if isinstance(other, Publisher):
150            return hash(other) == hash(self)
151        return False
152
153    def __hash__(self) -> int:
154        return hash((self.name, self.address, self.email))
155
156
157@unique
158class BookType(Enum):
159    FICTION = 'fiction'
160    NON_FICTION = 'non-fiction'
161
162
163@serializable.serializable_class(name='edition')
164class BookEdition:
165
166    def __init__(self, *, number: int, name: str) -> None:
167        self._number = number
168        self._name = name
169
170    @property
171    @serializable.xml_attribute()
172    def number(self) -> int:
173        return self._number
174
175    @property
176    @serializable.xml_name('.')
177    def name(self) -> str:
178        return self._name
179
180    def __eq__(self, other: object) -> bool:
181        if isinstance(other, BookEdition):
182            return hash(other) == hash(self)
183        return False
184
185    def __hash__(self) -> int:
186        return hash((self.number, self.name))
187
188
189@serializable.serializable_class
190class BookReference:
191
192    def __init__(self, *, ref: str, references: Optional[Iterable['BookReference']] = None) -> None:
193        self.ref = ref
194        self.references = set(references or {})
195
196    @property
197    @serializable.json_name('reference')
198    @serializable.xml_attribute()
199    def ref(self) -> str:
200        return self._ref
201
202    @ref.setter
203    def ref(self, ref: str) -> None:
204        self._ref = ref
205
206    @property
207    @serializable.json_name('refersTo')
208    @serializable.type_mapping(ReferenceReferences)
209    @serializable.xml_array(serializable.XmlArraySerializationType.FLAT, 'reference')
210    def references(self) -> Set['BookReference']:
211        return self._references
212
213    @references.setter
214    def references(self, references: Iterable['BookReference']) -> None:
215        self._references = set(references)
216
217    def __eq__(self, other: object) -> bool:
218        if isinstance(other, BookReference):
219            return hash(other) == hash(self)
220        return False
221
222    def __hash__(self) -> int:
223        return hash((self.ref, tuple(self.references)))
224
225    def __repr__(self) -> str:
226        return f'<BookReference ref={self.ref}, targets={len(self.references)}>'
227
228
229@serializable.serializable_class
230class StockId(serializable.helpers.BaseHelper):
231
232    def __init__(self, id: str) -> None:
233        self._id = id
234
235    @property
236    @serializable.json_name('.')
237    @serializable.xml_name('.')
238    def id(self) -> str:
239        return self._id
240
241    @classmethod
242    def serialize(cls, o: Any) -> str:
243        if isinstance(o, StockId):
244            return str(o)
245        raise Exception(
246            f'Attempt to serialize a non-StockId: {o!r}')
247
248    @classmethod
249    def deserialize(cls, o: Any) -> 'StockId':
250        try:
251            return StockId(id=str(o))
252        except ValueError as err:
253            raise Exception(
254                f'StockId string supplied does not parse: {o!r}'
255            ) from err
256
257    def __eq__(self, other: Any) -> bool:
258        if isinstance(other, StockId):
259            return hash(other) == hash(self)
260        return False
261
262    def __lt__(self, other: Any) -> bool:
263        if isinstance(other, StockId):
264            return self._id < other._id
265        return NotImplemented
266
267    def __hash__(self) -> int:
268        return hash(self._id)
269
270    def __repr__(self) -> str:
271        return f'<StockId {self._id}>'
272
273    def __str__(self) -> str:
274        return self._id
275
276
277@serializable.serializable_class(name='bigbook',
278                                 ignore_during_deserialization=['something_to_be_ignored', 'ignore_me', 'ignored'])
279class Book:
280
281    def __init__(self, title: str, isbn: str, publish_date: date, authors: Iterable[str],
282                 publisher: Optional[Publisher] = None, chapters: Optional[Iterable[Chapter]] = None,
283                 edition: Optional[BookEdition] = None, type: BookType = BookType.FICTION,
284                 id: Optional[UUID] = None, references: Optional[Iterable[BookReference]] = None,
285                 rating: Optional[Decimal] = None, stock_ids: Optional[Iterable[StockId]] = None) -> None:
286        self._id = id or uuid4()
287        self._title = title
288        self._isbn = isbn
289        self._edition = edition
290        self._publish_date = publish_date
291        self._authors = set(authors)
292        self._publisher = publisher
293        self.chapters = list(chapters or [])
294        self._type = type
295        self.references = set(references or [])
296        self.rating = Decimal('NaN') if rating is None else rating
297        self._stock_ids = set(stock_ids or [])
298
299    @property
300    @serializable.xml_sequence(1)
301    def id(self) -> UUID:
302        return self._id
303
304    @property
305    @serializable.xml_sequence(2)
306    @serializable.type_mapping(TitleMapper)
307    def title(self) -> str:
308        return self._title
309
310    @property
311    @serializable.json_name('isbn_number')
312    @serializable.xml_attribute()
313    @serializable.xml_name('isbn_number')
314    def isbn(self) -> str:
315        return self._isbn
316
317    @property
318    @serializable.xml_sequence(3)
319    def edition(self) -> Optional[BookEdition]:
320        return self._edition
321
322    @property
323    @serializable.xml_sequence(4)
324    @serializable.type_mapping(Iso8601Date)
325    def publish_date(self) -> date:
326        return self._publish_date
327
328    @property
329    @serializable.xml_array(XmlArraySerializationType.FLAT, 'author')
330    @serializable.xml_sequence(5)
331    def authors(self) -> Set[str]:
332        return self._authors
333
334    @property
335    @serializable.xml_sequence(7)
336    def publisher(self) -> Optional[Publisher]:
337        return self._publisher
338
339    @property
340    @serializable.xml_array(XmlArraySerializationType.NESTED, 'chapter')
341    @serializable.xml_sequence(8)
342    def chapters(self) -> List[Chapter]:
343        return self._chapters
344
345    @chapters.setter
346    def chapters(self, chapters: Iterable[Chapter]) -> None:
347        self._chapters = list(chapters)
348
349    @property
350    @serializable.xml_sequence(6)
351    def type(self) -> BookType:
352        return self._type
353
354    @property
355    @serializable.view(SchemaVersion4)
356    @serializable.xml_array(serializable.XmlArraySerializationType.NESTED, 'reference')
357    @serializable.xml_sequence(7)
358    def references(self) -> Set[BookReference]:
359        return self._references
360
361    @references.setter
362    def references(self, references: Iterable[BookReference]) -> None:
363        self._references = set(references)
364
365    @property
366    @serializable.xml_sequence(20)
367    def rating(self) -> Decimal:
368        return self._rating
369
370    @rating.setter
371    def rating(self, rating: Decimal) -> None:
372        self._rating = rating
373
374    @property
375    @serializable.view(SchemaVersion4)
376    @serializable.xml_array(XmlArraySerializationType.FLAT, 'stockId')
377    @serializable.xml_sequence(21)
378    def stock_ids(self) -> Set[StockId]:
379        return self._stock_ids
380
381
382ThePhoenixProject_v1 = Book(
383    title='The Phoenix Project', isbn='978-1942788294', publish_date=date(year=2018, month=4, day=16),
384    authors=['Gene Kim', 'Kevin Behr', 'George Spafford'],
385    publisher=Publisher(name='IT Revolution Press LLC'),
386    edition=BookEdition(number=5, name='5th Anniversary Limited Edition'),
387    id=UUID('f3758bf0-0ff7-4366-a5e5-c209d4352b2d'),
388    rating=Decimal('9.8')
389)
390
391ThePhoenixProject_v1.chapters.append(Chapter(number=1, title='Tuesday, September 2'))
392ThePhoenixProject_v1.chapters.append(Chapter(number=2, title='Tuesday, September 2'))
393ThePhoenixProject_v1.chapters.append(Chapter(number=3, title='Tuesday, September 2'))
394ThePhoenixProject_v1.chapters.append(Chapter(number=4, title='Wednesday, September 3'))
395
396ThePhoenixProject_v2 = Book(
397    title='The Phoenix Project', isbn='978-1942788294', publish_date=date(year=2018, month=4, day=16),
398    authors=['Gene Kim', 'Kevin Behr', 'George Spafford'],
399    publisher=Publisher(name='IT Revolution Press LLC', address='10 Downing Street'),
400    edition=BookEdition(number=5, name='5th Anniversary Limited Edition'),
401    id=UUID('f3758bf0-0ff7-4366-a5e5-c209d4352b2d'),
402    rating=Decimal('9.8'),
403    stock_ids=[StockId('stock-id-1'), StockId('stock-id-2')]
404)
405
406ThePhoenixProject_v2.chapters.append(Chapter(number=1, title='Tuesday, September 2'))
407ThePhoenixProject_v2.chapters.append(Chapter(number=2, title='Tuesday, September 2'))
408ThePhoenixProject_v2.chapters.append(Chapter(number=3, title='Tuesday, September 2'))
409ThePhoenixProject_v2.chapters.append(Chapter(number=4, title='Wednesday, September 3'))
410
411SubRef1 = BookReference(ref='sub-ref-1')
412SubRef2 = BookReference(ref='sub-ref-2')
413SubRef3 = BookReference(ref='sub-ref-3')
414
415Ref1 = BookReference(ref='my-ref-1')
416Ref2 = BookReference(ref='my-ref-2', references=[SubRef1, SubRef3])
417Ref3 = BookReference(ref='my-ref-3', references=[SubRef2])
418
419ThePhoenixProject_v2.references = {Ref3, Ref2, Ref1}
420
421ThePhoenixProject = ThePhoenixProject_v2
422
423if __name__ == '__main__':
424    tpp_as_xml = ThePhoenixProject.as_xml()  # type:ignore[attr-defined]
425    tpp_as_json = ThePhoenixProject.as_json()  # type:ignore[attr-defined]
426    print(tpp_as_xml, tpp_as_json, sep='\n\n')
427
428    import io
429    import json
430
431    tpp_from_xml = ThePhoenixProject.from_xml(  # type:ignore[attr-defined]
432        io.StringIO(tpp_as_xml))
433    tpp_from_json = ThePhoenixProject.from_json(  # type:ignore[attr-defined]
434        json.loads(tpp_as_json))

Logging and log access

This library utilizes an own instance of Logger, which you may access and add handlers to.

Example: send all logs messages to stdErr
import sys
import logging
import serializable

my_log_handler = logging.StreamHandler(sys.stderr)
my_log_handler.setLevel(logging.DEBUG)
my_log_handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
serializable.logger.addHandler(my_log_handler)
serializable.logger.setLevel(my_log_handler.level)
serializable.logger.propagate = False

@serializable.serializable_class
class Chapter:

   def __init__(self, *, number: int, title: str) -> None:
     self._number = number
     self._title = title

   @property
   def number(self) -> int:
     return self._number

   @property
   def title(self) -> str:
     return self._title


moby_dick_c1 = Chapter(number=1, title='Loomings')
print(moby_dick_c1.as_json())

Support

If you run into issues utilising this library, please raise a GitHub Issue. When raising an issue please include as much detail as possible including:

  • Version of py-serializable you have installed

  • Input(s)

  • Expected Output(s)

  • Actual Output(s)

Python Version Support

We endeavour to support all functionality for all current actively supported Python versions. However, some features may not be possible/present in older Python versions due to their lack of support - which are noted below.

CHANGELOG

v1.0.3 (2024-04-04)

Chore

  • chore(deps-dev): update autopep8 requirement from 2.0.4 to 2.1.0 (#86)

Updates the requirements on autopep8 to permit the latest version.


updated-dependencies:

  • dependency-name: autopep8 dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``1577157` <https://github.com/madpah/serializable/commit/1577157b585f538d63dba80c26aa19c3804b2740>`_)

  • chore(deps-dev): update flake8-logging requirement from 1.5.0 to 1.6.0 (#87)

Updates the requirements on flake8-logging to permit the latest version.


updated-dependencies:

  • dependency-name: flake8-logging dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``7d64241` <https://github.com/madpah/serializable/commit/7d6424115c02543b5d37d6c0025eed70279e2eab>`_)

  • chore(deps-dev): update coverage requirement from 7.4.3 to 7.4.4 (#84)

Updates the requirements on coverage to permit the latest version.


updated-dependencies:

  • dependency-name: coverage dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``425f05e` <https://github.com/madpah/serializable/commit/425f05e7161d21534730349965fc1b3e896b4c9f>`_)

  • chore(deps-dev): update mypy requirement from 1.8.0 to 1.9.0 (#83)

Updates the requirements on mypy to permit the latest version.


updated-dependencies:

  • dependency-name: mypy dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``9fa5297` <https://github.com/madpah/serializable/commit/9fa52975c1267b952d961c69bd47e820b74d8084>`_)

Fix

  • fix: support deserialization of XML flat arrays where child_name does not conform to current formatter #89 (#90)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``ade5bd7` <https://github.com/madpah/serializable/commit/ade5bd76cf945b7380dbeac5e6233417da2d26c6>`_)

v1.0.2 (2024-03-01)

Build

  • build: use poetry v1.8.1 (#81)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``46a8d9e` <https://github.com/madpah/serializable/commit/46a8d9e629ac502864a99acaa9418d1c5cd32388>`_)

Chore

  • chore(deps-dev): update coverage requirement from 7.4.1 to 7.4.3 (#79)

Updates the requirements on coverage to permit the latest version.


updated-dependencies:

  • dependency-name: coverage dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``fbf9b06` <https://github.com/madpah/serializable/commit/fbf9b0609227ebb31ee3f652358f3e18e5ef71b8>`_)

  • chore(deps): bump Gr1N/setup-poetry from 8 to 9 (#80)

Bumps Gr1N/setup-poetry from 8 to 9.


updated-dependencies:

  • dependency-name: Gr1N/setup-poetry dependency-type: direct:production update-type: version-update:semver-major …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``3264bc6` <https://github.com/madpah/serializable/commit/3264bc6cf7ff7473968d506ea85ebc04ced0ea79>`_)

  • chore(deps-dev): update flake8-quotes requirement from 3.3.2 to 3.4.0 (#77)

Updates the requirements on flake8-quotes to permit the latest version.


updated-dependencies:

  • dependency-name: flake8-quotes dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``8a5460a` <https://github.com/madpah/serializable/commit/8a5460a453eaad49faf0245e435147bac727eb9e>`_)

v1.0.1 (2024-02-13)

Chore

  • chore(deps-dev): update coverage requirement from 7.4.0 to 7.4.1 (#69)

Updates the requirements on coverage to permit the latest version.


updated-dependencies:

  • dependency-name: coverage dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``447e6b8` <https://github.com/madpah/serializable/commit/447e6b8446382a8fdd27ffd83ed8bca03a7d9717>`_)

  • chore(deps-dev): update flake8-bugbear requirement (#71)

Updates the requirements on flake8-bugbear to permit the latest version.


updated-dependencies:

  • dependency-name: flake8-bugbear dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``e3e51a4` <https://github.com/madpah/serializable/commit/e3e51a4f25a0bc521bc035ce0e0df2de669c166e>`_)

  • chore(deps-dev): update flake8-logging requirement from 1.4.0 to 1.5.0 (#70)

Updates the requirements on flake8-logging to permit the latest version.


updated-dependencies:

  • dependency-name: flake8-logging dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``aeca110` <https://github.com/madpah/serializable/commit/aeca110db142699cae3b206640ba6dd6c6cbea74>`_)

  • chore(deps-dev): update flake8-bugbear requirement (#68)

Updates the requirements on flake8-bugbear to permit the latest version.


updated-dependencies:

  • dependency-name: flake8-bugbear dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``1727d78` <https://github.com/madpah/serializable/commit/1727d78783a893526ce402963c9ca4dcb86496a3>`_)

Fix

  • fix: serialization of datetime without timezone with local time offset (#76)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``06776ba` <https://github.com/madpah/serializable/commit/06776baef2cc4b893550320c474128317f6276c1>`_)

Refactor

  • refactor: usage of typing.Literal as non-string (#73)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``32fbe2a` <https://github.com/madpah/serializable/commit/32fbe2a5b2cbfa06ca8899d6e319a120971ee8e1>`_)

v1.0.0 (2024-01-22)

Breaking

  • feat!: v1.0.0 (#55)

    Release of first major version 🎉

    ## BREAKING Changes

    • Dropped support for python &lt;3.8


Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``2cee4d5` <https://github.com/madpah/serializable/commit/2cee4d5f48d59a737f4fc7b0e3d26fbce33c2392>`_)

Chore

  • chore: add flake8-logging (#61)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``cebb507` <https://github.com/madpah/serializable/commit/cebb507f67edde23da3586816819b144aa1051d1>`_)

Documentation

  • docs: fix conda link/url

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``5645ca6` <https://github.com/madpah/serializable/commit/5645ca65763198a166c348172cc29147881ad6f2>`_)

v0.17.1 (2024-01-07)

Documentation

  • docs: add "documentation" url to project meta

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``bf864d7` <https://github.com/madpah/serializable/commit/bf864d75d8a12426d4c71ae9ea1f533e730bd54e>`_)

  • docs: add "documentation" url to project meta

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``d3bcc42` <https://github.com/madpah/serializable/commit/d3bcc4258ab8cdf6c9e09b47985997cafdc19e9a>`_)

Fix

Unknown

  • 0.17.1

chore(release): 0.17.1

Automatically generated by python-semantic-release (``3b50104` <https://github.com/madpah/serializable/commit/3b501047671da16b6543abc4208d11e61c87b3d9>`_)

v0.17.0 (2024-01-06)

Chore

  • chore(deps-dev): update flake8 requirement from 6.1.0 to 7.0.0 (#52)

Updates the requirements on flake8 to permit the latest version.


updated-dependencies:

  • dependency-name: flake8 dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``14493ec` <https://github.com/madpah/serializable/commit/14493ec158def9c4bce1239efd0d70289919f60f>`_)

  • chore(deps): bump actions/checkout from 3 to 4 (#36)

Bumps actions/checkout from 3 to 4.


updated-dependencies:

  • dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``54576ff` <https://github.com/madpah/serializable/commit/54576ffe738892e525ee1ea8d84c53a6b518f6b1>`_)

  • chore: test with python 3.12 (#29)


Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; Co-authored-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``8051886` <https://github.com/madpah/serializable/commit/80518867cdf249bb50e71e6ef5ea6602297ca045>`_)

  • chore: Update dev tools, style (#44)


Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``b05e50b` <https://github.com/madpah/serializable/commit/b05e50b6ae503d047a33f62ccc865b9e810dba38>`_)

  • chore(deps-dev): update flake8-bugbear requirement (#43)

Updates the requirements on flake8-bugbear to permit the latest version.


updated-dependencies:

  • dependency-name: flake8-bugbear dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``7e77788` <https://github.com/madpah/serializable/commit/7e777885507b3cbba9d0dea86d841256bdd44db0>`_)

  • chore(deps-dev): update flake8-isort requirement from 4.2.0 to 6.0.0 (#40)

Updates the requirements on flake8-isort to permit the latest version.


updated-dependencies:

  • dependency-name: flake8-isort dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``8d3019e` <https://github.com/madpah/serializable/commit/8d3019ebfe2962b0d019700d30e42aab8a919581>`_)

  • chore(deps-dev): update coverage requirement from 7.2.1 to 7.2.7 (#42)

Updates the requirements on coverage to permit the latest version.


updated-dependencies:

  • dependency-name: coverage dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``f2bc2ad` <https://github.com/madpah/serializable/commit/f2bc2ad66e05b62af1b05ccb1383e71b5ca4b752>`_)

  • chore(deps-dev): update typing-extensions requirement (#41)

Updates the requirements on typing-extensions to permit the latest version.


updated-dependencies:

  • dependency-name: typing-extensions dependency-type: direct:development …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``0b36ea5` <https://github.com/madpah/serializable/commit/0b36ea53999920462473c7a0c24f256820f9d678>`_)

  • chore: update maintainers

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``4bcad49` <https://github.com/madpah/serializable/commit/4bcad49ef77a254db22930f0fbb24a55613437e3>`_)

  • chore(deps): bump actions/setup-python from 4 to 5 (#38)

Bumps actions/setup-python from 4 to 5.


updated-dependencies:

  • dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major …

Signed-off-by: dependabot[bot] &lt;support@github.com&gt; Co-authored-by: dependabot[bot] &lt;49699333+dependabot[bot]@users.noreply.github.com&gt; (``1578f13` <https://github.com/madpah/serializable/commit/1578f138b04a28672aaee4206fa7b52095f0a792>`_)

  • chore: prep maintenance (#35)


Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``a5db923` <https://github.com/madpah/serializable/commit/a5db92349f09145db187b60010e0df3e600af43b>`_)

Documentation

  • docs: modernixe read-the-docs

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``7ae6aad` <https://github.com/madpah/serializable/commit/7ae6aad3b5939508238d1502c116866ef79949cb>`_)

  • docs: homepage (#48)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``de206d6` <https://github.com/madpah/serializable/commit/de206d6083be643a58f08554b61518367f67cda1>`_)

  • docs: condaforge (#46)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``c0074ce` <https://github.com/madpah/serializable/commit/c0074ce911f66bc6de0a451b8922f80f1ffa6270>`_)

Feature

  • feat: logger (#47)

Reworked the way this library does logging/warning. It utilizes the logger named serializable for everything, now.


Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; Co-authored-by: Kyle Roeschley &lt;kyle.roeschley@ni.com&gt; (``9269b0e` <https://github.com/madpah/serializable/commit/9269b0e681665abaef3f110925cd098b2438880f>`_)

Unknown

  • 0.17.0

chore(release): 0.17.0

Automatically generated by python-semantic-release (``a6fc788` <https://github.com/madpah/serializable/commit/a6fc78853e13a3c7e922c7e95ef7cbbaa4bf3b1d>`_)

v0.16.0 (2023-11-29)

Feature

  • feat: more controll over XML attribute serialization (#34)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``38f42d6` <https://github.com/madpah/serializable/commit/38f42d64e556a85206faa50459a9ce3e889bd3ae>`_)

Unknown

  • 0.16.0

chore(release): 0.16.0

Automatically generated by python-semantic-release (``b444fd7` <https://github.com/madpah/serializable/commit/b444fd721102caaa51d0854fc6f6408e919a77d5>`_)

v0.15.0 (2023-10-10)

Feature

  • feat: allow custom (de)normalization (#32)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``aeecd6b` <https://github.com/madpah/serializable/commit/aeecd6b2e8c4e8febc84ebfa24fe7ec96fd9cb10>`_)

Unknown

  • 0.15.0

chore(release): 0.15.0

Automatically generated by python-semantic-release (``e80c514` <https://github.com/madpah/serializable/commit/e80c5146621e9ed1bfbe2118e36c269aa4cacdb8>`_)

v0.14.1 (2023-10-08)

Fix

  • fix: JSON deserialize Decimal (#31)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``b6dc66a` <https://github.com/madpah/serializable/commit/b6dc66acfb7fdc82b3dd18caf4ad79ec0e87eef0>`_)

Unknown

  • 0.14.1

chore(release): 0.14.1

Automatically generated by python-semantic-release (``0183a17` <https://github.com/madpah/serializable/commit/0183a174b5b9e402f20e3e240e565b124f2b008b>`_)

v0.14.0 (2023-10-06)

Feature

  • feat: enhanced typehints and typing (#27)

Even tough some structures are refactored, no public API is changed. No runtime is changed. TypeCheckers might behave differently, which is intentional due to bug fixes. This is considered a non-breaking change, as it does not affect runtime.


Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``410372a` <https://github.com/madpah/serializable/commit/410372a0fa2713c5a36d790f08d2d4b52a6a187c>`_)

Unknown

  • 0.14.0

chore(release): 0.14.0

Automatically generated by python-semantic-release (``7bb0d1b` <https://github.com/madpah/serializable/commit/7bb0d1b0fcf5b63770c214ec6e784f1f6ba94f58>`_)

v0.13.1 (2023-10-06)

Documentation

  • docs: add examples to docs (#28)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``4eddb24` <https://github.com/madpah/serializable/commit/4eddb242e51194694474748acdecd38b317b791e>`_)

  • docs: remove unnecessary type-ignores

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``26c561d` <https://github.com/madpah/serializable/commit/26c561dc0bf9f5755899a8fa0d0a37aba6275074>`_)

  • docs: remove unnecessary type-ignores

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``11b5896` <https://github.com/madpah/serializable/commit/11b5896057fd61838804ea5b52dc3bd0810f6c88>`_)

Fix

  • fix: protect default value for serialization_types from unintended downstream modifications (#30)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``0e814f5` <https://github.com/madpah/serializable/commit/0e814f5248176e02a7f96480e54320dde781f8b2>`_)

Refactor

  • refactor: _as_xml()'s klass_qualified_name module string from class, not instalce`

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``0499b59` <https://github.com/madpah/serializable/commit/0499b59b7e30711fa330058a4a711368c2677135>`_)

Unknown

  • 0.13.1

chore(release): 0.13.1

Automatically generated by python-semantic-release (``bd604c8` <https://github.com/madpah/serializable/commit/bd604c800e1a9ab6101ee8b7b810e92e6288de8b>`_)

  • tests: align tests with latest features/merges

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``76c566c` <https://github.com/madpah/serializable/commit/76c566c81e4121374f3874056bdaee225adbd363>`_)

v0.13.0 (2023-10-01)

Feature

  • feat: format specific (de)serialize (#25)

Added functionality to implement custom (de)serialization specific for XML or JSON (#13).

Changed

  • Class BaseHelper is no longer abstract.
    This class does not provide any functionality, it is more like a Protocol with some fallback implementations.

  • Method BaseHelper.serialize() is no longer abstract. Will raise NotImplementedError per default.

  • Method BaseHelper.deserialize() is no longer abstract. Will raise NotImplementedError per default.

Added

  • New method BaseHelper.json_serialize() predefined.
    Will call cls.serialize() per default.

  • New method BaseHelper.json_deserialize() predefined.
    Will call cls.deserialize() per default.


Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``dc998df` <https://github.com/madpah/serializable/commit/dc998df37a2ba37fa43d10c8a1ce044a5b9f5b1e>`_)

Unknown

  • 0.13.0

chore(release): 0.13.0

Automatically generated by python-semantic-release (``c1670d6` <https://github.com/madpah/serializable/commit/c1670d60e7f7adb0fd0f6be2f7cac89fff9315d9>`_)

v0.12.1 (2023-10-01)

Build

  • build: semantic-release sets library version everywhere (#16)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``296ef19` <https://github.com/madpah/serializable/commit/296ef196e8801b244843814d2d510f1e7d2044d4>`_)

Chore

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``4a7f5a1` <https://github.com/madpah/serializable/commit/4a7f5a1dbaa9d86565fd1993d6ae1d9fd7bb7d8a>`_)

Ci

  • ci: removed unused step

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``d63caa6` <https://github.com/madpah/serializable/commit/d63caa652c15137d2a8c65813b0e45005e5e52a9>`_)

Documentation

  • docs: render only public API (#19)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``fcc5d8e` <https://github.com/madpah/serializable/commit/fcc5d8e6c49e8b8c199cb55f855d09e4259a075a>`_)

  • docs: set codeblock language and caption (#15)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``5d5cf7b` <https://github.com/madpah/serializable/commit/5d5cf7bc29ed70f4024c714b2326012a9db54cea>`_)

Fix

  • fix: xml defaultNamespace serialization and detection (#20)

  • fixes: serialization with defaultNS fails #12

  • fixes: defaultNamespace detection fails on XML-attributes when deserializing #11


Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``59eaa5f` <https://github.com/madpah/serializable/commit/59eaa5f28eb2969e9d497669ef0436eb87b7525d>`_)

Refactor

  • refactor: simplify decorators (#26)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``a2b5503` <https://github.com/madpah/serializable/commit/a2b550349840f9f243df1bea77aff196f5e3e563>`_)

Unknown

  • 0.12.1

chore(release): 0.12.1

Automatically generated by python-semantic-release (``9a2798d` <https://github.com/madpah/serializable/commit/9a2798d23de90ed36a4aecb4ec955cbe037a4089>`_)

Signed-off-by: Jan Kowalleck &lt;jan.kowalleck@gmail.com&gt; (``68d229e` <https://github.com/madpah/serializable/commit/68d229e62d049713ade8e08487f491683b0bb0f9>`_)

  • Merge pull request #7 from claui/fix-top-level-license

Keep LICENSE in .dist-info when building wheel (``9bc4abc` <https://github.com/madpah/serializable/commit/9bc4abccc9cabed5f9808101a8d25717b86f01b4>`_)

  • Keep LICENSE in .dist-info when building wheel

Poetry automatically detects and includes LICENSE files in ….dist-info/ when it builds a wheel.

If LICENSE is also declared as a pattern in Poetry’s include list in pyproject.toml, then the file will appear in the root directory of the wheel, too:

Path = /var/lib/aurbuild/x86_64/claudia/build/python-py-serializable/src/serializable-0.12.0/dist/py_serializable-0.12.0-py3-none-any.whl
Type = zip
Physical Size = 22557

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
1980-01-01 00:00:00 .....        11357         3948  LICENSE
1980-01-01 00:00:00 .....        52795         9275  serializable/__init__.py
1980-01-01 00:00:00 .....         3382          923  serializable/formatters.py
1980-01-01 00:00:00 .....         3690         1180  serializable/helpers.py
1980-01-01 00:00:00 .....          153          117  serializable/py.typed
1980-01-01 00:00:00 .....        11357         3948  py_serializable-0.12.0.dist-info/LICENSE
1980-01-01 00:00:00 .....         3845         1449  py_serializable-0.12.0.dist-info/METADATA
1980-01-01 00:00:00 .....           88           85  py_serializable-0.12.0.dist-info/WHEEL
2016-01-01 00:00:00 .....          718          408  py_serializable-0.12.0.dist-info/RECORD
------------------- ----- ------------ ------------  ------------------------
2016-01-01 00:00:00              87385        21333  9 files

Note how the wheel contains two identical copies of your LICENSE file: one copy in the ….dist-info/ directory, picked up automatically by Poetry, and a second copy in the root directory of the wheel.

Including a generically-named file directly in a wheel’s root directory may cause problems:

  1. The LICENSE file is going to turn up at the top level of site-packages directly. That’s misleading, because anyone who’d browse site-packages might conclude that the license be valid for all packages, not just serializable, which is incorrect.

  2. Having generic files at the top level of site-packages causes conflicts with other wheels that happen to include the same file. For example, I’ve had LICENSE files coming from two different wheels, excluding serializable, sitting at the top level of my site-packages directory so I could install only one of them.

The fix is to remove the LICENSE pattern from the include list. Poetry automatically picks up files named LICENSE, and drops them either into an sdist’s root directory (when building an sdist) or into py_serializable-[version].dist-info/ (when building a wheel).

Signed-off-by: Claudia &lt;claui@users.noreply.github.com&gt; (``31e4003` <https://github.com/madpah/serializable/commit/31e4003e949b73a4cd7c18aac458200888c1a0f2>`_)

v0.12.0 (2023-03-07)

Ci

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``bcd15e2` <https://github.com/madpah/serializable/commit/bcd15e23d7be136d61cc285d2217945991094f70>`_)

  • ci: fix to CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``6eb28a6` <https://github.com/madpah/serializable/commit/6eb28a6097a62e98929fb657f27b68b736d54982>`_)

  • ci: update to run on 3.11 by default ci: consolidate to use Gr1N/setup-poetry and update to v8

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``7d65f32` <https://github.com/madpah/serializable/commit/7d65f328219edef784668f36583ca986ee0956f2>`_)

Feature

  • feat: bump dev dependencies to latest (including mypy fixes)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``06dcaa2` <https://github.com/madpah/serializable/commit/06dcaa28bfebb4505ddc67b287dc6f416822ffb6>`_)

  • feat: bump dev dependencies to latest (including mypy fixes)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``6d70287` <https://github.com/madpah/serializable/commit/6d70287640c411d33823e9188b0baa81fba80c24>`_)

Unknown

  • 0.12.0

Automatically generated by python-semantic-release (``fa9f9b3` <https://github.com/madpah/serializable/commit/fa9f9b39a13120a0b8d47b4fdb9469c2aa642cb6>`_)

  • Merge pull request #6 from madpah/fix/dep-updates

feat: bump dev dependencies to latest (including mypy fixes) (``08b4825` <https://github.com/madpah/serializable/commit/08b48253bacc62f8a0db54510bf6fe49df68a19f>`_)

v0.11.1 (2023-03-03)

Fix

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``32fd5a6` <https://github.com/madpah/serializable/commit/32fd5a698b41b489b4643bcbe795e24a1e0db423>`_)

  • fix: use defusedxml whenever we load XML to prevent XEE attacks

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``72e0127` <https://github.com/madpah/serializable/commit/72e01279274246313170e5e7c9d32afec16edf7c>`_)

  • fix: use defusedxml whenever we load XML to prevent XEE attacks

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``de61deb` <https://github.com/madpah/serializable/commit/de61deb5c2447a656ca6a111194b2b0ceeab9278>`_)

  • fix: use defusedxml whenever we load XML to prevent XEE attacks

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``de26dc3` <https://github.com/madpah/serializable/commit/de26dc3d0eaab533dac9b1db40f0add56dd67754>`_)

Unknown

  • 0.11.1

Automatically generated by python-semantic-release (``0bdccc4` <https://github.com/madpah/serializable/commit/0bdccc4a1a4b7fb74f2ea54898e5c08d133f6490>`_)

v0.11.0 (2023-03-03)

Ci

  • ci: revert to plain semantic-release to workaround poetry not found error

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``d3f7847` <https://github.com/madpah/serializable/commit/d3f78474c6484d3e440e979603af89799bc27456>`_)

Feature

  • feat: disabled handling to avoid class attributes that clash with keywords and builtins

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``4439227` <https://github.com/madpah/serializable/commit/44392274628ddec4aaaeae89a8387d435e3cf002>`_)

Unknown

  • 0.11.0

Automatically generated by python-semantic-release (``90de3b8` <https://github.com/madpah/serializable/commit/90de3b89974aafd39b6b386e0647989c65845e67>`_)

  • define commit_author?

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``4fad001` <https://github.com/madpah/serializable/commit/4fad001f6c631e23af911bd78469ad1a1ed8d2f6>`_)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``2f4d626` <https://github.com/madpah/serializable/commit/2f4d6262a4038b7f3e4da3b0ffe10b6293bd2227>`_)

  • Merge pull request #4 from madpah/feat/allow-python-keywords

feat: disabled handling to avoid class attributes that clash with keywords and builtins (``2a33bc6` <https://github.com/madpah/serializable/commit/2a33bc606e95995ae812e62c9018481c3353962f>`_)

  • cleanup

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``0ff402e` <https://github.com/madpah/serializable/commit/0ff402eb99e0073fa03ae0e19b881e352fbca2c7>`_)

v0.10.1 (2023-03-02)

Ci

  • ci: use higher powered GH token for release

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``1ea12f8` <https://github.com/madpah/serializable/commit/1ea12f8da136e94c33136da7c3f4a8409abeb0ef>`_)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``e6880ba` <https://github.com/madpah/serializable/commit/e6880ba4225fc85d48b61ee64f1adc1320cbc9ad>`_)

Fix

  • fix: handle empty XML elements during deserialization

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``f806f35` <https://github.com/madpah/serializable/commit/f806f3521f0afd8978f94f5ec355f47d9a538b91>`_)

Unknown

  • 0.10.1

Automatically generated by python-semantic-release (``69e5866` <https://github.com/madpah/serializable/commit/69e586630931c088381bfd687a00b83b55d360f8>`_)

v0.10.0 (2023-02-21)

Chore

  • chore: manual changelog

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``bc8300d` <https://github.com/madpah/serializable/commit/bc8300d323e6f7bfd7cc72a7b5ac89866f52cb38>`_)

Feature

  • feat: ability for custom type_mapping to take lower priority than xml_array

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``fc0bb22` <https://github.com/madpah/serializable/commit/fc0bb22f395498be42394af5f70addb9f63f0b3a>`_)

Unknown

  • 0.10.0

Automatically generated by python-semantic-release (``58d42ad` <https://github.com/madpah/serializable/commit/58d42ad0455495ad5998694cbd487866d682fed3>`_)

  • Merge pull request #3 from madpah/feat/recursive-parsing-differing-schemas

feat: xml_array has higher priority than type_mapping

feat: handle ForwardRef types (``664f947` <https://github.com/madpah/serializable/commit/664f947add279dad90ac9cf447a59059ab10d2cc>`_)

  • work to handle ForwardRef when we have cyclic references in models

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``a66e700` <https://github.com/madpah/serializable/commit/a66e700eeb5a80447522b8112ecdeff0345f0608>`_)

  • remove comment

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``6898b40` <https://github.com/madpah/serializable/commit/6898b40b6d55c70ade6e87de4a3cd4b8ce10a028>`_)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``2cfc44d` <https://github.com/madpah/serializable/commit/2cfc44ddc22d3ec5dc860d21297ab76b50102a74>`_)

v0.9.3 (2023-01-27)

Fix

  • fix: deserializing JSON with custom JSON name was incorrect

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``7d4aefc` <https://github.com/madpah/serializable/commit/7d4aefc98dfe39ae614227601369e9fd25c12faa>`_)

Unknown

  • 0.9.3

Automatically generated by python-semantic-release (``ccd610f` <https://github.com/madpah/serializable/commit/ccd610f7897e78478da7855095cf02580617340e>`_)

  • better logging for deserialization errors

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``a77452d` <https://github.com/madpah/serializable/commit/a77452d38e416aca59ef212379710c044885c383>`_)

  • added more logging

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``1f80c4b` <https://github.com/madpah/serializable/commit/1f80c4bb2390cbc5ebef87a8f32cc925f28bbde8>`_)

  • code style

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``8ca9e44` <https://github.com/madpah/serializable/commit/8ca9e44c479b35f0e599296b5e462dc87d9bf366>`_)

v0.9.2 (2023-01-27)

Fix

  • fix: nested array of Enum values in from_json() failed

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``ea4d76a` <https://github.com/madpah/serializable/commit/ea4d76a64c8c97f7cb0b16687f300c362dfe7623>`_)

  • fix: output better errors when deserializing JSON and we hit errors

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``1699c5b` <https://github.com/madpah/serializable/commit/1699c5b96bb6a8d4f034b29a6fe0521e3d650d53>`_)

Unknown

  • 0.9.2

Automatically generated by python-semantic-release (``435126c` <https://github.com/madpah/serializable/commit/435126c92032548944fe59243aa5935312ca7bfa>`_)

v0.9.1 (2023-01-26)

Fix

  • fix: nested array of Enum values in from_xml() failed

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``393a425` <https://github.com/madpah/serializable/commit/393a4256abb69228a9e6c2fc76b508e370a39d93>`_)

Unknown

  • 0.9.1

Automatically generated by python-semantic-release (``f4e018b` <https://github.com/madpah/serializable/commit/f4e018bf109c597ea70ce3a53a9d139aad926d2c>`_)

  • doc: added to docs to cover latest features and Views

fix: aligned View definition in unit tests with proper practice Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``c7c66f7` <https://github.com/madpah/serializable/commit/c7c66f719b93a9fc2c3929db67d0f7ae0665be7a>`_)

v0.9.0 (2023-01-24)

Chore

  • chore: silence mypy B027 forever

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``4112b7e` <https://github.com/madpah/serializable/commit/4112b7e604375130b3e43e65fc203264eead050c>`_)

  • chore: typing

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``ac67f09` <https://github.com/madpah/serializable/commit/ac67f090b16ec8fac5adb6d429c069751ff3bd69>`_)

  • chore: updated CI to test on Py 3.11

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``daa6c07` <https://github.com/madpah/serializable/commit/daa6c0797ef9c564509f0adbc57857c59ff93539>`_)

  • chore: updated CI to test on Py 3.11

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``c73dcde` <https://github.com/madpah/serializable/commit/c73dcdef9ca9b6d8ef3e1bff63cb751c1513143e>`_)

  • chore: fixed GitHub badge in README

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``e7895b7` <https://github.com/madpah/serializable/commit/e7895b7d637534f5792247916f9ef34c335721c4>`_)

Ci

  • ci: bump setup-poetry to v8 to gain support for Python 3.11

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``a5c4e25` <https://github.com/madpah/serializable/commit/a5c4e25afdfae8997f288023e7e2b9968cc161d1>`_)

Feature

  • feat: bring library to BETA state

feat: add support for Python 3.11 Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``c6c36d9` <https://github.com/madpah/serializable/commit/c6c36d911ae401af477bcc98633f10a87140d0a4>`_)

Unknown

  • 0.9.0

Automatically generated by python-semantic-release (``f5cb856` <https://github.com/madpah/serializable/commit/f5cb85629d6398956a4a1379e44bbd9a1f67d079>`_)

  • Merge pull request #2 from madpah/feat/support-py311

feat: bring library to BETA state &amp; add support Python 3.11 (``33c6756` <https://github.com/madpah/serializable/commit/33c6756d145a15c9d62216acc11568838bf0d1a0>`_)

v0.8.2 (2023-01-23)

Fix

  • fix: typing for @serializable.view was incorrect

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``756032b` <https://github.com/madpah/serializable/commit/756032b543a2fedac1bb61f57796eea438c0f9a7>`_)

  • fix: typing for @serializable.serializable_enum decorator was incorrect

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``84e7826` <https://github.com/madpah/serializable/commit/84e78262276833f507d4e8a1ce11d4a82733f395>`_)

Unknown

  • 0.8.2

Automatically generated by python-semantic-release (``3332ed9` <https://github.com/madpah/serializable/commit/3332ed98ae9c9bfae40df743ad4c0ea83eac038b>`_)

  • Merge pull request #1 from madpah/fix/typing

fix: typing only (``1860d4d` <https://github.com/madpah/serializable/commit/1860d4df369c8cf9cea917c025bb191fcd242f29>`_)

  • spacing

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``fdd5c8a` <https://github.com/madpah/serializable/commit/fdd5c8a344c3ace70170c91272074cbf6d0ebd01>`_)

v0.8.1 (2023-01-23)

Chore

  • chore: typing and import ordering

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``dd815c3` <https://github.com/madpah/serializable/commit/dd815c38b8e613abc0bdd65036782142c450198c>`_)

Fix

  • fix: Specific None value per View - support for XML was missing

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``5742861` <https://github.com/madpah/serializable/commit/5742861728d1b371bc0a819fed0b12e9da5829e1>`_)

Unknown

  • 0.8.1

Automatically generated by python-semantic-release (``c6d9db8` <https://github.com/madpah/serializable/commit/c6d9db8665e8d2c368004d3167d450c5f2f93c28>`_)

v0.8.0 (2023-01-20)

Chore

  • chore: remove poetry install from build command

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``b90da79` <https://github.com/madpah/serializable/commit/b90da79a5d90515cf7debf31da2bfd7482b81d04>`_)

Feature

  • feat: support for specific None values for Properties by View

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``a80ee35` <https://github.com/madpah/serializable/commit/a80ee3551c5e23f9c0491f48c3f98022317ddd99>`_)

Fix

  • fix: minor typing and styling

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``b728c4c` <https://github.com/madpah/serializable/commit/b728c4c995076cd18317c878c6f5900c6b266425>`_)

  • fix: minor typing and styling

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``b2ebcfb` <https://github.com/madpah/serializable/commit/b2ebcfb53cd640eb70a51a9f637db24e0d7b367e>`_)

Unknown

  • 0.8.0

Automatically generated by python-semantic-release (``4ccdfc9` <https://github.com/madpah/serializable/commit/4ccdfc98b2275efc744de0188152fcdcc560e00f>`_)

v0.7.3 (2022-09-22)

Fix

  • fix: None value for JSON is now None (null) fix: typing and coding standards

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``8b7f973` <https://github.com/madpah/serializable/commit/8b7f973cd96c861c4490c50553c880e88ebf33dc>`_)

Unknown

  • 0.7.3

Automatically generated by python-semantic-release (``8060db3` <https://github.com/madpah/serializable/commit/8060db392f47868bd61bcc333fad51cefd9d2e9f>`_)

v0.7.2 (2022-09-22)

Fix

  • fix: missing namespace for empty XML elements

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``f3659ab` <https://github.com/madpah/serializable/commit/f3659ab9ea651dcd65168aa22fa838d35ee189d5>`_)

Unknown

  • 0.7.2

Automatically generated by python-semantic-release (``08698d1` <https://github.com/madpah/serializable/commit/08698d10b9b0350458fb079b1ee38e5c118588d7>`_)

v0.7.1 (2022-09-15)

Fix

  • fix: support forced inclusion of array properties by using @serializable.include_none

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``7ad0ecf` <https://github.com/madpah/serializable/commit/7ad0ecf08c5f56de4584f4f081bfc0f667d2f477>`_)

  • fix: support for deserializing to objects from a primitive value

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``12f9f97` <https://github.com/madpah/serializable/commit/12f9f9711a5fd924898a0afb50a24c8d360ab3ff>`_)

Unknown

  • 0.7.1

Automatically generated by python-semantic-release (``01743f2` <https://github.com/madpah/serializable/commit/01743f27db48bb6e896531f1708d11a53571284a>`_)

v0.7.0 (2022-09-14)

Feature

  • feat: support for including None values, restricted to certain Views as required

fix: tests, imports and formatting Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``614068a` <https://github.com/madpah/serializable/commit/614068a4955f99d8fce5da341a1fd74a6772b775>`_)

Unknown

  • 0.7.0

Automatically generated by python-semantic-release (``4a007c0` <https://github.com/madpah/serializable/commit/4a007c0b3b2f22c4d26851267390909a01e8adf5>`_)

v0.6.0 (2022-09-14)

Feature

  • feat: implement views for serialization to JSON and XML

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``db57ef1` <https://github.com/madpah/serializable/commit/db57ef13fa89cc47db074bd9be4b48232842df07>`_)

Fix

  • fix: support for Decimal in JSON serialization

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``cc2c20f` <https://github.com/madpah/serializable/commit/cc2c20fe8bce46e4854cb0eecc6702459cd2f99a>`_)

  • fix: better serialization to JSON

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``e8b37f2` <https://github.com/madpah/serializable/commit/e8b37f2ee4246794c6c0e295bcdf32cd58d5e52d>`_)

Unknown

  • 0.6.0

Automatically generated by python-semantic-release (``da20686` <https://github.com/madpah/serializable/commit/da20686207f0ca95f7da29cb07f27ecc018b5134>`_)

v0.5.0 (2022-09-12)

Feature

  • feat: support for string formatting of values

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``99b8f3e` <https://github.com/madpah/serializable/commit/99b8f3e7ab84f087a87b330928fc598c96a0e682>`_)

  • feat: support string formatting for values

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``3fefe22` <https://github.com/madpah/serializable/commit/3fefe2294130b80f05e219bd655514a0956f7f93>`_)

  • feat: support for custom Enum implementations

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``c3622fc` <https://github.com/madpah/serializable/commit/c3622fcb0019de794b1cbd3ad6333b6044d8392a>`_)

Unknown

  • 0.5.0

Automatically generated by python-semantic-release (``0ede79d` <https://github.com/madpah/serializable/commit/0ede79daabcf3ce3c6364e8abc27f321db654a90>`_)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``a2a2ef8` <https://github.com/madpah/serializable/commit/a2a2ef86e2c9fe860453f755201507266c36daed>`_)

v0.4.0 (2022-09-06)

Chore

  • chore: increase logging to debug GH Actions

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``6111fbe` <https://github.com/madpah/serializable/commit/6111fbe5730e5923ca74732c8fda85f5e0fbd712>`_)

Feature

  • feat: add support for defining XML element ordering with @serializable.xml_sequence() decorator

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``c1442ae` <https://github.com/madpah/serializable/commit/c1442aeb1776243922fbaa6b5174db5a54f71920>`_)

Fix

  • fix: removed unused dependencies

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``448a3c9` <https://github.com/madpah/serializable/commit/448a3c9f0de897cf1ee6d7c46af377c2f389730d>`_)

  • fix: handle python builtins and keywords during as_xml() for element names

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``3bbfb1b` <https://github.com/madpah/serializable/commit/3bbfb1b4a7808f4cedd3b2b15f31aaaf8e35d60a>`_)

  • fix: handle python builtins and keywords during as_xml() for attributes

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``8d6a96b` <https://github.com/madpah/serializable/commit/8d6a96b0850d4993c96cbc7d532d848ba9c5e8b3>`_)

Unknown

  • 0.4.0

Automatically generated by python-semantic-release (``3034bd1` <https://github.com/madpah/serializable/commit/3034bd1f817e2cc24c10da4c7d0a1d68120f1fee>`_)

  • python &lt; 3.8 typing

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``339e53c` <https://github.com/madpah/serializable/commit/339e53cbec9a441ef9ef6ecea9f037c9085b6855>`_)

  • removed unused import

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``8462634` <https://github.com/madpah/serializable/commit/84626342df1dd5d9aea8d4c469431a0b19cf0bb3>`_)

  • updated release CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``f4cf0fa` <https://github.com/madpah/serializable/commit/f4cf0fa4d6a9f3349647caeb94d18b97bc836606>`_)

  • typing

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``0f9cf68` <https://github.com/madpah/serializable/commit/0f9cf68db3e676a9e16124c371359ec60e2fc304>`_)

  • cleanup

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``95a864a` <https://github.com/madpah/serializable/commit/95a864a1f9c67ec073308fdc3e97b82ce81b5392>`_)

  • test alternative poetry installation in CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``8eb8704` <https://github.com/madpah/serializable/commit/8eb8704f7b14767897093183020b71f6672f86c4>`_)

  • test alternative poetry installation in CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``8705180` <https://github.com/madpah/serializable/commit/87051801d6718c2eb4dd380e91bc30b9684a6386>`_)

  • test alternative poetry installation in CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``fe3f56a` <https://github.com/madpah/serializable/commit/fe3f56a26a20be4f6ccd3ae100300c947bdecf70>`_)

  • test alternative poetry installation in CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``4e7a19f` <https://github.com/madpah/serializable/commit/4e7a19fc54c2e51f6b963a4e9d758d0d8824413c>`_)

  • test alternative poetry installation in CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``7d268db` <https://github.com/madpah/serializable/commit/7d268dbad701604946877ef8e3947f8b14210f7e>`_)

  • test alternative poetry installation in CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``02caa9e` <https://github.com/madpah/serializable/commit/02caa9e35d3ac3a3b961b09cb9665e9f27ab1371>`_)

  • test alternative poetry installation in CI

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``210d41d` <https://github.com/madpah/serializable/commit/210d41d39418cd58af62b2672233e743dbd4372f>`_)

  • force poetry cache clear

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``731d7ae` <https://github.com/madpah/serializable/commit/731d7ae51ac7bd1225af7d3c757042cac9f3ac9c>`_)

  • bump poetry to 1.1.12

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``90b8a92` <https://github.com/madpah/serializable/commit/90b8a92327741c5b8b91a7fb1ef1356febe53944>`_)

  • typing

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``3427f4b` <https://github.com/madpah/serializable/commit/3427f4b5b136183b524cda871fb49f9ab78a20a7>`_)

  • doc: added docs for xml_sequence() decorator

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``d2211c9` <https://github.com/madpah/serializable/commit/d2211c90b65e27510711d90daf1b001f3e7c81e2>`_)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``2e32f08` <https://github.com/madpah/serializable/commit/2e32f084552bee69ad815466741d66fee96ff2e1>`_)

v0.3.9 (2022-08-24)

Fix

  • fix: support declaration of XML NS in as_xml() call

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``19b2b70` <https://github.com/madpah/serializable/commit/19b2b7048fdd7048d62f618987c13f2d3a457726>`_)

Unknown

  • 0.3.9

Automatically generated by python-semantic-release (``3269921` <https://github.com/madpah/serializable/commit/32699214554b0ec5d4b592f2ab70d6ae923c9e9c>`_)

v0.3.8 (2022-08-24)

Fix

  • fix: deserialization of XML boolean values

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``799d477` <https://github.com/madpah/serializable/commit/799d4773d858fdf8597bef905302a373ca150db8>`_)

Unknown

  • 0.3.8

Automatically generated by python-semantic-release (``dbf545c` <https://github.com/madpah/serializable/commit/dbf545cb4a51a10125a4104771ecca11e484ac53>`_)

v0.3.7 (2022-08-23)

Fix

  • fix: fixed deferred parsing for Properties

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``833e29b` <https://github.com/madpah/serializable/commit/833e29b8391c85931b12c98f87a2faf3a68d388e>`_)

Unknown

  • 0.3.7

Automatically generated by python-semantic-release (``1628f28` <https://github.com/madpah/serializable/commit/1628f2870c8de2643c74550cbe34c09d84b419d7>`_)

v0.3.6 (2022-08-23)

Fix

  • fix: support for cyclic dependencies

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``911626c` <https://github.com/madpah/serializable/commit/911626c88fb260049fdf2931f6ea1b0b05d7166a>`_)

Unknown

  • 0.3.6

Automatically generated by python-semantic-release (``54607f1` <https://github.com/madpah/serializable/commit/54607f1ac9e64e7cd8762699fd7f1567ac9c8d83>`_)

v0.3.5 (2022-08-22)

Fix

  • fix: support for non-primitive types when XmlSerializationType == FLAT

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``7eff15b` <https://github.com/madpah/serializable/commit/7eff15bbb8d20760418071c005d65d2623b44eab>`_)

Unknown

  • 0.3.5

Automatically generated by python-semantic-release (``d7e03d1` <https://github.com/madpah/serializable/commit/d7e03d13522d983ab79e4fa114f5deb4d43a7db9>`_)

v0.3.4 (2022-08-22)

Fix

  • fix: support ENUM in XML Attributes

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``f2f0922` <https://github.com/madpah/serializable/commit/f2f0922f2d0280185f6fc7f96408d6647588c8d2>`_)

Unknown

  • 0.3.4

Automatically generated by python-semantic-release (``adae34c` <https://github.com/madpah/serializable/commit/adae34c2c7be2ab920335d038cc4f9a80dbb128f>`_)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``7ec0197` <https://github.com/madpah/serializable/commit/7ec01978b2b581b0fbeb610b0707d4d6aa42ec1a>`_)

v0.3.3 (2022-08-19)

Fix

  • fix: handle Array types where the concrete type is quoted in its definition

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``b6db879` <https://github.com/madpah/serializable/commit/b6db879d72822ada74a41362594b009f09349da9>`_)

Unknown

  • 0.3.3

Automatically generated by python-semantic-release (``f0c463b` <https://github.com/madpah/serializable/commit/f0c463b45061b05e060df526185c3b374f49fda2>`_)

v0.3.2 (2022-08-19)

Fix

  • fix: work to support sortedcontainers as a return type for Properties

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``805a3f7` <https://github.com/madpah/serializable/commit/805a3f7a10e41f63b132ac0bb234497d5d39fe2b>`_)

Unknown

  • 0.3.2

Automatically generated by python-semantic-release (``f86da94` <https://github.com/madpah/serializable/commit/f86da944467b0d8ff571f3ca2e924b50e388bb4c>`_)

v0.3.1 (2022-08-19)

Fix

  • fix: better support for Properties that have a Class type that is not a Serializable Class (e.g. UUID)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``95d407b` <https://github.com/madpah/serializable/commit/95d407b4456d8f106cf54ceb650cbde1aab69457>`_)

Unknown

  • 0.3.1

Automatically generated by python-semantic-release (``53d96bd` <https://github.com/madpah/serializable/commit/53d96bd515bf4bafa1216bc6041e25b8f7ddecb7>`_)

v0.3.0 (2022-08-19)

Feature

  • feat: support ignoring elements/properties during deserialization

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``6319d1f` <https://github.com/madpah/serializable/commit/6319d1f9e632a941b1d79a63083c1ecb194105be>`_)

Unknown

  • 0.3.0

Automatically generated by python-semantic-release (``a286b88` <https://github.com/madpah/serializable/commit/a286b88a5a9cb17eaa4f04c94f9c0c148e9e7052>`_)

v0.2.3 (2022-08-19)

Chore

  • chore: address isort and flake8 errors

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``0ceb5a2` <https://github.com/madpah/serializable/commit/0ceb5a2291a17580296f1bbab133ef22a22bd103>`_)

Fix

  • fix: update helpers to be properly typed

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``d924dc2` <https://github.com/madpah/serializable/commit/d924dc2d3b5f02c61ff6ac36fa10fa6adaac7022>`_)

Unknown

  • 0.2.3

Automatically generated by python-semantic-release (``f632d2f` <https://github.com/madpah/serializable/commit/f632d2f10b7b5fb6cbdad038eaacaf73c2c9bbb7>`_)

v0.2.2 (2022-08-19)

Fix

  • fix: change to helpers to address typing issues

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``1c32ba1` <https://github.com/madpah/serializable/commit/1c32ba143504a605a77df4908422a95d0bd07edf>`_)

  • fix: remove / from method signature so we work on Python &lt; 3.8

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``c45864c` <https://github.com/madpah/serializable/commit/c45864cd6c90ed38d8cedd944adcfe43b32326b2>`_)

Unknown

  • 0.2.2

Automatically generated by python-semantic-release (``60045d8` <https://github.com/madpah/serializable/commit/60045d8342357b0a3ffe6b2a22abc9068f0d140c>`_)

v0.2.1 (2022-08-18)

Fix

  • fix: update to work on python &lt; 3.10

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``91df8cb` <https://github.com/madpah/serializable/commit/91df8cbb718db15ea182888aa796db32b8015004>`_)

Unknown

  • 0.2.1

Automatically generated by python-semantic-release (``4afc403` <https://github.com/madpah/serializable/commit/4afc4035f5dda5e6387963abb8d1332aa90dbd2c>`_)

v0.2.0 (2022-08-18)

Feature

  • feat: library re-write to utilise decorators

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``957fca7` <https://github.com/madpah/serializable/commit/957fca757d89dc1b8ef9b13357a5a9380dbe94ff>`_)

Unknown

  • 0.2.0

Automatically generated by python-semantic-release (``5bff0a8` <https://github.com/madpah/serializable/commit/5bff0a88ecc4c135ec60eafcc592f55157e1b103>`_)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``9f1b4ca` <https://github.com/madpah/serializable/commit/9f1b4ca17ee57f8a55ae211d78daed29c0068584>`_)

  • typing

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``d3633ed` <https://github.com/madpah/serializable/commit/d3633ed1fc09b72ea222a51b4a852dd7db52a0bf>`_)

  • typing

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``3480d71` <https://github.com/madpah/serializable/commit/3480d7126e063cef5746522479b381eba8cca818>`_)

  • removed print() calls - added logger

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``1deee5e` <https://github.com/madpah/serializable/commit/1deee5ec611a3c31f63a66be762caac70625472f>`_)

  • removed dead code

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``375b367` <https://github.com/madpah/serializable/commit/375b367e8705b5b6d0b5e4ac0c506776eb9da001>`_)

  • wip: all unit tests passing for JSON and XML after migrating to use of decorators

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``d4ab8f4` <https://github.com/madpah/serializable/commit/d4ab8f413b1f2bbf79e5a66ea353407f9dc15944>`_)

  • wip - JSON serialization and deserialization unit tests passing using decorators

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``291b37d` <https://github.com/madpah/serializable/commit/291b37da7d3f414750d555797f24378158eae4c4>`_)

  • wip - move to using Decorators to annotate classes to affect serialization/deserialization

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``05d6e5a` <https://github.com/madpah/serializable/commit/05d6e5a68630e4af09e81a02d5aca4a55391871a>`_)

v0.1.7 (2022-08-15)

Fix

  • fix: support for Objects that when represented in XML may just be simple elements with attributes

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``1369d7d` <https://github.com/madpah/serializable/commit/1369d7d755d9e50273b72e2fdd7d2967442e5bde>`_)

Unknown

  • 0.1.7

Automatically generated by python-semantic-release (``291a2b3` <https://github.com/madpah/serializable/commit/291a2b3822e2f5c0e4b1ed7c90b3205147f74704>`_)

v0.1.6 (2022-08-15)

Fix

  • fix: temporarilty add Any as part of AnySerializable type

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``d3e9beb` <https://github.com/madpah/serializable/commit/d3e9bebd7b8dc78d4eb36447ad0b1ee46e2745e0>`_)

Unknown

  • 0.1.6

Automatically generated by python-semantic-release (``77cc49b` <https://github.com/madpah/serializable/commit/77cc49bd1ad9fae4bed17eaf47659d584a3cec3f>`_)

v0.1.5 (2022-08-13)

Fix

  • fix: direct support for Python Enum

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``50148cc` <https://github.com/madpah/serializable/commit/50148cc98a26e4e51479b491acb58451ea5b42b6>`_)

Unknown

  • 0.1.5

Automatically generated by python-semantic-release (``532d0d1` <https://github.com/madpah/serializable/commit/532d0d1eb613d0c62e881cd898e5f5195a506b17>`_)

v0.1.4 (2022-08-13)

Fix

  • fix: added missing py.typed marker

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``ee3169f` <https://github.com/madpah/serializable/commit/ee3169f466353a88922174b40f5b29cb98998be9>`_)

Unknown

  • 0.1.4

Automatically generated by python-semantic-release (``02c2c30` <https://github.com/madpah/serializable/commit/02c2c3019de4939138c92d070ffdadb86d9dc7f4>`_)

v0.1.3 (2022-08-12)

Fix

  • fix: added helpers for serializing XML dates and times (xsd:date, xsd:datetime)

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``c309834` <https://github.com/madpah/serializable/commit/c3098346abf445876d99ecb768d7a4a08b12a291>`_)

Unknown

  • 0.1.3

Automatically generated by python-semantic-release (``9c6de39` <https://github.com/madpah/serializable/commit/9c6de399dd9ea70b2136a8aa0797a3bd3ffbc881>`_)

v0.1.2 (2022-08-12)

Fix

  • fix: support for properties whose value is an Type[SerializableObject] but are not List or Set

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``bf6773c` <https://github.com/madpah/serializable/commit/bf6773c40f3f45dbe2821fdbe785b369f0b3b71c>`_)

Unknown

  • 0.1.2

Automatically generated by python-semantic-release (``7ca1b6f` <https://github.com/madpah/serializable/commit/7ca1b6f92061c8cd73d8554c764dc4b39c2b6364>`_)

v0.1.1 (2022-08-11)

Fix

  • fix: handle nested objects that are not list or set

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``4bc5252` <https://github.com/madpah/serializable/commit/4bc525258d0ee655beabace18e41323b4b67ae1b>`_)

Unknown

  • 0.1.1

Automatically generated by python-semantic-release (``fc77999` <https://github.com/madpah/serializable/commit/fc77999d8ab8c8ac2f6273f64387f95104551e56>`_)

v0.1.0 (2022-08-10)

Chore

  • chore: corrected GitHub repo name

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``3dd770c` <https://github.com/madpah/serializable/commit/3dd770c3be7c1316fc292942f74e58e4df04158c>`_)

  • chore: corrected GitHub repo name

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``4d009b7` <https://github.com/madpah/serializable/commit/4d009b71b48badac55ac37994e3d4521d320270a>`_)

Feature

  • feat: first alpha release

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``c95a772` <https://github.com/madpah/serializable/commit/c95a7724186b6e45554624b5238c719d172ffc9f>`_)

  • feat: first working draft of library for (de-)serialization to/from JSON and XML

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``7af4f9c` <https://github.com/madpah/serializable/commit/7af4f9c4a100f1ce10502ecef228f42ea61e9c22>`_)

Unknown

  • 0.1.0

Automatically generated by python-semantic-release (``701a522` <https://github.com/madpah/serializable/commit/701a522410783677087a0da682f899f4fbd4368d>`_)

  • doc: fixed doc config and added first pass documentation

Signed-off-by: Paul Horton &lt;paul.horton@owasp.org&gt; (``38705a1` <https://github.com/madpah/serializable/commit/38705a1156d04a5ae5fc96c6cd691e1d1a0e2ead>`_)

API Reference

This page contains auto-generated API reference documentation [1].

serializable

Submodules

serializable.formatters
Module Contents
Classes

BaseNameFormatter

Helper class that provides a standard way to create an ABC using

CamelCasePropertyNameFormatter

Helper class that provides a standard way to create an ABC using

KebabCasePropertyNameFormatter

Helper class that provides a standard way to create an ABC using

SnakeCasePropertyNameFormatter

Helper class that provides a standard way to create an ABC using

CurrentFormatter

class serializable.formatters.BaseNameFormatter

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract classmethod encode(property_name: str) str
abstract classmethod decode(property_name: str) str
classmethod decode_as_class_name(name: str) str
classmethod decode_handle_python_builtins_and_keywords(name: str) str
classmethod encode_handle_python_builtins_and_keywords(name: str) str
class serializable.formatters.CamelCasePropertyNameFormatter

Bases: BaseNameFormatter

Helper class that provides a standard way to create an ABC using inheritance.

classmethod encode(property_name: str) str
classmethod decode(property_name: str) str
classmethod decode_as_class_name(name: str) str
classmethod decode_handle_python_builtins_and_keywords(name: str) str
classmethod encode_handle_python_builtins_and_keywords(name: str) str
class serializable.formatters.KebabCasePropertyNameFormatter

Bases: BaseNameFormatter

Helper class that provides a standard way to create an ABC using inheritance.

classmethod encode(property_name: str) str
classmethod decode(property_name: str) str
classmethod decode_as_class_name(name: str) str
classmethod decode_handle_python_builtins_and_keywords(name: str) str
classmethod encode_handle_python_builtins_and_keywords(name: str) str
class serializable.formatters.SnakeCasePropertyNameFormatter

Bases: BaseNameFormatter

Helper class that provides a standard way to create an ABC using inheritance.

classmethod encode(property_name: str) str
classmethod decode(property_name: str) str
classmethod decode_as_class_name(name: str) str
classmethod decode_handle_python_builtins_and_keywords(name: str) str
classmethod encode_handle_python_builtins_and_keywords(name: str) str
class serializable.formatters.CurrentFormatter
formatter: Type[BaseNameFormatter]
serializable.helpers
Module Contents
Classes

BaseHelper

Base Helper.

Iso8601Date

Base Helper.

XsdDate

Base Helper.

XsdDateTime

Base Helper.

class serializable.helpers.BaseHelper

Base Helper.

Inherit from this class and implement/override the needed functions!

This class does not provide any functionality, it is more like a Protocol with some fallback implementations.

abstract classmethod serialize(o: Any) Any | str

general purpose serializer

abstract classmethod deserialize(o: Any) Any

general purpose deserializer

classmethod json_normalize(o: Any, *, view: Type[serializable.ViewType] | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any | None

json specific normalizer

classmethod json_serialize(o: Any) str | Any

json specific serializer

classmethod json_denormalize(o: Any, *, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any

json specific denormalizer

Parameters:
  • tCls – the class that was desired to denormalize to

  • pCls – tha prent class - as context

classmethod json_deserialize(o: Any) Any

json specific deserializer

classmethod xml_normalize(o: Any, *, element_name: str, view: Type[serializable.ViewType] | None, xmlns: str | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) xml.etree.ElementTree.Element | Any | None

xml specific normalizer

classmethod xml_serialize(o: Any) str | Any

xml specific serializer

classmethod xml_denormalize(o: xml.etree.ElementTree.Element, *, default_ns: str | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any

xml specific denormalizer

classmethod xml_deserialize(o: str | Any) Any

xml specific deserializer

class serializable.helpers.Iso8601Date

Bases: BaseHelper

Base Helper.

Inherit from this class and implement/override the needed functions!

This class does not provide any functionality, it is more like a Protocol with some fallback implementations.

classmethod serialize(o: Any) str

general purpose serializer

classmethod deserialize(o: Any) datetime.date

general purpose deserializer

classmethod json_normalize(o: Any, *, view: Type[serializable.ViewType] | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any | None

json specific normalizer

classmethod json_serialize(o: Any) str | Any

json specific serializer

classmethod json_denormalize(o: Any, *, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any

json specific denormalizer

Parameters:
  • tCls – the class that was desired to denormalize to

  • pCls – tha prent class - as context

classmethod json_deserialize(o: Any) Any

json specific deserializer

classmethod xml_normalize(o: Any, *, element_name: str, view: Type[serializable.ViewType] | None, xmlns: str | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) xml.etree.ElementTree.Element | Any | None

xml specific normalizer

classmethod xml_serialize(o: Any) str | Any

xml specific serializer

classmethod xml_denormalize(o: xml.etree.ElementTree.Element, *, default_ns: str | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any

xml specific denormalizer

classmethod xml_deserialize(o: str | Any) Any

xml specific deserializer

class serializable.helpers.XsdDate

Bases: BaseHelper

Base Helper.

Inherit from this class and implement/override the needed functions!

This class does not provide any functionality, it is more like a Protocol with some fallback implementations.

classmethod serialize(o: Any) str

general purpose serializer

classmethod deserialize(o: Any) datetime.date

general purpose deserializer

classmethod json_normalize(o: Any, *, view: Type[serializable.ViewType] | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any | None

json specific normalizer

classmethod json_serialize(o: Any) str | Any

json specific serializer

classmethod json_denormalize(o: Any, *, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any

json specific denormalizer

Parameters:
  • tCls – the class that was desired to denormalize to

  • pCls – tha prent class - as context

classmethod json_deserialize(o: Any) Any

json specific deserializer

classmethod xml_normalize(o: Any, *, element_name: str, view: Type[serializable.ViewType] | None, xmlns: str | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) xml.etree.ElementTree.Element | Any | None

xml specific normalizer

classmethod xml_serialize(o: Any) str | Any

xml specific serializer

classmethod xml_denormalize(o: xml.etree.ElementTree.Element, *, default_ns: str | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any

xml specific denormalizer

classmethod xml_deserialize(o: str | Any) Any

xml specific deserializer

class serializable.helpers.XsdDateTime

Bases: BaseHelper

Base Helper.

Inherit from this class and implement/override the needed functions!

This class does not provide any functionality, it is more like a Protocol with some fallback implementations.

classmethod serialize(o: Any) str

general purpose serializer

classmethod deserialize(o: Any) datetime.datetime

general purpose deserializer

classmethod json_normalize(o: Any, *, view: Type[serializable.ViewType] | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any | None

json specific normalizer

classmethod json_serialize(o: Any) str | Any

json specific serializer

classmethod json_denormalize(o: Any, *, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any

json specific denormalizer

Parameters:
  • tCls – the class that was desired to denormalize to

  • pCls – tha prent class - as context

classmethod json_deserialize(o: Any) Any

json specific deserializer

classmethod xml_normalize(o: Any, *, element_name: str, view: Type[serializable.ViewType] | None, xmlns: str | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) xml.etree.ElementTree.Element | Any | None

xml specific normalizer

classmethod xml_serialize(o: Any) str | Any

xml specific serializer

classmethod xml_denormalize(o: xml.etree.ElementTree.Element, *, default_ns: str | None, prop_info: serializable.ObjectMetadataLibrary.SerializableProperty, ctx: Type[Any], **kwargs: Any) Any

xml specific denormalizer

classmethod xml_deserialize(o: str | Any) Any

xml specific deserializer

Package Contents

Classes

ViewType

Base of all views.

SerializationType

Enum to define the different formats supported for serialization and deserialization.

XmlArraySerializationType

Enum to differentiate how array-type properties (think Iterables) are serialized.

ObjectMetadataLibrary

namespace-like

Functions

serializable_enum(…)

Decorator

serializable_class(…)

Decorator used to tell serializable that a class is to be included in (de-)serialization.

type_mapping(→ Callable[[_F], _F])

Decorator

include_none(→ Callable[[_F], _F])

Decorator

json_name(→ Callable[[_F], _F])

Decorator

string_format(→ Callable[[_F], _F])

Decorator

view(→ Callable[[_F], _F])

Decorator

xml_attribute(→ Callable[[_F], _F])

Decorator

xml_array(→ Callable[[_F], _F])

Decorator

xml_name(→ Callable[[_F], _F])

Decorator

xml_sequence(→ Callable[[_F], _F])

Decorator

Attributes

logger

The logger. The thing that captures all this package has to say.

serializable.logger

The logger. The thing that captures all this package has to say. Feel free to modify its level and attach handlers to it.

class serializable.ViewType

Base of all views.

class serializable.SerializationType

Bases: str, enum.Enum

Enum to define the different formats supported for serialization and deserialization.

JSON = 'JSON'
XML = 'XML'
capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center()

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count()

S.count(sub[, start[, end]]) -> int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode()

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith()

S.endswith(suffix[, start[, end]]) -> bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs()

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find()

S.find(sub[, start[, end]]) -> int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format()

S.format(*args, **kwargs) -> str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map()

S.format_map(mapping) -> str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index()

S.index(sub[, start[, end]]) -> int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join()

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust()

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip()

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

partition()

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix()

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix()

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace()

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind()

S.rfind(sub[, start[, end]]) -> int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex()

S.rindex(sub[, start[, end]]) -> int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust()

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition()

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit()

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip()

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split()

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines()

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith()

S.startswith(prefix[, start[, end]]) -> bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip()

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate()

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill()

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

name()

The name of the Enum member.

value()

The value of the Enum member.

class serializable.XmlArraySerializationType(*args, **kwds)

Bases: enum.Enum

Enum to differentiate how array-type properties (think Iterables) are serialized.

Given a Warehouse has a property boxes that returns List[Box]:

FLAT would allow for XML looking like:

`` <warehouse>

<box>..box 1..</box> <box>..box 2..</box>

</warehouse> ``

NESTED would allow for XML looking like:

`` <warehouse>

<boxes>

<box>..box 1..</box> <box>..box 2..</box>

</boxes>

</warehouse> ``

FLAT = 1
NESTED = 2
name()

The name of the Enum member.

value()

The value of the Enum member.

class serializable.ObjectMetadataLibrary

namespace-like

The core Class in serializable that is used to record all metadata about classes that you annotate for serialization and deserialization.

class SerializableClass(*, klass: type, custom_name: str | None = None, serialization_types: Iterable[SerializationType] | None = None, ignore_during_deserialization: Iterable[str] | None = None)

Internal model class used to represent metadata we hold about Classes that are being included in (de-)serialization.

property name: str
property klass: type
property custom_name: str | None
property serialization_types: Iterable[SerializationType]
property ignore_during_deserialization: Set[str]
class SerializableProperty(*, prop_name: str, prop_type: Any, custom_names: Dict[SerializationType, str], custom_type: Any | None = None, include_none_config: Set[Tuple[Type[ViewType], Any]] | None = None, is_xml_attribute: bool = False, string_format_: str | None = None, views: Iterable[Type[ViewType]] | None = None, xml_array_config: Tuple[XmlArraySerializationType, str] | None = None, xml_sequence_: int | None = None)

Internal model class used to represent metadata we hold about Properties that are being included in (de-)serialization.

property name: str
property custom_names: Dict[SerializationType, str]
property type_: Any
property concrete_type: Any
property custom_type: Any | None
property include_none: bool
property include_none_views: Set[Tuple[Type[ViewType], Any]]
property is_xml_attribute: bool
property string_format: str | None
property views: Set[Type[ViewType]]
property xml_array_config: Tuple[XmlArraySerializationType, str] | None
property is_array: bool
property is_enum: bool
property is_optional: bool
property xml_sequence: int
custom_name(serialization_type: SerializationType) str | None
include_none_for_view(view_: Type[ViewType]) bool
get_none_value_for_view(view_: Type[ViewType] | None) Any
get_none_value(view_: Type[ViewType] | None = None) Any
is_helper_type() bool
is_primitive_type() bool
parse_type_deferred() None
custom_enum_klasses: Set[Type[enum.Enum]]
klass_mappings: Dict[str, ObjectMetadataLibrary]
klass_property_mappings: Dict[str, Dict[str, ObjectMetadataLibrary]]
classmethod defer_property_type_parsing(prop: ObjectMetadataLibrary, klasses: Iterable[str]) None
classmethod is_klass_serializable(klass: Any) bool
classmethod is_property(o: Any) bool
classmethod register_enum(klass: Type[_E]) Type[_E]
classmethod register_klass(klass: Type[_T], custom_name: str | None, serialization_types: Iterable[SerializationType], ignore_during_deserialization: Iterable[str] | None = None) Type[_T] | Type[_JsonSerializable] | Type[_XmlSerializable]
classmethod register_custom_json_property_name(qual_name: str, json_property_name: str) None
classmethod register_custom_string_format(qual_name: str, string_format: str) None
classmethod register_custom_xml_property_name(qual_name: str, xml_property_name: str) None
classmethod register_klass_view(klass: Type[_T], view_: Type[ViewType]) Type[_T]
classmethod register_property_include_none(qual_name: str, view_: Type[ViewType] | None = None, none_value: Any | None = None) None
classmethod register_property_view(qual_name: str, view_: Type[ViewType]) None
classmethod register_xml_property_array_config(qual_name: str, array_type: XmlArraySerializationType, child_name: str) None
classmethod register_xml_property_attribute(qual_name: str) None
classmethod register_xml_property_sequence(qual_name: str, sequence: int) None
classmethod register_property_type_mapping(qual_name: str, mapped_type: type) None
serializable.serializable_enum(cls: Literal[None] = None) Callable[[Type[_E]], Type[_E]]
serializable.serializable_enum(cls: Type[_E]) Type[_E]

Decorator

serializable.serializable_class(cls: Literal[None] = None, *, name: str | None = ..., serialization_types: Iterable[SerializationType] | None = ..., ignore_during_deserialization: Iterable[str] | None = ...) Callable[[Type[_T]], Type[_T] | Type[_JsonSerializable] | Type[_XmlSerializable]]
serializable.serializable_class(cls: Type[_T], *, name: str | None = ..., serialization_types: Iterable[SerializationType] | None = ..., ignore_during_deserialization: Iterable[str] | None = ...) Type[_T] | Type[_JsonSerializable] | Type[_XmlSerializable]

Decorator used to tell serializable that a class is to be included in (de-)serialization.

Parameters:
  • cls – Class

  • name – Alternative name to use for this Class

  • serialization_types – Serialization Types that are to be supported for this class.

  • ignore_during_deserialization – List of properties/elements to ignore during deserialization

Returns:

serializable.type_mapping(type_: type) Callable[[_F], _F]

Decorator

serializable.include_none(view_: Type[ViewType] | None = None, none_value: Any | None = None) Callable[[_F], _F]

Decorator

serializable.json_name(name: str) Callable[[_F], _F]

Decorator

serializable.string_format(format_: str) Callable[[_F], _F]

Decorator

serializable.view(view_: Type[ViewType]) Callable[[_F], _F]

Decorator

serializable.xml_attribute() Callable[[_F], _F]

Decorator

serializable.xml_array(array_type: XmlArraySerializationType, child_name: str) Callable[[_F], _F]

Decorator

serializable.xml_name(name: str) Callable[[_F], _F]

Decorator

serializable.xml_sequence(sequence: int) Callable[[_F], _F]

Decorator