Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow for App server= to take input only #920

Merged
merged 8 commits into from
Dec 19, 2023
Merged

feat: Allow for App server= to take input only #920

merged 8 commits into from
Dec 19, 2023

Conversation

schloerke
Copy link
Collaborator

Related: #793

@schloerke schloerke requested a review from wch December 18, 2023 22:06
@schloerke schloerke added this to the v0.7.0 milestone Dec 18, 2023
@schloerke schloerke modified the milestones: v0.6.1, v0.7.0 Dec 19, 2023
shiny/_app.py Outdated
Comment on lines 471 to 474
def has_only_input(
x: Callable[[Inputs], None] | Callable[[Inputs, Outputs, Session], None]
) -> TypeGuard[Callable[[Inputs], None]]:
return len(signature(x).parameters) == 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that the TypeGuard does provide some help for the type checker here, but still, I think it's clearer if the len(...) == 1 check is inlined in the elif statements above, and then a cast is used inside the elif blocks. As it is, I find myself jumping up and down in the code to understand what it's doing.

It would be nice if Python type checking were smarter and didn't require either of these workarounds.

shiny/_app.py Outdated
pass


def ignore_output_session_server(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def ignore_output_session_server(
def wrap_server_fn_with_output_session(

shiny/_app.py Outdated
@@ -446,3 +452,29 @@ def file_response_handler(req: Request) -> FileResponse:
file_response_handler,
name="shiny-app-static-assets-" + mount_point,
)


def noop_server(input: Inputs, output: Outputs, session: Session) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity:

Suggested change
def noop_server(input: Inputs, output: Outputs, session: Session) -> None:
def noop_server_fn(input: Inputs, output: Outputs, session: Session) -> None:

@wch wch merged commit 42fc70f into main Dec 19, 2023
26 checks passed
@wch wch deleted the server_input_only branch December 19, 2023 22:18
gadenbuie added a commit that referenced this pull request Jan 5, 2024
schloerke added a commit that referenced this pull request Jan 8, 2024
* main: (24 commits)
  Use dynamic version of py-shiny for deploy tests (#970)
  Add underscores to hide some imports (#978)
  Add rsconnect json files(shinyapps.io tests) and folium tests (#928)
  Express' `value_box()` no longer includes named positional args (#966)
  Include `tooltip()` and `popover()` in express (#949)
  Remove extra call to run_express()
  Call `tagify()` early to intercept `AttributeErrors` (#941)
  Don't pass sidebar twice to navbar_page
  Update changelog
  Update changelog
  Switch from `requests` to `urllib` (#940)
  Bump version to 0.6.1.1
  Fix docstring for page_opts
  Fix API doc sections for Express
  Smarter, lazier, and more complete page default/api for express (#893)
  Change `express.layout` to `express.ui` (#904)
  Remove `@output` from examples (#790)
  feat: Allow for `App` `server=` to take `input` only (#920)
  Add fixes for type stub generation (#828)
  Move quarto express docs to bottom
  ...
wch pushed a commit that referenced this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants