Merge branch '8.1.x' of https://github.com/Rowlando13/click into trim_args_section
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by unknown · committed by unknown · parents ba5b4ce, 6986b08 · Browse files · 5 files·+36 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+36 added−23 removed
- other:+36 added−23 removed
Provenance
- Commit
c2e6f2e- Tree
1f088c0- Author
unknown <edward.g2013@gmail.com>- Committer
unknown <edward.g2013@gmail.com>- Parent 1
ba5b4ce- Parent 2
6986b08
5 files changed+36 added−23 removed
modified:docs/shell-completion.rst+1 added-1 removed
60 unmodified lines61 Add this to ``~/.config/fish/completions/foo-bar.fish``:62 63 .. code-block:: fish64 65- eval (env _FOO_BAR_COMPLETE=fish_source foo-bar)65+ _FOO_BAR_COMPLETE=fish_source foo-bar | source66 67 This is the same file used for the activation script method68 below. For Fish it's probably always easier to use that method.69 218 unmodified linesmodified:src/click/__init__.py+1 added-1 removed
68 unmodified lines69 from .utils import get_binary_stream as get_binary_stream70 from .utils import get_text_stream as get_text_stream71 from .utils import open_file as open_file72 73-__version__ = "8.1.6"73+__version__ = "8.1.7"modified:src/click/_compat.py+1 added-1 removed
514 unmodified lines515 return locale.getpreferredencoding()516 517 _ansi_stream_wrappers: t.MutableMapping[t.TextIO, t.TextIO] = WeakKeyDictionary()518 519- def auto_wrap_for_ansi(519+ def auto_wrap_for_ansi( # noqa: F811520 stream: t.TextIO, color: t.Optional[bool] = None521 ) -> t.TextIO:522 """Support ANSI color and style codes on Windows by wrapping a523 stream with colorama.100 unmodified linesmodified:src/click/shell_completion.py+23 added-20 removed
165 unmodified lines166 fi167 """168 169 _SOURCE_FISH = """\170-function %(complete_func)s170+function %(complete_func)s;171 set -l response (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp) \172-COMP_CWORD=(commandline -t) %(prog_name)s)172+COMP_CWORD=(commandline -t) %(prog_name)s);173 174- for completion in $response175- set -l metadata (string split "," $completion)174+ for completion in $response;175+ set -l metadata (string split "," $completion);176 177- if test $metadata[1] = "dir"178- __fish_complete_directories $metadata[2]179- else if test $metadata[1] = "file"180- __fish_complete_path $metadata[2]181- else if test $metadata[1] = "plain"182- echo $metadata[2]183- end184- end185-end177+ if test $metadata[1] = "dir";178+ __fish_complete_directories $metadata[2];179+ else if test $metadata[1] = "file";180+ __fish_complete_path $metadata[2];181+ else if test $metadata[1] = "plain";182+ echo $metadata[2];183+ end;184+ end;185+end;186 187 complete --no-files --command %(prog_name)s --arguments \188-"(%(complete_func)s)"188+"(%(complete_func)s)";189 """190 191 192 class ShellComplete:36 unmodified lines229 def func_name(self) -> str:230 """The name of the shell function defined by the completion231 script.232 """233- safe_name = re.sub(r"\W*", "", self.prog_name.replace("-", "_"), re.ASCII)233+ safe_name = re.sub(r"\W*", "", self.prog_name.replace("-", "_"), flags=re.ASCII)234 return f"_{safe_name}_completion"235 236 def source_vars(self) -> t.Dict[str, t.Any]:237 """Vars for formatting :attr:`source_template`.62 unmodified lines300 301 name = "bash"302 source_template = _SOURCE_BASH303 304+ @staticmethod304- def _check_version(self) -> None:305+ def _check_version() -> None:306 import subprocess307 308 output = subprocess.run(309 ["bash", "-c", 'echo "${BASH_VERSION}"'], stdout=subprocess.PIPE3 unmodified lines313 if match is not None:314 major, minor = match.groups()315 316 if major < "4" or major == "4" and minor < "4":316- raise RuntimeError(317+ echo(318 _(319 "Shell completion is not supported for Bash"320 " versions older than 4.4."320- )321+ ),322+ err=True,323 )324 else:323- raise RuntimeError(324- _("Couldn't detect Bash version, shell completion is not supported.")325+ echo(326+ _("Couldn't detect Bash version, shell completion is not supported."),327+ err=True,328 )329 330 def source(self) -> str:331 self._check_version()265 unmodified linesmodified:CHANGES.rst+10 added
1 .. currentmodule:: click2 3+Version 8.1.74+-------------5+6+Released 2023-08-177+8+- Fix issue with regex flags in shell completion. :issue:`2581`9+- Bash version detection issues a warning instead of an error. :issue:`2574`10+- Fix issue with completion script for Fish shell. :issue:`2567`11+12+13 Version 8.1.614 -------------15 16 Released 2023-07-181090 unmodified lines