Skip to content

Adding loosly defined types  #788

@cesco-fran

Description

@cesco-fran

Problems:

  • You want define a type that is not possible to define in python at the moment of writing.
  • You can define a type but you choose to defer its precise definition is a later time.

You have a type annotation that allow you to declare
that the type you are defining is just an approximation of the type you
would like to define.

Example: You want define a type to define the data structure that can
be json serialize, at this time this is not possible with actual typing system.
So you make the best approximation you do and decorate it with the LooseType annotation.

JsonType = LooseType(Union[List[..,], Dict[...]])

Now you can use this annotation with mypy or other related tool
to keep track of the type that are not precisely defined, and that in
the future you can improve thanks to update of the python typing system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: featureDiscussions about new features for Python's type annotations

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions