question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Literal type support

See original GitHub issue

Support 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:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
Aran-Feycommented, Apr 22, 2021

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?

2reactions
f4hycommented, May 4, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found