posit-dev / posit-dev/py-shiny

`reactive.Effect` should warn if function returns a value

Open
#425 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

For example, if a user writes this:

@reactive.Effect
def foo():
  return 123

It will run and the user will not receive any indication that the code is probably not doing what they expect. (It will be flagged by a static type checker like pyright, but many users don't use them.)

This should raise an informative warning. (And come to think of it, we should do that in R as well. But now that I think about it again, we can't tell in R if a function just returned a value because it happened to be the last expression when running the function, or if the function was really intended to return the value, so we can't add this check in R.)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Python reactive.Effect entry point and trace how decorated functions are run. Determine where a returned value can be detected and how warnings are emitted. Done means an Effect function returning a value produces an informative warning, while functions without a return value continue to run normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.