minos-python icon indicating copy to clipboard operation
minos-python copied to clipboard

`minos.common.Field` must accept `tuple` type

Open garciparedes opened this issue 4 years ago • 3 comments

Issue by garciparedes Monday May 10, 2021 at 13:09 GMT Originally opened as https://github.com/Clariteia/minos_microservice_common/issues/193


The current MinosModel field typing is not compatible with the tuple type, which causes a big modelling issue in cases in which it's needed to define an unnamed type validation, such us tuple[str, int float] (the fields must have str, int and float types respectively.

Currently, there is a workaround to obtain a similar behaviour, combining the list + Union operators and writing as list[Union[str, int, float] but the obtained result is not strictly the same, because in this case there is not any ordering constraint nor any sequence-length constraint. In this case a [3, "foo", 4.35] is a valid value, but also a ["foo"] and [] are also fine according to that typing, so that it could carry future type checking errors or misconceptions.

For the above causes, I propose to extend the MinosModel type compatibility including the tuple.

┆Issue is synchronized with this ClickUp task by Unito

garciparedes avatar Jan 26 '22 10:01 garciparedes

Comment by garciparedes Friday Oct 08, 2021 at 07:48 GMT


Here is an explanation about how the tuple type hints must work: https://docs.python.org/3/library/typing.html#typing.Tuple

garciparedes avatar Jan 26 '22 10:01 garciparedes

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 27 '22 00:04 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 09 '22 08:08 stale[bot]