Repository: marcosschroh/dataclasses-avroschema

Issue:
Unclear error message
**Describe the bug**
While doing `AvroBaseModel.avro_schema_to_python()`, I get the following exception:
```
RuntimeError: Type not yet supported: <class 'dataclasses_avroschema.pydantic.main.AvroBaseModel'>
```

I don't have any idea which type this is or where it is in the code. It would be great if this error included some information about which type is not supported and potentially how I can fix the error.


Discussion:
github-actions[bot]: [PR Preview Action](https://github.com/rossjrw/pr-preview-action) v1.4.8
:---:
:rocket: Deployed preview to https://marcosschroh.github.io/dataclasses-avroschema/pr-preview/pr-777/
on branch [`gh-pages`](https://github.com/marcosschroh/dataclasses-avroschema/tree/gh-pages) at 2024-10-17 07:13 UTC
<!-- Sticky Pull Request Commentpr-preview -->
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/marcosschroh/dataclasses-avroschema/pull/777?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 99.50%. Comparing base [(`0a2991e`)](https://app.codecov.io/gh/marcosschroh/dataclasses-avroschema/commit/0a2991e2a0e2080766d5b95a9a7b0e7c7659ef19?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh) to head [(`fff4db4`)](https://app.codecov.io/gh/marcosschroh/dataclasses-avroschema/commit/fff4db40810aecd62f8bd28d3ea447d83633d700?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master     #777   +/-   ##
=======================================
  Coverage   99.50%   99.50%           
=======================================
  Files          34       34           
  Lines        2012     2014    +2     
=======================================
+ Hits         2002     2004    +2     
  Misses         10       10           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/marcosschroh/dataclasses-avroschema/pull/777?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Marcos+Schroh).


Patch:
diff --git a/dataclasses_avroschema/main.py b/dataclasses_avroschema/main.py
index 34e02cd..63f7cfe 100644
--- a/dataclasses_avroschema/main.py
+++ b/dataclasses_avroschema/main.py
@@ -25,12 +25,15 @@ class AvroModel:
     _parser: Optional[Parser] = None
     _klass: Optional[Type] = None
     _metadata: Optional[SchemaMetadata] = None
-    _user_defined_types: Set[UserDefinedType] = set()
     _parent: Any = None
+    _user_defined_types: Set[UserDefinedType] = set()
     _rendered_schema: OrderedDict = dataclasses.field(default_factory=OrderedDict)
 
     @classmethod
     def generate_dataclass(cls: "Type[CT]") -> "Type[CT]":
+        if cls is AvroModel:
+            raise AttributeError("Schema generation must be called on a subclass of AvroModel, not AvroModel itself.")
+
         if dataclasses.is_dataclass(cls):
             return cls  # type: ignore
         return dataclasses.dataclass(cls)
@@ -69,7 +72,7 @@ class AvroModel:
     def generate_schema(
         cls: "Type[CT]", schema_type: serialization.SerializationType = "avro"
     ) -> Optional[OrderedDict]:
-        if cls._parser is None or cls.__mro__[1] != AvroModel:
+        if cls._parser is None:
             # Generate dataclass and metadata
             cls._klass = cls.generate_dataclass()
 


Test patch:
diff --git a/tests/schemas/test_schema.py b/tests/schemas/test_schema.py
index e38d930..48a8ca7 100644
--- a/tests/schemas/test_schema.py
+++ b/tests/schemas/test_schema.py
@@ -368,3 +368,21 @@ def test_avro_schema_method_with_inheritance() -> None:
         derived_b_schema
         == '{"type": "record", "name": "DerivedB", "fields": [{"name": "some_data", "type": "string"}, {"name": "some_more_data_B", "type": "string"}], "doc": "DerivedB docs"}'
     )
+
+
+def test_generate_schema_from_avro_model() -> None:
+    msg = "Schema generation must be called on a subclass of AvroModel, not AvroModel"
+    with pytest.raises(AttributeError, match=msg):
+        AvroModel.generate_schema()
+
+    with pytest.raises(AttributeError, match=msg):
+        AvroModel.avro_schema()
+
+    with pytest.raises(AttributeError, match=msg):
+        AvroModel.avro_schema_to_python()
+
+    with pytest.raises(AttributeError, match=msg):
+        AvroModel.get_fullname()
+
+    with pytest.raises(AttributeError, match=msg):
+        AvroModel.get_fields()