-
-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into master_mateusoliveira
- Loading branch information
Showing
12 changed files
with
139 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ dist | |
.mypy_cache | ||
.idea | ||
site | ||
.coverage | ||
htmlcov | ||
.pytest_cache | ||
coverage.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import click | ||
import typer | ||
|
||
app = typer.Typer() | ||
|
||
|
||
def shell_complete(ctx: click.Context, param: click.Parameter, incomplete: str): | ||
typer.echo(f"ctx: {ctx.info_name}", err=True) | ||
typer.echo(f"arg is: {param.name}", err=True) | ||
typer.echo(f"incomplete is: {incomplete}", err=True) | ||
return ["Emma"] | ||
|
||
|
||
@app.command(context_settings={"auto_envvar_prefix": "TEST"}) | ||
def main(name: str = typer.Argument(shell_complete=shell_complete)): | ||
""" | ||
Say hello. | ||
""" | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from __future__ import annotations | ||
|
||
import typer | ||
from typer.testing import CliRunner | ||
from typing_extensions import Annotated | ||
|
||
runner = CliRunner() | ||
|
||
|
||
def test_annotated(): | ||
app = typer.Typer() | ||
|
||
@app.command() | ||
def cmd(force: Annotated[bool, typer.Option("--force")] = False): | ||
if force: | ||
print("Forcing operation") | ||
else: | ||
print("Not forcing") | ||
|
||
result = runner.invoke(app) | ||
assert result.exit_code == 0, result.output | ||
assert "Not forcing" in result.output | ||
|
||
result = runner.invoke(app, ["--force"]) | ||
assert result.exit_code == 0, result.output | ||
assert "Forcing operation" in result.output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters