-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Related to #331
Running typechecking validation using generated SDK by Kiota yields errors due to the inconsistencies .
1. Usage of the ParsableFactory
The functions below use the type as a parameter
- send_async (this applies to the Error map as well)- https://github.com/microsoft/kiota-abstractions-python/blob/06e6d07dc121d0585e83bc3befc4d3b6f0827c90/kiota_abstractions/request_adapter.py#L32
- get_object_value - https://github.com/microsoft/kiota-abstractions-python/blob/06e6d07dc121d0585e83bc3befc4d3b6f0827c90/kiota_abstractions/serialization/parse_node.py#L158
However, on generation, the parameters passed are not instances of the factory but type(class) definitions.
- send_async - https://github.com/microsoftgraph/msgraph-sdk-python/blob/416fccc20bd90a8f8d71ef7cc7519d2f63f488f5/msgraph/generated/storage/storage_request_builder.py#L52
- get_object_value - https://github.com/microsoftgraph/msgraph-sdk-python/blob/416fccc20bd90a8f8d71ef7cc7519d2f63f488f5/msgraph/generated/models/post.py#L83
- error_map (values)- https://github.com/microsoftgraph/msgraph-sdk-python/blob/416fccc20bd90a8f8d71ef7cc7519d2f63f488f5/msgraph/generated/storage/storage_request_builder.py#L46
The relevant implementations also happen to call the create_from_discriminator_value statically directly.
https://github.com/microsoft/kiota-serialization-json-python/blob/160d8a6d54237f96205f9972acbf17da5d80b2cd/kiota_serialization_json/json_parse_node.py#L215C18-L215C25
Resolving the typing inconsistency will need both generation and library changes as if we update the ParsableFactory to be a type variable as it is used and rename the current ParsableFactory we may end up breaking library functionalities calling methods like create_from_discriminator_value directly.
We probably need to either
- create a new type variable based of the
ParsableFactoryclass (or generate it inline) and generate it across the SDK to fix the type inconsistency and update the library parameter types to use this too. - update the library implementation of
ParsableFactoryto be consistent with other sdks and have the ParsableFactory be a function template. This would also involve updating the library implementations likeget_object_valueto no longer expect types and also probably be source breaking as well.
2. Return type of request executors should be optional in the case of returning streams/bytes
Taking a look at an example at
https://github.com/microsoftgraph/msgraph-sdk-python/blob/416fccc20bd90a8f8d71ef7cc7519d2f63f488f5/msgraph/generated/applications/item/logo/logo_request_builder.py#L49
The function ends up returning the result of send_primitive_async which is an optional not just bytes
Metadata
Metadata
Assignees
Labels
Type
Projects
Status