Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve typing of string enums #2567

Open
pquentin opened this issue May 24, 2024 · 0 comments
Open

Improve typing of string enums #2567

pquentin opened this issue May 24, 2024 · 0 comments

Comments

@pquentin
Copy link
Member

pquentin commented May 24, 2024

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.

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.

Note that this is different from #1691 which is about using Python classes for enums.

@pquentin pquentin changed the title Improve typing of enums Improve typing of string enums May 24, 2024
@pquentin pquentin self-assigned this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants