[FEATURE] Literal type support
See original GitHub issueSupport for the literal type (python 3.8 or via typing_extensions) would be nice. Eg.
def get_list(output: Literal["raw", "json", "yaml"] = "raw"):
if output == "json":
typer.echo(json.dumps([1, 2, 3]))
The only workarounds (using string or multiple bool flags + validating input) are ugly now.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Unsupported literal type class in Apache Spark in scala
How to convert a dataframe to dataset in Apache Spark in Scala? 1 · Error of "Not supported within a window function" occurs...
Read more >Handbook - Literal Types - TypeScript
In practice string literal types combine nicely with union types, type guards, and type aliases. You can use these features together to get...
Read more >Literal types and Enums - mypy 0.991 documentation
Literal types let you indicate that an expression is equal to some specific ... Mypy also tries to support special features of Enum...
Read more >C++ named requirements: LiteralType (since C++11)
Specifies that a type is a literal type. Literal types are the types of constexpr variables and they can be constructed, manipulated, ...
Read more >Literals - Spark 3.3.1 Documentation
Spark SQL supports the following literals: ... There are two kinds of numeric literals: integral literal and fractional literal.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I don’t get why this is closed. Does this mean you won’t be adding support for
typing.Literal? Or did the bot mess up?While things could be rewritten as an enum, it does not play nice with existing typed code which uses typing.Literal to define a set of allowed values. I hope we can revisit this.