You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #169 support for Python is being added in Typeshare. This enables the majority of Rust -> Python type translation use-cases leveraging Pydantic, a data validation library for Python.
This issue captures follow-up improvements for the Python typeshare implementation, that have been left out of scope for the first iteration.
Tighter type validation: conint from Pydantic (and other constrained types) can be used for tighter validation. For example, if the Rust type is u8, then we can leverage conint to bound the number from 0 to 255. Currently, this validation relies on the Rust deserializer.
Generics are not yet supported: struct and enum with generic parameters are not supported. For example, the test case can_generate_generic_enum is not enabled for Python as it is not supported. This can be achieved using TypeVar of the typing library.
Only support for adjacently tagged enums: Rust enums must be adjacently tagged, like #[serde(tag = "t", content = "c")], other enum representations, such as internally, externally or untagged are not supported. This is a limitation for the entire Typeshare framework, which already throws parsing errors in the absence of adjacent enum tags.
Type overriding is not supported: Type overriding with the #[typeshare] macro is not supported. See the test can_override_types for details.
Multi-file support: Currently, all the Python types are written to a single file. @darrell-roberts has shared a potential solution to this here.
part of this will be to remove the overriden generate_types function. See suggestion
In #169 support for Python is being added in Typeshare. This enables the majority of Rust -> Python type translation use-cases leveraging Pydantic, a data validation library for Python.
This issue captures follow-up improvements for the Python typeshare implementation, that have been left out of scope for the first iteration.
Tighter type validation:
conint
from Pydantic (and other constrained types) can be used for tighter validation. For example, if the Rust type is u8, then we can leverageconint
to bound the number from 0 to 255. Currently, this validation relies on the Rust deserializer.Generics are not yet supported:
struct
andenum
with generic parameters are not supported. For example, the test casecan_generate_generic_enum
is not enabled for Python as it is not supported. This can be achieved usingTypeVar
of the typing library.Only support for adjacently tagged enums: Rust
enum
s must be adjacently tagged, like#[serde(tag = "t", content = "c")]
, other enum representations, such as internally, externally or untagged are not supported. This is a limitation for the entire Typeshare framework, which already throws parsing errors in the absence of adjacent enum tags.Type overriding is not supported: Type overriding with the
#[typeshare]
macro is not supported. See the testcan_override_types
for details.Multi-file support: Currently, all the Python types are written to a single file. @darrell-roberts has shared a potential solution to this here.
generate_types
function. See suggestionOriginally posted by @CheatCod in #169 (comment)
The text was updated successfully, but these errors were encountered: