Repository: marcosschroh/dataclasses-avroschema

Issue:
AttributeError: 'NoneType' object has no attribute 'fake'
**Describe the bug**

In my pydantic data model I have the following attribute `X: List[Optional[types.Float32]]`. When I call fake() of this class I get the error 'AttributeError: 'NoneType' object has no attribute 'fake''

**To Reproduce**
```py
from dataclasses_avroschema import types
from dataclasses_avroschema.avrodantic import AvroBaseModel 
from typing import List, Optional, Union

class Model(AvroBaseModel):
    A: str
    B: types.Float32
    X: List[Optional[types.Float32]]
    Y: List[Union[types.Float32, None]]

print(Model.fake())
```

**Expected behavior**

`A='BCGUpoVuoBhZZsPxLBTL' B=3.97300348265236 X=[0.22, 0.3, None] Y=[90.4, 3472.0, None]`

Discussion:
github-actions[bot]: [PR Preview Action](https://github.com/rossjrw/pr-preview-action) v1.3.0
:---:
:rocket: Deployed preview to https://marcosschroh.github.io/dataclasses-avroschema/pr-preview/pr-244/
on branch [`gh-pages`](https://github.com/marcosschroh/dataclasses-avroschema/tree/gh-pages) at 2023-02-16 07:56 UTC
<!-- Sticky Pull Request Commentpr-preview -->
codecov[bot]: # [Codecov](https://codecov.io/gh/marcosschroh/dataclasses-avroschema/pull/244?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh) Report
> Merging [#244](https://codecov.io/gh/marcosschroh/dataclasses-avroschema/pull/244?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh) (afbcca8) into [master](https://codecov.io/gh/marcosschroh/dataclasses-avroschema/commit/107ce8cafba9b3d69ca12a863d9c36b78f19bf67?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh) (107ce8c) will **not change** coverage.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##           master     #244   +/-   ##
=======================================
  Coverage   99.37%   99.37%           
=======================================
  Files          14       14           
  Lines        1281     1281           
  Branches      264      264           
=======================================
  Hits         1273     1273           
  Misses          3        3           
  Partials        5        5           
```


| [Impacted Files](https://codecov.io/gh/marcosschroh/dataclasses-avroschema/pull/244?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh) | Coverage Δ | |
|---|---|---|
| [dataclasses\_avroschema/fields.py](https://codecov.io/gh/marcosschroh/dataclasses-avroschema/pull/244?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh#diff-ZGF0YWNsYXNzZXNfYXZyb3NjaGVtYS9maWVsZHMucHk=) | `99.37% <100.00%> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh)


Patch:
diff --git a/dataclasses_avroschema/fields.py b/dataclasses_avroschema/fields.py
index c263d29..74a22a9 100644
--- a/dataclasses_avroschema/fields.py
+++ b/dataclasses_avroschema/fields.py
@@ -287,23 +287,22 @@ class ListField(ContainerField):
         items_type = self.type.__args__[0]
 
         if utils.is_union(items_type):
-            self.items_type = UnionField(
+            self.internal_field = UnionField(
                 self.name,
                 items_type,
                 default=self.default,
                 default_factory=self.default_factory,
                 model_metadata=self.model_metadata,
                 parent=self.parent,
-            ).get_avro_type()
+            )
         else:
             self.internal_field = AvroField(
                 self.name, items_type, model_metadata=self.model_metadata, parent=self.parent
             )
-            self.items_type = self.internal_field.get_avro_type()
+
+        self.items_type = self.internal_field.get_avro_type()
 
     def fake(self) -> typing.List:
-        # return a list of one element with the type specified
-        # TODO: check when the internal value is self reference which seems to return `None`
         return [self.internal_field.fake()]
 
 


Test patch:
diff --git a/tests/fake/test_fake.py b/tests/fake/test_fake.py
index 596adfb..c81f8f1 100644
--- a/tests/fake/test_fake.py
+++ b/tests/fake/test_fake.py
@@ -155,6 +155,7 @@ def test_self_one_to_many_relationship() -> None:
     class User(AvroModel):
         name: str
         age: int
+        points: typing.List[typing.Optional[types.Float32]]
         teamates: typing.Optional[typing.List[typing.Type["User"]]] = None
 
     assert isinstance(User.fake(), User)