Repository: asyncapi/modelina (ts)

Issue:
[BUG] generates broken Python code, default kwarg repeated
### Describe the bug.

I just bumped `"@asyncapi/cli": "2.14.1"` to `"@asyncapi/cli": "2.16.0"` and was surprised to see my tests fail, cuz I didn't see any relevant changes in the release notes.

What I found was that there are now serializers and validators, which seems fine, but `asyncapi generate models python doc/asyncapi.yaml --pyDantic` generates broken code now:

```py
class AnonymousSchema1(BaseModel): 
  id: str = Field()
  source: str = Field()
  specversion: str = Field()
  type: str = Field()
  datacontenttype: Optional[str] = Field(default=None, default=None)
  dataschema: Optional[str] = Field(default=None, default=None)
  subject: Optional[str] = Field(default=None, default=None)
  time: Optional[str] = Field(default=None, default=None)
  data: Optional[Union[dict[str, Any], List[Any], str, float, bool]] = Field(default=None, default=None)
  data_base64: Optional[str] = Field(default=None, default=None)
  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True, default=None)
```

The kwarg `default` is repeated everywhere.

(It also has some unused imports, which bugs me a little :D)

### Expected behavior

Generates valid Python code.

### Screenshots

-

### How to Reproduce

1. grab an asyncapi example spec
2. add a nullable type (I guess), or just `$ref` https://raw.githubusercontent.com/cloudevents/spec/v1.0.2/cloudevents/formats/cloudevents.json
3. asyncapi generate models python doc/asyncapi.yaml --pyDantic


### 🥦 Browser

None

### 👀 Have you checked for similar open issues?

- [x] I checked and didn't find similar issue

### 🏢 Have you read the Contributing Guidelines?

- [x] I have read the [Contributing Guidelines](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md)

### Are you willing to work on this issue ?

Yes I am willing to submit a PR!

Pull request description:
fix: remove double None from Pydantic preset
@jonaslagoni not sure if you're the original author - could you review this? See #2174 

Fixes #2174

Patch:
diff --git a/examples/generate-python-pydantic-models/__snapshots__/index.spec.ts.snap b/examples/generate-python-pydantic-models/__snapshots__/index.spec.ts.snap
index 4633b737..6a9edff3 100644
--- a/examples/generate-python-pydantic-models/__snapshots__/index.spec.ts.snap
+++ b/examples/generate-python-pydantic-models/__snapshots__/index.spec.ts.snap
@@ -3,11 +3,11 @@
 exports[`Should be able to render python models and should log expected output to console: class-model 1`] = `
 Array [
   "class Root(BaseModel): 
-  optional_field: Optional[str] = Field(description='''this field is optional''', default=None, default=None)
+  optional_field: Optional[str] = Field(description='''this field is optional''', default=None)
   required_field: str = Field(description='''this field is required''')
-  no_description: Optional[str] = Field(default=None, default=None)
-  options: Optional[Options.Options] = Field(default=None, default=None)
-  content_type: Optional[str] = Field(default=None, default=None)
+  no_description: Optional[str] = Field(default=None)
+  options: Optional[Options.Options] = Field(default=None)
+  content_type: Optional[str] = Field(default=None)
 ",
 ]
 `;
diff --git a/src/generators/python/presets/Pydantic.ts b/src/generators/python/presets/Pydantic.ts
index facc117c..d4d1931d 100644
--- a/src/generators/python/presets/Pydantic.ts
+++ b/src/generators/python/presets/Pydantic.ts
@@ -59,9 +59,6 @@ const PYTHON_PYDANTIC_CLASS_PRESET: ClassPresetType<PythonOptions> = {
     ) {
       decoratorArgs.push('exclude=True');
     }
-    if (!property.required) {
-      decoratorArgs.push('default=None');
-    }
 
     return `${propertyName}: ${type} = Field(${decoratorArgs.join(', ')})`;
   },


Test patch:
diff --git a/test/generators/python/presets/__snapshots__/Pydantic.spec.ts.snap b/test/generators/python/presets/__snapshots__/Pydantic.spec.ts.snap
index 08f608f1..7135ae1e 100644
--- a/test/generators/python/presets/__snapshots__/Pydantic.spec.ts.snap
+++ b/test/generators/python/presets/__snapshots__/Pydantic.spec.ts.snap
@@ -4,7 +4,7 @@ exports[`PYTHON_PYDANTIC_PRESET should render nullable union 1`] = `
 Array [
   "class NullableUnionTest(BaseModel): 
   nullable_union_test: Optional[Union[Union1.Union1]] = Field(default=None)
-  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True, default=None)
+  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True)
 
   @model_serializer(mode='wrap')
   def custom_serializer(self, handler):
@@ -40,8 +40,8 @@ Array [
 
 ",
   "class Union1(BaseModel): 
-  test_prop1: Optional[str] = Field(default=None, default=None)
-  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True, default=None)
+  test_prop1: Optional[str] = Field(default=None)
+  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True)
 
   @model_serializer(mode='wrap')
   def custom_serializer(self, handler):
@@ -84,8 +84,8 @@ exports[`PYTHON_PYDANTIC_PRESET should render pydantic for class 1`] = `
   prop: Optional[str] = Field(description='''test
     multi
     line
-    description''', default=None, default=None)
-  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True, default=None)
+    description''', default=None)
+  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True)
 
   @model_serializer(mode='wrap')
   def custom_serializer(self, handler):
@@ -125,8 +125,8 @@ exports[`PYTHON_PYDANTIC_PRESET should render pydantic for class 1`] = `
 exports[`PYTHON_PYDANTIC_PRESET should render union to support Python < 3.10 1`] = `
 Array [
   "class UnionTest(BaseModel): 
-  union_test: Optional[Union[Union1.Union1, Union2.Union2]] = Field(default=None, default=None)
-  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True, default=None)
+  union_test: Optional[Union[Union1.Union1, Union2.Union2]] = Field(default=None)
+  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True)
 
   @model_serializer(mode='wrap')
   def custom_serializer(self, handler):
@@ -162,8 +162,8 @@ Array [
 
 ",
   "class Union1(BaseModel): 
-  test_prop1: Optional[str] = Field(default=None, default=None)
-  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True, default=None)
+  test_prop1: Optional[str] = Field(default=None)
+  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True)
 
   @model_serializer(mode='wrap')
   def custom_serializer(self, handler):
@@ -199,8 +199,8 @@ Array [
 
 ",
   "class Union2(BaseModel): 
-  test_prop2: Optional[str] = Field(default=None, default=None)
-  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True, default=None)
+  test_prop2: Optional[str] = Field(default=None)
+  additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True)
 
   @model_serializer(mode='wrap')
   def custom_serializer(self, handler):