Skip to content
Myr

Merge commit '752ff79d680fceb26d2a93f1eef376d90823ec47' into feature/790

Before adoption: this commit came in with the history the project adopted, so no landing records it.

# Conflicts: # CHANGES

authored by Nicholas Wiles · committed by Nicholas Wiles · parents 65da5cc, 752ff79 · Browse files · 7 files+37 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+37 added−11 removed

  • tests:+22 added−0 removed
  • other:+15 added−11 removed

7 files+37 added−11 removed

modified:click/_unicodefun.py+1 added-1 removed
114 unmodified lines
115 ) % bad_locale116117 raise RuntimeError('Click will abort further execution because Python 3 '118 'was configured to use ASCII as encoding for the '119 'environment. Consult http://click.pocoo.org/python3/'119 'environment. Consult http://click.pocoo.org/python3/ '120 'for mitigation steps.' + extra)
modified:click/globals.py+1 added-1 removed
7 unmodified lines
8 """Returns the current click context. This can be used as a way to9 access the current context object from anywhere. This is a more implicit10 alternative to the :func:`pass_context` decorator. This function is11 primarily useful for helpers such as :func:`echo` which might be12 interested in changing it's behavior based on the current context.12 interested in changing its behavior based on the current context.1314 To push the current context, :meth:`Context.scope` can be used.1516 .. versionadded:: 5.0
32 unmodified lines
modified:click/types.py+7 added-7 removed
272 unmodified lines
273 def convert(self, value, param, ctx):274 if isinstance(value, bool):275 return bool(value)276 value = value.lower()277 if value in ('true', '1', 'yes', 'y'):277 if value in ('true', 't,' '1', 'yes', 'y'):278 return True279 elif value in ('false', '0', 'no', 'n'):279 elif value in ('false', 'f', '0', 'no', 'n'):280 return False281 self.fail('%s is not a valid boolean' % value, param, ctx)282283 def __repr__(self):
117 unmodified lines
401 will not expand a tilde-prefix, as this is402 supposed to be done by the shell only.403 :param allow_dash: If this is set to `True`, a single dash to indicate404 standard streams is permitted.405 :param type: optionally a string type that should be used to406 represent the path. The default is `None` which407 means the return value will be either bytes or408 unicode depending on what makes most sense given the409 input data Click deals with.405 :param path_type: optionally a string type that should be used to406 represent the path. The default is `None` which407 means the return value will be either bytes or408 unicode depending on what makes most sense given the409 input data Click deals with.410 """411 envvar_list_splitter = os.path.pathsep412413 def __init__(self, exists=False, file_okay=True, dir_okay=True,
178 unmodified lines
modified:docs/parameters.rst+2 added-2 removed
45 unmodified lines
46 A parameter that only accepts floating point values.4748``bool`` / :data:`click.BOOL`:49 A parameter that accepts boolean values. This is automatically used50 for boolean flags. If used with string values ``1``, ``yes``, ``y``51 and ``true`` convert to `True` and ``0``, ``no``, ``n`` and ``false``50 for boolean flags. If used with string values ``1``, ``yes``, ``y``, ``t``51 and ``true`` convert to `True` and ``0``, ``no``, ``n``, ``f`` and ``false``52 convert to `False`.5354:data:`click.UUID`:55 A parameter that accepts UUID values. This is not automatically
68 unmodified lines
modified:tests/test_basic.py+22 added
178 unmodified lines
179 assert not result.exception180 assert result.output == '%s\n' % (default)181182183def test_boolean_conversion(runner):184 for default in True, False:185 @click.command()186 @click.option('--flag', default=default, type=bool)187 def cli(flag):188 click.echo(flag)189190 for value in 'true', 't,' '1', 'yes', 'y':191 result = runner.invoke(cli, ['--flag', value])192 assert not result.exception193 assert result.output == 'True\n'194195 for value in 'false', 'f', '0', 'no', 'n':196 result = runner.invoke(cli, ['--flag', value])197 assert not result.exception198 assert result.output == 'False\n'199200 result = runner.invoke(cli, [])201 assert not result.exception202 assert result.output == '%s\n' % default203204205def test_file_option(runner):206 @click.command()207 @click.option('--file', type=click.File('w'))208 def input(file):
290 unmodified lines
modified:CHANGES+1 added
23 unmodified lines
24- `CliRunner.invoke` now may receive `args` as a string representing25 a Unix shell command. See #664.26- Fix bug that caused bashcompletion to give inproper completions on 27 chained commands. See #774.28- 't' and 'f' are now converted to True and False. 29- Fix bug that caused bashcompletion to give inproper completions on30 chained commands when a required option/argument was being completed.31 See #790.32
357 unmodified lines
modified:setup.cfg+3 added
1 unmodified line
2universal=134[metadata]5license_file = LICENSE67[tool:pytest]8addopts = -p no:warnings