Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ jobs:
- image: circleci/python:3.6
environment:
TOXENV: py36-core
py37-core:
<<: *common
docker:
- image: circleci/python:3.7
environment:
TOXENV: py37-core
pypy3-core:
<<: *common
docker:
Expand All @@ -71,6 +77,12 @@ jobs:
- image: circleci/python:3.6
environment:
TOXENV: py36-doctest
py37-doctest:
<<: *common
docker:
- image: circleci/python:3.7
environment:
TOXENV: py37-doctest
pypy3-doctest:
<<: *common
docker:
Expand All @@ -91,10 +103,12 @@ workflows:
jobs:
- py35-core
- py36-core
- py37-core
- pypy3-core

- py35-doctest
- py36-doctest
- py37-doctest
- pypy3-doctest

- lint
17 changes: 16 additions & 1 deletion rlp/sedes/serializable.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,23 @@ def __new__(cls, name, bases, attrs):
# If this is the original creation of the `Serializable` class,
# just create the class.
return super_new(cls, name, bases, attrs)

# The class being constructed is a subclass of `Serializable`.

annotated_fields = tuple(
(field, sede)
for field, sede in attrs.get('__annotations__', {}).items()
if hasattr(sede, 'serialize') and hasattr(sede, 'deserialize')
)

if declares_fields and annotated_fields:
raise TypeError(
f"{name} defines both a 'fields' attribute as well as annotated fields."
)
elif not declares_fields:
if has_multiple_serializable_parents:
if annotated_fields:
fields = annotated_fields
elif has_multiple_serializable_parents:
raise TypeError(
"Cannot create subclass from multiple parent `Serializable` "
"classes without explicit `fields` declaration."
Expand Down
Loading