Post

Use the type `Literal` in your Python function signatures for arguments that represent options. This is better than using the general type that the configurations fall into. Stricter is better since it'll catch more bugs, earlier. It also helps document the valid values.

If your options are just some strings, you can, and probably should, use StrEnum from the module enum. For integers, an IntEnum can do. For other types or a union of types, you’ll want to use Literal. Aaaand,

0 reposts0 likes