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

Add support for simple Literal fields #152

Merged
merged 1 commit into from
Aug 3, 2022
Merged

Add support for simple Literal fields #152

merged 1 commit into from
Aug 3, 2022

Conversation

lebrice
Copy link
Owner

@lebrice lebrice commented Aug 3, 2022

This adds support for simple fields, like:

from typing import Literal
from dataclasses import dataclass

@dataclass
class Config:
    model: Literal["resnet18", "resnet50"] = "resnet18"

Also adds support for:

  • Literal[ints]
  • Literal[strings]
  • Literal[enums]
  • Literal[bools]

Doesn't yet add support for:

  • Optional[Literal[X]]
  • List[Literal[X]]
  • Tuple[Literal[X], ...]

Signed-off-by: Fabrice Normandin fabrice.normandin@gmail.com

This adds support for simple fields, like:

```python
from typing import Literal
from dataclasses import dataclass

@DataClass
class Config:
    model: Literal["resnet18", "resnet50"] = "resnet18
```

Also adds support for:
- Literal[ints]
- Literal[enums]

Doesn't yet add support for:
- Optional[Literal[X]]
- List[Literal[X]]
- Tuple[Literal[X], ...]

Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
@lebrice lebrice merged commit 94c3171 into master Aug 3, 2022
@lebrice lebrice deleted the simple-literals branch August 3, 2022 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant