Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] typer.main.get_group should return a click.Group #96

Open
dbanty opened this issue Apr 30, 2020 · 0 comments
Open

[BUG] typer.main.get_group should return a click.Group #96

dbanty opened this issue Apr 30, 2020 · 0 comments

Comments

@dbanty
Copy link

@dbanty dbanty commented Apr 30, 2020

Describe the bug

The function typer.main.get_group is annotated as returning a click.Command which isn't wrong because a click.Group is a click.Command, but means I have to cast to group when trying to integrate with existing Click applications.

To Reproduce

Steps to reproduce the behavior with a minimum self-contained file.

Replace each part with your own scenario:

  • Create a file main.py with:
import typer

app = typer.Typer()


@app.callback()
def callback():
    """ My partially-upgraded-to-Typer app """

# insert some fancy new Typer commands here


click_group = typer.main.get_group(app)


@click_group.command()
def some_old_click_function():
      """ I need to rewrite this somday """

Run mypy on this script with mypy main.py and it will output something like

main.py:16: error: "Command" has no attribute "command"

Expected behavior

Able to drop in Typer at the top level to start slowly converting an existing Click app.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

  • OS: macOS
  • Typer Version: 0.2.1
  • Python version: 3.8.2
  • mypy version: 0.770
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.