Open pquentin opened 1 month ago
Today, string enums are typed using Literal to allow specific values and None if the value is not set, which is OK. However, we also use str as an option, which allows any value and defeats the purpose of having types in the first place.
Literal
None
str
For example, see wait_for in https://elasticsearch-py.readthedocs.io/en/v8.13.1/api/ml.html#elasticsearch.client.MlClient.start_trained_model_deployment. The type is Literal['fully_allocated', 'started', 'starting'] | str | None which prevents any useful type checking. We should remove the str type.
wait_for
Literal['fully_allocated', 'started', 'starting'] | str | None
Note that this is different from https://github.com/elastic/elasticsearch-py/issues/1691 which is about using Python classes for enums.
Today, string enums are typed using
Literal
to allow specific values andNone
if the value is not set, which is OK. However, we also usestr
as an option, which allows any value and defeats the purpose of having types in the first place.For example, see
wait_for
in https://elasticsearch-py.readthedocs.io/en/v8.13.1/api/ml.html#elasticsearch.client.MlClient.start_trained_model_deployment. The type isLiteral['fully_allocated', 'started', 'starting'] | str | None
which prevents any useful type checking. We should remove thestr
type.Note that this is different from https://github.com/elastic/elasticsearch-py/issues/1691 which is about using Python classes for enums.