posit-dev / posit-dev/py-shiny
`DownloadHandler` should allow returning `Path` objects
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
- 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 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