posit-dev / posit-dev/py-shiny
Incorrect `@Calc` type when function's return type is `Any`
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
Using pyright, Calc works fine in cases like this:
@reactive.Calc
def f():
return 1
f # Inferred type is (function) f: Calc_[int]
However, if the function returns Any, then it thinks that the object is a CalcAsync_:
@reactive.Calc
def g() -> Any: ...
g # Inferred type is (function) g: CalcAsync_[Any]
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two decorator examples with pyright and inspect the typing behind reactive.Calc, Calc_[Any], and CalcAsync_. Trace why an Any return is inferred as CalcAsync_ and verify that the corrected result is inferred as Calc_[Any].
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100