Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/return instance after deserialization #72

Merged
merged 8 commits into from
Aug 27, 2020
Prev Previous commit
Next Next commit
doc: documentation updated
  • Loading branch information
marcosschroh committed Aug 26, 2020
commit 8211c744c177f0d318dafddc7267239ec7ba1c72
2 changes: 0 additions & 2 deletions dataclasses_avroschema/schema_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from dacite import Config, from_dict

from dacite import Config, from_dict

from dataclasses_avroschema import schema_definition, serialization, utils

from .fields import FieldType
Expand Down
13 changes: 7 additions & 6 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ You will find a series of example about how to use [dataclasses-avroschema](http
## Installation

1. `python3.7 -m venv venv`
2. `pip install -r requirements.txt`
2. `source venv/bin/activate`
3. `pip install -r requirements.txt`

## Run the examples

Expand All @@ -19,9 +20,9 @@ You will find a series of example about how to use [dataclasses-avroschema](http

## Examples

### dataclasses-avroschema and aiokafka
As examples you will find how to serialize/deserialize python dataclasses using the `AvroModel` provided by `dataclasses-avroschema` and how to produce/consume events using specifics python kafka drivers.

In the file `aiokafka_example.py` you will find the integration between `dataclasses-avroschema` and `aiokafka`. We show you how to serialize/deserialize python dataclasses using the `AvroModel` and produce/consume the events with `aiokafka`. For this example we use the following model:
The model is for the examples is the following:

```python
@dataclass
Expand All @@ -38,8 +39,8 @@ class UserModel(AvroModel):
aliases = ["user-v1", "super user"]
```

and two `async` functions in order to produce and consume events.
[Example of dataclasses-avroschema and aiokafka](https://github.com/marcosschroh/dataclasses-avroschema/blob/feat/return-instance-after-deserialization/examples/aiokafka_example.py)

### dataclasses-avroschema and confluent
[Example of dataclasses-avroschema and confluent](https://github.com/marcosschroh/dataclasses-avroschema/blob/feat/return-instance-after-deserialization/examples/aiokafka_example.py)

### dataclasses-avroschema and kafka-python
[Example of dataclasses-avroschema and kafka-python](https://github.com/marcosschroh/dataclasses-avroschema/blob/feat/return-instance-after-deserialization/examples/aiokafka_example.py)
Empty file.
6 changes: 5 additions & 1 deletion tests/serialization/test_complex_types_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ def test_complex_fields_with_defaults(user_advance_with_defaults_dataclass):
}

user = user_advance_with_defaults_dataclass(**data)
expected_user = user_advance_with_defaults_dataclass(name="juan", age=20, favorite_colors="BLUE",)
expected_user = user_advance_with_defaults_dataclass(
name="juan",
age=20,
favorite_colors="BLUE",
)

avro_binary = user.serialize()
avro_json = user.serialize(serialization_type="avro-json")
Expand Down