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

Update validation project with typing updates #434

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/validation/validation/kiota-lock.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"descriptionHash": "CE55775E5E36A748E59FB2BA5E63C392C63AA9CC15CE23D56FB5C14B92BBFA708FF5D4386EC1532D7A7BB74C8D9E80AE6482AB3806FB0393E1DD8151FAE8FE50",
"descriptionHash": "3DC72B5983908CB42E339F1D48A1BC8C0AE0770120FA8B34C3720F9542528E5E8658FF0D371EAFFFB66493724EEFC1D12FB138D0DF1F63D8AA202485F8A3F5E4",
"descriptionLocation": "https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/dev/openApiDocs/v1.0/Mail.yml",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.19.0",
"kiotaVersion": "1.22.0",
"clientClassName": "ValidationClient",
"typeAccessModifier": "Public",
"clientNamespaceName": "validation",
Expand Down
13 changes: 8 additions & 5 deletions tests/validation/validation/models/attachment.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from __future__ import annotations
import datetime
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
from .entity import Entity

from .entity import Entity

@dataclass
class Attachment(Entity):
class Attachment(Entity, Parsable):
# The MIME type.
content_type: Optional[str] = None
# true if the attachment is an inline attachment; otherwise, false.
Expand All @@ -33,16 +34,16 @@ def create_from_discriminator_value(parse_node: ParseNode) -> Attachment:
raise TypeError("parse_node cannot be null.")
return Attachment()

def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
from .entity import Entity

from .entity import Entity

fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"contentType": lambda n : setattr(self, 'content_type', n.get_str_value()),
"isInline": lambda n : setattr(self, 'is_inline', n.get_bool_value()),
"lastModifiedDateTime": lambda n : setattr(self, 'last_modified_date_time', n.get_datetime_value()),
Expand All @@ -62,6 +63,8 @@ def serialize(self,writer: SerializationWriter) -> None:
if writer is None:
raise TypeError("writer cannot be null.")
super().serialize(writer)
from .entity import Entity

writer.write_str_value("contentType", self.content_type)
writer.write_bool_value("isInline", self.is_inline)
writer.write_datetime_value("lastModifiedDateTime", self.last_modified_date_time)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
from .attachment import Attachment

@dataclass
class AttachmentCollectionResponse(AdditionalDataHolder, Parsable):
# Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
additional_data: Dict[str, Any] = field(default_factory=dict)
additional_data: dict[str, Any] = field(default_factory=dict)

# The OdataNextLink property
odata_next_link: Optional[str] = None
# The value property
value: Optional[List[Attachment]] = None
value: Optional[list[Attachment]] = None

@staticmethod
def create_from_discriminator_value(parse_node: ParseNode) -> AttachmentCollectionResponse:
Expand All @@ -27,16 +28,16 @@ def create_from_discriminator_value(parse_node: ParseNode) -> AttachmentCollecti
raise TypeError("parse_node cannot be null.")
return AttachmentCollectionResponse()

def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
from .attachment import Attachment

from .attachment import Attachment

fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"@odata.nextLink": lambda n : setattr(self, 'odata_next_link', n.get_str_value()),
"value": lambda n : setattr(self, 'value', n.get_collection_of_object_values(Attachment)),
}
Expand All @@ -50,6 +51,8 @@ def serialize(self,writer: SerializationWriter) -> None:
"""
if writer is None:
raise TypeError("writer cannot be null.")
from .attachment import Attachment

writer.write_str_value("@odata.nextLink", self.odata_next_link)
writer.write_collection_of_object_values("value", self.value)
writer.write_additional_data_value(self.additional_data)
Expand Down
11 changes: 6 additions & 5 deletions tests/validation/validation/models/date_time_time_zone.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING, Union

@dataclass
class DateTimeTimeZone(AdditionalDataHolder, Parsable):
# Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
additional_data: Dict[str, Any] = field(default_factory=dict)
additional_data: dict[str, Any] = field(default_factory=dict)

# A single point of time in a combined date and time representation ({date}T{time}; for example, 2017-08-29T04:00:00.0000000).
date_time: Optional[str] = None
Expand All @@ -24,12 +25,12 @@ def create_from_discriminator_value(parse_node: ParseNode) -> DateTimeTimeZone:
raise TypeError("parse_node cannot be null.")
return DateTimeTimeZone()

def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"dateTime": lambda n : setattr(self, 'date_time', n.get_str_value()),
"timeZone": lambda n : setattr(self, 'time_zone', n.get_str_value()),
}
Expand Down
11 changes: 6 additions & 5 deletions tests/validation/validation/models/email_address.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING, Union

@dataclass
class EmailAddress(AdditionalDataHolder, Parsable):
# Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
additional_data: Dict[str, Any] = field(default_factory=dict)
additional_data: dict[str, Any] = field(default_factory=dict)

# The email address of the person or entity.
address: Optional[str] = None
Expand All @@ -24,12 +25,12 @@ def create_from_discriminator_value(parse_node: ParseNode) -> EmailAddress:
raise TypeError("parse_node cannot be null.")
return EmailAddress()

def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"address": lambda n : setattr(self, 'address', n.get_str_value()),
"name": lambda n : setattr(self, 'name', n.get_str_value()),
}
Expand Down
11 changes: 6 additions & 5 deletions tests/validation/validation/models/entity.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING, Union

@dataclass
class Entity(AdditionalDataHolder, Parsable):
# Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
additional_data: Dict[str, Any] = field(default_factory=dict)
additional_data: dict[str, Any] = field(default_factory=dict)

# The unique identifier for an entity. Read-only.
id: Optional[str] = None
Expand All @@ -22,12 +23,12 @@ def create_from_discriminator_value(parse_node: ParseNode) -> Entity:
raise TypeError("parse_node cannot be null.")
return Entity()

def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"id": lambda n : setattr(self, 'id', n.get_str_value()),
}
return fields
Expand Down
13 changes: 8 additions & 5 deletions tests/validation/validation/models/extension.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
from .entity import Entity

from .entity import Entity

@dataclass
class Extension(Entity):
class Extension(Entity, Parsable):

@staticmethod
def create_from_discriminator_value(parse_node: ParseNode) -> Extension:
Expand All @@ -22,16 +23,16 @@ def create_from_discriminator_value(parse_node: ParseNode) -> Extension:
raise TypeError("parse_node cannot be null.")
return Extension()

def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
from .entity import Entity

from .entity import Entity

fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
}
super_fields = super().get_field_deserializers()
fields.update(super_fields)
Expand All @@ -46,5 +47,7 @@ def serialize(self,writer: SerializationWriter) -> None:
if writer is None:
raise TypeError("writer cannot be null.")
super().serialize(writer)
from .entity import Entity



Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
from .extension import Extension

@dataclass
class ExtensionCollectionResponse(AdditionalDataHolder, Parsable):
# Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
additional_data: Dict[str, Any] = field(default_factory=dict)
additional_data: dict[str, Any] = field(default_factory=dict)

# The OdataNextLink property
odata_next_link: Optional[str] = None
# The value property
value: Optional[List[Extension]] = None
value: Optional[list[Extension]] = None

@staticmethod
def create_from_discriminator_value(parse_node: ParseNode) -> ExtensionCollectionResponse:
Expand All @@ -27,16 +28,16 @@ def create_from_discriminator_value(parse_node: ParseNode) -> ExtensionCollectio
raise TypeError("parse_node cannot be null.")
return ExtensionCollectionResponse()

def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
from .extension import Extension

from .extension import Extension

fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"@odata.nextLink": lambda n : setattr(self, 'odata_next_link', n.get_str_value()),
"value": lambda n : setattr(self, 'value', n.get_collection_of_object_values(Extension)),
}
Expand All @@ -50,6 +51,8 @@ def serialize(self,writer: SerializationWriter) -> None:
"""
if writer is None:
raise TypeError("writer cannot be null.")
from .extension import Extension

writer.write_str_value("@odata.nextLink", self.odata_next_link)
writer.write_collection_of_object_values("value", self.value)
writer.write_additional_data_value(self.additional_data)
Expand Down
14 changes: 9 additions & 5 deletions tests/validation/validation/models/followup_flag.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import AdditionalDataHolder, Parsable, ParseNode, SerializationWriter
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
from .date_time_time_zone import DateTimeTimeZone
Expand All @@ -10,7 +11,7 @@
@dataclass
class FollowupFlag(AdditionalDataHolder, Parsable):
# Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
additional_data: Dict[str, Any] = field(default_factory=dict)
additional_data: dict[str, Any] = field(default_factory=dict)

# The completedDateTime property
completed_date_time: Optional[DateTimeTimeZone] = None
Expand All @@ -32,18 +33,18 @@ def create_from_discriminator_value(parse_node: ParseNode) -> FollowupFlag:
raise TypeError("parse_node cannot be null.")
return FollowupFlag()

def get_field_deserializers(self,) -> Dict[str, Callable[[ParseNode], None]]:
def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
"""
The deserialization information for the current model
Returns: Dict[str, Callable[[ParseNode], None]]
Returns: dict[str, Callable[[ParseNode], None]]
"""
from .date_time_time_zone import DateTimeTimeZone
from .followup_flag_status import FollowupFlagStatus

from .date_time_time_zone import DateTimeTimeZone
from .followup_flag_status import FollowupFlagStatus

fields: Dict[str, Callable[[Any], None]] = {
fields: dict[str, Callable[[Any], None]] = {
"completedDateTime": lambda n : setattr(self, 'completed_date_time', n.get_object_value(DateTimeTimeZone)),
"dueDateTime": lambda n : setattr(self, 'due_date_time', n.get_object_value(DateTimeTimeZone)),
"flagStatus": lambda n : setattr(self, 'flag_status', n.get_enum_value(FollowupFlagStatus)),
Expand All @@ -59,6 +60,9 @@ def serialize(self,writer: SerializationWriter) -> None:
"""
if writer is None:
raise TypeError("writer cannot be null.")
from .date_time_time_zone import DateTimeTimeZone
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we're getting those local imports we don't seem to be doing anything with?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that. I'll take spike at this first before merging this to figure out if we should handle this separately.

from .followup_flag_status import FollowupFlagStatus

writer.write_object_value("completedDateTime", self.completed_date_time)
writer.write_object_value("dueDateTime", self.due_date_time)
writer.write_enum_value("flagStatus", self.flag_status)
Expand Down
Loading