Skip to content

Commit

Permalink
fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Nov 10, 2024
1 parent 03a5941 commit 4ca737d
Show file tree
Hide file tree
Showing 42 changed files with 49 additions and 42 deletions.
8 changes: 7 additions & 1 deletion src/Generator/Python.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ private function getImports(DefinitionTypeAbstract $origin): array

$imports[] = 'from pydantic import BaseModel, Field, GetCoreSchemaHandler';
$imports[] = 'from pydantic_core import CoreSchema, core_schema';
$imports[] = 'from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict';
$imports[] = 'from typing import Any, Dict, Generic, List, Optional, TypeVar';

if ($origin instanceof MapDefinitionType) {
$imports[] = 'from collections import UserDict';
} elseif ($origin instanceof ArrayDefinitionType) {
$imports[] = 'from collections import UserList';
}

if (TypeUtil::contains($origin, StringPropertyType::class, Format::DATE)) {
$imports[] = 'import datetime';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .property_type import PropertyType


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/argument.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .property_type import PropertyType
from .string_property_type import StringPropertyType
from .integer_property_type import IntegerPropertyType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .collection_definition_type import CollectionDefinitionType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .collection_property_type import CollectionPropertyType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .scalar_property_type import ScalarPropertyType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .map_definition_type import MapDefinitionType
from .array_definition_type import ArrayDefinitionType
from .definition_type import DefinitionType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .property_type import PropertyType
from .string_property_type import StringPropertyType
from .integer_property_type import IntegerPropertyType
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/definition_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .struct_definition_type import StructDefinitionType
from .map_definition_type import MapDefinitionType
from .array_definition_type import ArrayDefinitionType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .property_type import PropertyType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .scalar_property_type import ScalarPropertyType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .collection_definition_type import CollectionDefinitionType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .collection_property_type import CollectionPropertyType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .scalar_property_type import ScalarPropertyType


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/operation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .response import Response
from .argument import Argument

Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/property_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .string_property_type import StringPropertyType
from .integer_property_type import IntegerPropertyType
from .number_property_type import NumberPropertyType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .property_type import PropertyType


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .property_type import PropertyType
from .string_property_type import StringPropertyType
from .integer_property_type import IntegerPropertyType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .string_property_type import StringPropertyType
from .integer_property_type import IntegerPropertyType
from .number_property_type import NumberPropertyType
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/security.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .security_http_basic import SecurityHttpBasic
from .security_http_bearer import SecurityHttpBearer
from .security_api_key import SecurityApiKey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .security import Security


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .security import Security


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .security import Security


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/security_o_auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .security import Security


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .scalar_property_type import ScalarPropertyType


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .definition_type import DefinitionType
from .reference_property_type import ReferencePropertyType
from .property_type import PropertyType
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/type_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .type_schema import TypeSchema
from .security import Security
from .operation import Operation
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/complex/type_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .definition_type import DefinitionType


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/default/author.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .location import Location


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/default/location.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar


# Location of the person
Expand Down
3 changes: 2 additions & 1 deletion tests/Generator/resource/python/default/meta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from collections import UserDict


class Meta(UserDict[str, str]):
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/default/news.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
import datetime
from .meta import Meta
from .author import Author
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/import/import.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .student_map import StudentMap
from .student import Student

Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/import/my_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .student import Student


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/namespace/import.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .student_map import StudentMap
from .student import Student

Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/namespace/my_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .student import Student


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/oop/human_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .map import Map
from .human_type import HumanType

Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/oop/human_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .human_type import HumanType


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/oop/map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar


P = TypeVar("P")
Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/oop/root_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .student_map import StudentMap


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/oop/student.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .human_type import HumanType


Expand Down
2 changes: 1 addition & 1 deletion tests/Generator/resource/python/oop/student_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar, UserList, UserDict
from typing import Any, Dict, Generic, List, Optional, TypeVar
from .map import Map
from .human_type import HumanType
from .student import Student
Expand Down

0 comments on commit 4ca737d

Please sign in to comment.