Type Checking¶
Many type checkers will raise warnings or errors for functions with the @prompt
decorator due to the function having no body or return value. There are several ways to deal with these.
- Disable the check globally for the type checker. For example in mypy by disabling error code
empty-body
.# pyproject.toml [tool.mypy] disable_error_code = ["empty-body"]
- Make the function body
...
(this does not satisfy mypy) orraise
.@prompt("Choose a color") def random_color() -> str: ...
- Use comment
# type: ignore[empty-body]
on each function. In this case you can add a docstring instead of...
.@prompt("Choose a color") def random_color() -> str: # type: ignore[empty-body] """Returns a random color."""