Skip to content

Inconsistent typing used in generated code and the libraries. #333

@andrueastman

Description

@andrueastman

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

However, on generation, the parameters passed are not instances of the factory but type(class) definitions.

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 ParsableFactory class (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 ParsableFactory to be consistent with other sdks and have the ParsableFactory be a function template. This would also involve updating the library implementations like get_object_value to 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

bugSomething isn't working

Type

No type

Projects

Status

Done ✔️

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions