tiangolo / typer

Typer, build great CLIs. Easy to code. Based on Python type hints.

Home Page:https://typer.tiangolo.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for bytes in Options and Arguments

AlexanderPodorov opened this issue · comments

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

import typer


def main(name: bytes):
    typer.echo(name)


if  __name__ == '__main__':
    typer.run(main)

Description

It would be nice if we could add support for bytes in order to use it in contexts where bytes are expected (e.g. base64 encode/decode, password hashing, etc.)

Wanted Solution

Support for bytes type. Currently typer says:
RuntimeError: Type not yet supported: <class 'bytes'>

Wanted Code

import typer


def main(name: bytes):
    typer.echo(name)


if  __name__ == '__main__':
    typer.run(main)

Alternatives

Always use encode/decode methods.

Operating System

macOS

Operating System Details

No response

Typer Version

0.7.0

Python Version

3.11.1

Additional Context

No response

Hi,

is there any news on this issue?