@param.output should enforce type
- Dominant language
- Python
- Stars
- 521
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 35
Description
Generally, Param enforces declared types where feasible, but currently it does not do so for output types:
```python
import param
class P(param.Parameterized):
a = param.Number(default=5, bounds=(0, 10))
b = param.Number(default=5, bounds=(0, 10))
@param.output(param.String)
def product(self):
return self.a * self.b
p = P(a=2, b=3)
p.product()
>>> 6
```
This code declares that `product()` returns a string, but no error is raised when the method returns a number instead. Outputs are still useful as declaration, but it seems like we can make the decorator not just record the output type, but also validate it, raising an exception in the same way that supplying something of the wrong type to `a` or `b` would.
Contributor guide
Assessment
This issue has not been assessed yet.