posit-dev / posit-dev/py-shiny

`DownloadHandler` should allow returning `Path` objects

Open
#976 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

Currently, DownloadHandlers can accepts strings, but not Path objects, so they have to be used like this:

@render.download()
def download():
    path = Path(__file__).parent / "mtcars.csv"
    return str(path)

It would be more convenient if you could just return a Path object, like this:

@render.download()
def download():
    return Path(__file__).parent / "mtcars.csv"

Also, I believe that currently there's no checking that the returned path is absolute, but we should do that, because the current working dir may not be the same as the app directory

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 DownloadHandler implementation and trace how the value returned by a download function is handled when it is a string. Add support for pathlib.Path values and enforce absolute paths, then add or update coverage for both behaviors and run the relevant test suite.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.