Skip to content

✨ Implement list parsing from string with separators - #800

Closed
libklein wants to merge 30 commits into
fastapi:masterfrom
libklein:multiple-arguments-via-separated-lists
Closed

✨ Implement list parsing from string with separators#800
libklein wants to merge 30 commits into
fastapi:masterfrom
libklein:multiple-arguments-via-separated-lists

Conversation

@libklein

@libklein libklein commented Apr 17, 2024

Copy link
Copy Markdown

Implements feature #554.

This merge request introduces the functionality to parse List[T] options from strings using a specified separator. An example of how this can be utilized is demonstrated below:

def main(number: List[float] = typer.Option([], multiple_separator=",")):
    print(f"The sum is {sum(number)}")

#  Passing --number 1,2,3 outputs 6  
#  Works with --number 1,2 --number 3 as well. Output would be 6 again.

The implementation works by overwriting the process_value function of the click parser, doing string splitting before forwarding the result to click. This ensures full compatibility with the existing features of both Click and Typer. The feature does not allow whitespace only separators to avoid ambiguities.

Feedback is much appreciated!

Open questions:

  • Currently, error handling is implemented in the constructor of typer.Option, which delays error detection until the command execution. Should we consider moving this error handling to the OptionInfo constructor to allow for earlier failure detection?
    ToDo:
  • Add to doc_src
  • Write tests
  • Update documentation

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@svlandeg

Copy link
Copy Markdown
Member

Hi, thanks for your PR! I'll put this in draft as long as the test suite is failing.

@svlandeg
svlandeg marked this pull request as draft April 18, 2024 08:02
@svlandeg svlandeg added feature New feature, enhancement or request p3 labels Apr 18, 2024
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@libklein
libklein marked this pull request as ready for review April 18, 2024 20:11
Comment thread typer/core.py Outdated
@github-actions

This comment was marked as outdated.

@ivantodorovich ivantodorovich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks 💚

Comment thread docs/tutorial/multiple-values/multiple-options.md Outdated
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@svlandeg

Copy link
Copy Markdown
Member

Hi @libklein,

I have updated the PR to adhere to the new documentation format, and it is still awaiting further review by Tiangolo. It has been put on our internal review queue. I'd like everyone to refrain from adding additional pings, as that just creates a longer PR thread and generates a lot of noise in our notifications on our end. Instead, if you'd like this PR to be merged, please add an emoticon on the very first post ☝️, which gives us a good idea on how "popular" the idea/PR is.

I do realise it can be a bit frustrating to have this PR sit here for so long. There's just a lot of working in maintaining several open-source repo's (Typer, FastAPI, SQLModel, ...) and we do our best to keep up. Thanks for your understanding! 🙏

Hi @svlandeg,

more than a year has passed since creating the PR. Are there any updates concerning the roadmap?

@svlandeg svlandeg removed their assignment Aug 28, 2025
@svlandeg
svlandeg marked this pull request as ready for review August 28, 2025 13:43
@github-actions

This comment was marked as outdated.

@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Oct 20, 2025
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Oct 21, 2025
@github-actions

github-actions Bot commented Oct 21, 2025

Copy link
Copy Markdown
Contributor

@svlandeg
svlandeg marked this pull request as draft November 25, 2025 13:13
@svlandeg svlandeg self-assigned this Nov 25, 2025
@svlandeg svlandeg removed their assignment Nov 25, 2025
@svlandeg
svlandeg marked this pull request as ready for review November 25, 2025 13:37
@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Dec 19, 2025
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has a merge conflict that needs to be resolved.

@tiangolo

Copy link
Copy Markdown
Member

Thanks for the interest and work on this! ☕

I want to implement a few big refactors and features that might solve many of these use cases.

I also need to do that before expanding the surface of what is supported with additional external PRs, because that also means I would have to keep maintaining and handling backwards compatibility for those new changes while doing those big refactors.

I have not wanted to close PRs that target the same or similar problems before I have an alternative, but then I have left many PRs open for too long, which is not useful or clear either. Sorry for that.

And then, after I make those big refactors, the problem might be solved... and if not, a bunch of conflicts will show up, so it will be better and easier to start from scratch (from the new code state).

So, I'll close this one for now to keep things clean.

For the specific use case, the best would be to document it in a new GitHub Discussion (or 👍 any existing one) with the specific problem to solve (without details of the implementation) to track the feature request.

Thank you! 🍰

@tiangolo tiangolo closed this May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Automatically generated when a PR has a merge conflict feature New feature, enhancement or request p3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: Documentation of passing multiple values in "option" vs "argument" isn't sufficiently explicit

6 participants