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

Add support for Click 7.1.1 #60

Merged
merged 5 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ $ python main.py
Usage: main.py [OPTIONS] NAME
Try "main.py --help" for help.

Error: Missing argument "NAME".
Error: Missing argument 'NAME'.

// You get a --help for free
$ python main.py --help
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ $ python main.py
Usage: main.py [OPTIONS] NAME
Try "main.py --help" for help.

Error: Missing argument "NAME".
Error: Missing argument 'NAME'.

// You get a --help for free
$ python main.py --help
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ $ python main.py
Usage: main.py [OPTIONS] NAME
Try "main.py --help" for help.

Error: Missing argument "NAME".
Error: Missing argument 'NAME'.
```

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/commands/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ $ python main.py
Usage: main.py [OPTIONS] NAME
Try "main.py --help" for help.

Error: Missing argument "NAME".
Error: Missing argument 'NAME'.

// With the NAME CLI argument
$ python main.py Camila
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/commands/one-or-multiple.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ python main.py
Usage: main.py [OPTIONS] NAME
Try "main.py --help" for help.

Error: Missing argument "NAME".
Error: Missing argument 'NAME'.

// With the NAME CLI argument
$ python main.py Camila
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/first-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ $ python main.py
Usage: main.py [OPTIONS] NAME
Try "main.py --help" for help.

Error: Missing argument "NAME".
Error: Missing argument 'NAME'.

// Now pass that NAME CLI argument
$ python main.py Camila
Expand Down Expand Up @@ -128,7 +128,7 @@ $ python main.py Camila
Usage: main.py [OPTIONS] NAME LASTNAME
Try "main.py --help" for help.

Error: Missing argument "LASTNAME".
Error: Missing argument 'LASTNAME'.

// These 2 arguments are required, so, pass both:
$ python main.py Camila Gutiérrez
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/options/required.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ python main.py Camila
Usage: main.py [OPTIONS] NAME
Try "main.py --help" for help.

Error: Missing option "--lastname".
Error: Missing option '--lastname'.

// Now update it to pass the required --lastname CLI option
$ python main.py Camila --lastname Gutiérrez
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/parameter-types/datetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ python main.py july-19-1989

Usage: main.py [OPTIONS] [%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d%H:%M:%S]

Error: Invalid value for "[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]": invalid datetime format: july-19-1989. (choose from %Y-%m-%d, %Y-%m-%dT%H:%M:%S, %Y-%m-%d %H:%M:%S)
Error: Invalid value for '[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]': invalid datetime format: july-19-1989. (choose from %Y-%m-%d, %Y-%m-%dT%H:%M:%S, %Y-%m-%d %H:%M:%S)
```

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/parameter-types/enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $ python main.py --network capsule
Usage: main.py [OPTIONS]
Try "main.py --help" for help.

Error: Invalid value for "--network": invalid choice: capsule. (choose from simple, conv, lstm)
Error: Invalid value for '--network': invalid choice: capsule. (choose from simple, conv, lstm)
```

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/parameter-types/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $ python main.py Camila --age 15.3
Usage: main.py [OPTIONS] NAME
Try "main.py --help" for help.

Error: Invalid value for "--age": 15.3 is not a valid integer
Error: Invalid value for '--age': 15.3 is not a valid integer

// Because 15.3 is not an INTEGER (it's a float)
```
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/parameter-types/number.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ $ python main.py 1002
Usage: main.py [OPTIONS] ID
Try "main.py --help" for help.

Error: Invalid value for "ID": 1002 is not in the valid range of 0 to 1000.
Error: Invalid value for 'ID': 1002 is not in the valid range of 0 to 1000.

// Pass an invalid age
$ python main.py 5 --age 15

Usage: main.py [OPTIONS] ID
Try "main.py --help" for help.

Error: Invalid value for "--age": 15 is smaller than the minimum valid value 18.
Error: Invalid value for '--age': 15 is smaller than the minimum valid value 18.

// Pass an invalid score
$ python main.py 5 --age 20 --score 100.5

Usage: main.py [OPTIONS] ID
Try "main.py --help" for help.

Error: Invalid value for "--score": 100.5 is bigger than the maximum valid value 100.
Error: Invalid value for '--score': 100.5 is bigger than the maximum valid value 100.

// But as we didn't specify a minimum score, this is accepted
$ python main.py 5 --age 20 --score -5
Expand Down Expand Up @@ -87,7 +87,7 @@ $ python main.py 1002
Usage: main.py [OPTIONS] ID
Try "main.py --help" for help.

Error: Invalid value for "ID": 1002 is not in the valid range of 0 to 1000.
Error: Invalid value for 'ID': 1002 is not in the valid range of 0 to 1000.

// But --rank and --score use clamp
$ python main.py 5 --rank 11 --score -5
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/parameter-types/path.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $ python main.py --config config.txt
Usage: main.py [OPTIONS]
Try "main.py --help" for help.

Error: Invalid value for "--config": File "config.txt" does not exist.
Error: Invalid value for '--config': File 'config.txt' does not exist.

// Now create a quick config
$ echo "some settings" > config.txt
Expand All @@ -89,7 +89,7 @@ $ python main.py --config ./
Usage: main.py [OPTIONS]
Try "main.py --help" for help.

Error: Invalid value for "--config": File "./" is a directory.
Error: Invalid value for '--config': File './' is a directory.
```

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/parameter-types/uuid.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $ python main.py 7479706572-72756c6573
Usage: main.py [OPTIONS] USER_ID
Try "main.py --help" for help.

Error: Invalid value for "USER_ID": 7479706572-72756c6573 is not a valid UUID value
Error: Invalid value for 'USER_ID': 7479706572-72756c6573 is not a valid UUID value
```

</div>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [
"License :: OSI Approved :: MIT License"
]
requires = [
"click >= 7.0.0, <8.0.0"
"click >= 7.1.1, <7.2.0"
]
description-file = "README.md"
requires-python = ">=3.6"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tutorial/test_arguments/test_tutorial001.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def test_call_no_arg():
result = runner.invoke(app)
assert result.exit_code != 0
assert 'Error: Missing argument "NAME".' in result.output
assert "Error: Missing argument 'NAME'." in result.output


def test_call_arg():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def test_no_arg():
result = runner.invoke(app)
assert result.exit_code != 0
assert 'Error: Missing argument "NAME".' in result.output
assert "Error: Missing argument 'NAME'." in result.output


def test_arg():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tutorial/test_first_steps/test_tutorial002.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def test_1():
result = runner.invoke(app, [])
assert result.exit_code != 0
assert 'Error: Missing argument "NAME"' in result.output
assert "Error: Missing argument 'NAME'" in result.output


def test_2():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tutorial/test_first_steps/test_tutorial003.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def test_1():
result = runner.invoke(app, ["Camila"])
assert result.exit_code != 0
assert 'Error: Missing argument "LASTNAME"' in result.output
assert "Error: Missing argument 'LASTNAME'" in result.output


def test_2():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def test_1():
result = runner.invoke(app, ["Camila"])
assert result.exit_code != 0
assert 'Error: Missing option "--lastname".' in result.output
assert "Error: Missing option '--lastname'." in result.output


def test_option_lastname():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_invalid():
result = runner.invoke(app, ["july-19-1989"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]": invalid datetime format: july-19-1989. (choose from %Y-%m-%d, %Y-%m-%dT%H:%M:%S, %Y-%m-%d %H:%M:%S)'
"Error: Invalid value for '[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]': invalid datetime format: july-19-1989. (choose from %Y-%m-%d, %Y-%m-%dT%H:%M:%S, %Y-%m-%d %H:%M:%S)"
in result.output
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_invalid():
result = runner.invoke(app, ["--network", "capsule"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "--network": invalid choice: capsule. (choose from simple, conv, lstm)'
"Error: Invalid value for '--network': invalid choice: capsule. (choose from simple, conv, lstm)"
in result.output
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_invalid():
result = runner.invoke(app, ["Camila", "--age", "15.3"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "--age": 15.3 is not a valid integer' in result.output
"Error: Invalid value for '--age': 15.3 is not a valid integer" in result.output
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_invalid_id():
result = runner.invoke(app, ["1002"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "ID": 1002 is not in the valid range of 0 to 1000.'
"Error: Invalid value for 'ID': 1002 is not in the valid range of 0 to 1000."
in result.output
)

Expand All @@ -39,7 +39,7 @@ def test_invalid_age():
result = runner.invoke(app, ["5", "--age", "15"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "--age": 15 is smaller than the minimum valid value 18.'
"Error: Invalid value for '--age': 15 is smaller than the minimum valid value 18."
in result.output
)

Expand All @@ -48,7 +48,7 @@ def test_invalid_score():
result = runner.invoke(app, ["5", "--age", "20", "--score", "100.5"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "--score": 100.5 is bigger than the maximum valid value 100.'
"Error: Invalid value for '--score': 100.5 is bigger than the maximum valid value 100."
in result.output
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_invalid_id():
result = runner.invoke(app, ["1002"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "ID": 1002 is not in the valid range of 0 to 1000.'
"Error: Invalid value for 'ID': 1002 is not in the valid range of 0 to 1000."
in result.output
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_not_exists(tmpdir):
config_file.unlink()
result = runner.invoke(app, ["--config", f"{config_file}"])
assert result.exit_code != 0
assert 'Error: Invalid value for "--config": File' in result.output
assert "Error: Invalid value for '--config': File" in result.output
assert "does not exist" in result.output


Expand All @@ -35,7 +35,7 @@ def test_dir():
result = runner.invoke(app, ["--config", "./"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "--config": File "./" is a directory.'
"Error: Invalid value for '--config': File './' is a directory."
in result.output
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_invalid_uuid():
result = runner.invoke(app, ["7479706572-72756c6573"])
assert result.exit_code != 0
assert (
'Error: Invalid value for "USER_ID": 7479706572-72756c6573 is not a valid UUID value'
"Error: Invalid value for 'USER_ID': 7479706572-72756c6573 is not a valid UUID value"
in result.output
)

Expand Down
3 changes: 3 additions & 0 deletions typer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def command(
short_help: Optional[str] = None,
options_metavar: str = "[OPTIONS]",
add_help_option: bool = True,
no_args_is_help: bool = False,
hidden: bool = False,
deprecated: bool = False,
) -> Callable[[CommandFunctionType], CommandFunctionType]:
Expand All @@ -159,6 +160,7 @@ def decorator(f: CommandFunctionType) -> CommandFunctionType:
short_help=short_help,
options_metavar=options_metavar,
add_help_option=add_help_option,
no_args_is_help=no_args_is_help,
hidden=hidden,
deprecated=deprecated,
)
Expand Down Expand Up @@ -437,6 +439,7 @@ def get_command_from_info(command_info: CommandInfo) -> click.Command:
short_help=command_info.short_help,
options_metavar=command_info.options_metavar,
add_help_option=command_info.add_help_option,
no_args_is_help=command_info.no_args_is_help,
hidden=command_info.hidden,
deprecated=command_info.deprecated,
)
Expand Down
2 changes: 2 additions & 0 deletions typer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(
short_help: Optional[str] = None,
options_metavar: str = "[OPTIONS]",
add_help_option: bool = True,
no_args_is_help: bool = False,
hidden: bool = False,
deprecated: bool = False,
):
Expand All @@ -100,6 +101,7 @@ def __init__(
self.short_help = short_help
self.options_metavar = options_metavar
self.add_help_option = add_help_option
self.no_args_is_help = no_args_is_help
self.hidden = hidden
self.deprecated = deprecated

Expand Down
2 changes: 0 additions & 2 deletions typer/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def invoke( # type: ignore
env: Optional[Mapping[str, str]] = None,
catch_exceptions: bool = True,
color: bool = False,
mix_stderr: bool = False,
**extra: Any,
) -> Result:
use_cli = _get_command(app)
Expand All @@ -24,6 +23,5 @@ def invoke( # type: ignore
env=env,
catch_exceptions=catch_exceptions,
color=color,
mix_stderr=mix_stderr,
**extra,
)