plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

feat: add type annotations to generated code

Open gvwilson opened this issue 11 months ago • 0 comments

feat: adding type annotations to some constructor parameters

Using get_typing_type from codegen/datatypes.py to add Python datatype to some constructor parameters.

Notes:

  1. Does not handle the compound datatype yet. get_typing_type raises a ValueError because it doesn't have a clause for this type; add_constructor_params catches this and simply doesn't add a type definition. Something between a third and half of all constructor parameters suffer from this, so we need to figure out what compound means and define a type for it. (See FIXME in the codegen directory.)

  2. Almost all parameters are nullable, so the type is defined as (for example) int but the default value assigned is None.

  3. Depends on #4978.

gvwilson avatar Feb 03 '25 14:02 gvwilson