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.

You can have multiple values inside Literal, like Literal["celsius", "fahrenheit"]. You don’t need to split them like I did, above. Thanks for folks in the comments!

0 reposts3 likes