argcomplete 3.3.0__tar.gz → 3.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. {argcomplete-3.3.0 → argcomplete-3.5.0}/.github/workflows/ci.yml +2 -1
  2. {argcomplete-3.3.0 → argcomplete-3.5.0}/Changes.rst +27 -0
  3. {argcomplete-3.3.0 → argcomplete-3.5.0}/Makefile +3 -3
  4. {argcomplete-3.3.0/argcomplete.egg-info → argcomplete-3.5.0}/PKG-INFO +1 -1
  5. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/bash_completion.d/_python-argcomplete +4 -2
  6. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/completers.py +1 -1
  7. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/finders.py +7 -5
  8. argcomplete-3.3.0/scripts/activate-global-python-argcomplete → argcomplete-3.5.0/argcomplete/scripts/activate_global_python_argcomplete.py +47 -33
  9. argcomplete-3.5.0/argcomplete/scripts/python_argcomplete_check_easy_install_script.py +84 -0
  10. argcomplete-3.5.0/argcomplete/scripts/register_python_argcomplete.py +79 -0
  11. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/shell_integration.py +2 -2
  12. {argcomplete-3.3.0 → argcomplete-3.5.0/argcomplete.egg-info}/PKG-INFO +1 -1
  13. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete.egg-info/SOURCES.txt +6 -3
  14. argcomplete-3.5.0/argcomplete.egg-info/entry_points.txt +4 -0
  15. {argcomplete-3.3.0 → argcomplete-3.5.0}/pyproject.toml +7 -0
  16. {argcomplete-3.3.0 → argcomplete-3.5.0}/setup.py +0 -1
  17. argcomplete-3.5.0/test/stuck +6 -0
  18. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test.py +7 -2
  19. argcomplete-3.5.0/test/test_package/__init__.py +0 -0
  20. argcomplete-3.3.0/scripts/python-argcomplete-check-easy-install-script +0 -63
  21. argcomplete-3.3.0/scripts/register-python-argcomplete +0 -71
  22. {argcomplete-3.3.0 → argcomplete-3.5.0}/.github/FUNDING.yml +0 -0
  23. {argcomplete-3.3.0 → argcomplete-3.5.0}/.gitignore +0 -0
  24. {argcomplete-3.3.0 → argcomplete-3.5.0}/Authors.rst +0 -0
  25. {argcomplete-3.3.0 → argcomplete-3.5.0}/LICENSE.rst +0 -0
  26. {argcomplete-3.3.0 → argcomplete-3.5.0}/MANIFEST.in +0 -0
  27. {argcomplete-3.3.0 → argcomplete-3.5.0}/NOTICE +0 -0
  28. {argcomplete-3.3.0 → argcomplete-3.5.0}/README.rst +0 -0
  29. {argcomplete-3.3.0 → argcomplete-3.5.0}/SECURITY.md +0 -0
  30. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/__init__.py +0 -0
  31. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/_check_console_script.py +0 -0
  32. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/_check_module.py +0 -0
  33. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/exceptions.py +0 -0
  34. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/io.py +0 -0
  35. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/lexers.py +0 -0
  36. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/packages/__init__.py +0 -0
  37. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/packages/_argparse.py +0 -0
  38. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/packages/_shlex.py +0 -0
  39. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete/py.typed +0 -0
  40. {argcomplete-3.3.0/test → argcomplete-3.5.0/argcomplete/scripts}/__init__.py +0 -0
  41. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete.egg-info/dependency_links.txt +0 -0
  42. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete.egg-info/not-zip-safe +0 -0
  43. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete.egg-info/requires.txt +0 -0
  44. {argcomplete-3.3.0 → argcomplete-3.5.0}/argcomplete.egg-info/top_level.txt +0 -0
  45. {argcomplete-3.3.0 → argcomplete-3.5.0}/common.mk +0 -0
  46. {argcomplete-3.3.0 → argcomplete-3.5.0}/contrib/README.rst +0 -0
  47. {argcomplete-3.3.0 → argcomplete-3.5.0}/docs/changelog.rst +0 -0
  48. {argcomplete-3.3.0 → argcomplete-3.5.0}/docs/conf.py +0 -0
  49. {argcomplete-3.3.0 → argcomplete-3.5.0}/docs/examples/describe_github_user.py +0 -0
  50. {argcomplete-3.3.0 → argcomplete-3.5.0}/docs/fish_help_string.png +0 -0
  51. {argcomplete-3.3.0 → argcomplete-3.5.0}/docs/index.rst +0 -0
  52. {argcomplete-3.3.0 → argcomplete-3.5.0}/docs/toc.html +0 -0
  53. {argcomplete-3.3.0 → argcomplete-3.5.0}/setup.cfg +0 -0
  54. {argcomplete-3.3.0/test/test_package → argcomplete-3.5.0/test}/__init__.py +0 -0
  55. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/inputrc +0 -0
  56. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/prog +0 -0
  57. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_contrib_shells.py +0 -0
  58. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/build/lib/test_module.py +0 -0
  59. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/build/lib/test_package/__init__.py +0 -0
  60. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/setup.py +0 -0
  61. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/test_module.py +0 -0
  62. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/test_package/__init__.py +0 -0
  63. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/test_package.egg-info/PKG-INFO +0 -0
  64. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/test_package.egg-info/SOURCES.txt +0 -0
  65. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/test_package.egg-info/dependency_links.txt +0 -0
  66. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/test_package.egg-info/entry_points.txt +0 -0
  67. {argcomplete-3.3.0 → argcomplete-3.5.0}/test/test_package/test_package.egg-info/top_level.txt +0 -0
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- os: [ubuntu-20.04, ubuntu-22.04, macos-11, macos-12]
11
+ os: [ubuntu-20.04, ubuntu-22.04, macos-12, macos-14]
12
12
  python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
13
13
 
14
14
  steps:
@@ -29,6 +29,7 @@ jobs:
29
29
  - run: make lint
30
30
  - run: make test
31
31
  - uses: codecov/codecov-action@v3
32
+ if: ${{matrix.python-version == '3.12' && matrix.os == 'ubuntu-22.04'}}
32
33
  black:
33
34
  runs-on: ubuntu-22.04
34
35
  steps:
@@ -1,3 +1,30 @@
1
+ Changes for v3.5.0 (2024-08-06)
2
+ ===============================
3
+
4
+ - Use project.scripts instead of setuptools scripts (#498)
5
+
6
+ - Test infrastructure improvements
7
+
8
+ Changes for v3.4.0 (2024-06-16)
9
+ ===============================
10
+
11
+ - No stdin for python calls from bash completion functions (#488)
12
+
13
+ Prevents usage of stdin by (python) executables that are called
14
+ during completion generation. This prevents the completion locking up
15
+ the entire shell when the python script is broken i.e. it enters an
16
+ interactive mode (REPL) instead of generating the completions, as
17
+ expected.
18
+
19
+ - Localize shell variable REPLY to avoid overwriting users’ value
20
+ (#489)
21
+
22
+ The variable REPLY is used by default by the ``read`` shell builtin
23
+ to store the return value, and like all bash/zsh variables, is scoped
24
+ globally. This change allows this variable to be used for other needs
25
+ by appropriately scoping its internal use by an argcomplete utility
26
+ function that uses ``read``.
27
+
1
28
  Changes for v3.3.0 (2024-04-14)
2
29
  ===============================
3
30
 
@@ -4,9 +4,9 @@ test_deps:
4
4
  python -m pip install .[test]
5
5
 
6
6
  lint:
7
- for dir in $$(dirname */__init__.py); do ruff $$dir; done
8
- for script in scripts/*[^cmd]; do if grep -q python $$script; then ruff $$script; fi; done
9
- mypy --install-types --non-interactive --check-untyped-defs argcomplete
7
+ for dir in $$(dirname */__init__.py); do ruff check $$dir; done
8
+ for script in scripts/*[^cmd]; do if grep -q python $$script; then ruff check $$script; fi; done
9
+ mypy --install-types --non-interactive argcomplete
10
10
 
11
11
  test:
12
12
  coverage run --source=argcomplete --omit=argcomplete/packages/_shlex.py ./test/test.py -v
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: argcomplete
3
- Version: 3.3.0
3
+ Version: 3.5.0
4
4
  Summary: Bash tab completion for argparse
5
5
  Home-page: https://github.com/kislyuk/argcomplete
6
6
  Author: Andrey Kislyuk
@@ -1,5 +1,6 @@
1
1
  #compdef -default-
2
2
 
3
+ # argcomplete global completion loader for zsh and bash
3
4
  # Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors.
4
5
  # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
5
6
 
@@ -46,9 +47,9 @@ __python_argcomplete_run() {
46
47
 
47
48
  __python_argcomplete_run_inner() {
48
49
  if [[ -z "${_ARC_DEBUG-}" ]]; then
49
- "$@" 8>&1 9>&2 1>/dev/null 2>&1
50
+ "$@" 8>&1 9>&2 1>/dev/null 2>&1 </dev/null
50
51
  else
51
- "$@" 8>&1 9>&2 1>&9 2>&1
52
+ "$@" 8>&1 9>&2 1>&9 2>&1 </dev/null
52
53
  fi
53
54
  }
54
55
 
@@ -76,6 +77,7 @@ __python_argcomplete_scan_head() {
76
77
  local file="$1"
77
78
  local target="$2"
78
79
 
80
+ local REPLY
79
81
  if [[ -n "${ZSH_VERSION-}" ]]; then
80
82
  read -r -k 1024 -u 0 < "$file";
81
83
  else
@@ -22,7 +22,7 @@ class BaseCompleter:
22
22
 
23
23
  def __call__(
24
24
  self, *, prefix: str, action: argparse.Action, parser: argparse.ArgumentParser, parsed_args: argparse.Namespace
25
- ):
25
+ ) -> None:
26
26
  raise NotImplementedError("This method should be implemented by a subclass.")
27
27
 
28
28
 
@@ -7,10 +7,10 @@ import argparse
7
7
  import os
8
8
  import sys
9
9
  from collections.abc import Mapping
10
- from typing import Callable, Dict, List, Optional, Sequence, Union
10
+ from typing import Callable, Dict, List, Optional, Sequence, TextIO, Union
11
11
 
12
12
  from . import io as _io
13
- from .completers import ChoicesCompleter, FilesCompleter, SuppressCompleter
13
+ from .completers import BaseCompleter, ChoicesCompleter, FilesCompleter, SuppressCompleter
14
14
  from .io import debug, mute_stderr
15
15
  from .lexers import split_line
16
16
  from .packages._argparse import IntrospectiveArgumentParser, action_is_greedy, action_is_open, action_is_satisfied
@@ -66,13 +66,13 @@ class CompletionFinder(object):
66
66
  argument_parser: argparse.ArgumentParser,
67
67
  always_complete_options: Union[bool, str] = True,
68
68
  exit_method: Callable = os._exit,
69
- output_stream=None,
69
+ output_stream: Optional[TextIO] = None,
70
70
  exclude: Optional[Sequence[str]] = None,
71
71
  validator: Optional[Callable] = None,
72
72
  print_suppressed: bool = False,
73
73
  append_space: Optional[bool] = None,
74
- default_completer=FilesCompleter(),
75
- ):
74
+ default_completer: BaseCompleter = FilesCompleter(),
75
+ ) -> None:
76
76
  """
77
77
  :param argument_parser: The argument parser to autocomplete on
78
78
  :param always_complete_options:
@@ -132,6 +132,8 @@ class CompletionFinder(object):
132
132
  debug("Unable to open fd 8 for writing, quitting")
133
133
  exit_method(1)
134
134
 
135
+ assert output_stream is not None
136
+
135
137
  ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013")
136
138
  if len(ifs) != 1:
137
139
  debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env python
1
+ #!/usr/bin/env python3
2
2
  # PYTHON_ARGCOMPLETE_OK
3
3
 
4
4
  # Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors.
@@ -17,6 +17,9 @@ import sys
17
17
 
18
18
  import argcomplete
19
19
 
20
+ # PEP 366
21
+ __package__ = "argcomplete.scripts"
22
+
20
23
  zsh_shellcode = """
21
24
  # Begin added by argcomplete
22
25
  fpath=( {zsh_fpath} "${{fpath[@]}}" )
@@ -29,6 +32,13 @@ source "{activator}"
29
32
  # End added by argcomplete
30
33
  """
31
34
 
35
+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
36
+ parser.add_argument("-y", "--yes", help="automatically answer yes for all questions", action="store_true")
37
+ parser.add_argument("--dest", help='Specify the shell completion modules directory to install into, or "-" for stdout')
38
+ parser.add_argument("--user", help="Install into user directory", action="store_true")
39
+ argcomplete.autocomplete(parser)
40
+ args = None
41
+
32
42
 
33
43
  def get_local_dir():
34
44
  try:
@@ -81,6 +91,7 @@ def install_to_destination(dest):
81
91
 
82
92
 
83
93
  def get_consent():
94
+ assert args is not None
84
95
  if args.yes is True:
85
96
  return True
86
97
  while True:
@@ -120,35 +131,38 @@ def link_user_rcfiles():
120
131
  append_to_config_file(bash_completion_user_file, bash_shellcode.format(activator=get_activator_path()))
121
132
 
122
133
 
123
- parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
124
- parser.add_argument("-y", "--yes", help="automatically answer yes for all questions", action="store_true")
125
- parser.add_argument("--dest", help='Specify the shell completion modules directory to install into, or "-" for stdout')
126
- parser.add_argument("--user", help="Install into user directory", action="store_true")
127
- argcomplete.autocomplete(parser)
128
- args = parser.parse_args()
129
- destinations = []
130
-
131
- if args.dest:
132
- if args.dest != "-" and not os.path.exists(args.dest):
133
- parser.error(f"directory {args.dest} was specified via --dest, but it does not exist")
134
- destinations.append(args.dest)
135
- elif site.ENABLE_USER_SITE and site.USER_SITE in argcomplete.__file__:
136
- print(
137
- "Argcomplete was installed in the user site local directory. Defaulting to user installation.", file=sys.stderr
138
- )
139
- link_user_rcfiles()
140
- elif sys.prefix != sys.base_prefix:
141
- print("Argcomplete was installed in a virtual environment. Defaulting to user installation.", file=sys.stderr)
142
- link_user_rcfiles()
143
- elif args.user:
144
- link_user_rcfiles()
145
- else:
146
- print("Defaulting to system-wide installation.", file=sys.stderr)
147
- destinations.append(f"{get_zsh_system_dir()}/_python-argcomplete")
148
- destinations.append(f"{get_bash_system_dir()}/python-argcomplete")
149
-
150
- for destination in destinations:
151
- install_to_destination(destination)
152
-
153
- if args.dest is None:
154
- print("Please restart your shell or source the installed file to activate it.", file=sys.stderr)
134
+ def main():
135
+ global args
136
+ args = parser.parse_args()
137
+
138
+ destinations = []
139
+
140
+ if args.dest:
141
+ if args.dest != "-" and not os.path.exists(args.dest):
142
+ parser.error(f"directory {args.dest} was specified via --dest, but it does not exist")
143
+ destinations.append(args.dest)
144
+ elif site.ENABLE_USER_SITE and site.USER_SITE and site.USER_SITE in argcomplete.__file__:
145
+ print(
146
+ "Argcomplete was installed in the user site local directory. Defaulting to user installation.",
147
+ file=sys.stderr,
148
+ )
149
+ link_user_rcfiles()
150
+ elif sys.prefix != sys.base_prefix:
151
+ print("Argcomplete was installed in a virtual environment. Defaulting to user installation.", file=sys.stderr)
152
+ link_user_rcfiles()
153
+ elif args.user:
154
+ link_user_rcfiles()
155
+ else:
156
+ print("Defaulting to system-wide installation.", file=sys.stderr)
157
+ destinations.append(f"{get_zsh_system_dir()}/_python-argcomplete")
158
+ destinations.append(f"{get_bash_system_dir()}/python-argcomplete")
159
+
160
+ for destination in destinations:
161
+ install_to_destination(destination)
162
+
163
+ if args.dest is None:
164
+ print("Please restart your shell or source the installed file to activate it.", file=sys.stderr)
165
+
166
+
167
+ if __name__ == "__main__":
168
+ sys.exit(main())
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors.
4
+ # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
5
+
6
+ """
7
+ This script is part of the Python argcomplete package (https://github.com/kislyuk/argcomplete).
8
+ It is used to check if an EASY-INSTALL-SCRIPT wrapper redirects to a script that contains the string
9
+ "PYTHON_ARGCOMPLETE_OK". If you have enabled global completion in argcomplete, the completion hook will run it every
10
+ time you press <TAB> in your shell.
11
+
12
+ Usage:
13
+ python-argcomplete-check-easy-install-script <input executable file>
14
+ """
15
+
16
+ import sys
17
+
18
+ # PEP 366
19
+ __package__ = "argcomplete.scripts"
20
+
21
+
22
+ def main():
23
+ if len(sys.argv) != 2:
24
+ sys.exit(__doc__)
25
+
26
+ sys.tracebacklimit = 0
27
+
28
+ with open(sys.argv[1]) as fh:
29
+ line1, head = fh.read(1024).split("\n", 1)[:2]
30
+ if line1.startswith("#") and ("py" in line1 or "Py" in line1):
31
+ import re
32
+
33
+ lines = head.split("\n", 12)
34
+ for line in lines:
35
+ if line.startswith("# EASY-INSTALL-SCRIPT"):
36
+ import pkg_resources
37
+
38
+ re_match = re.match("# EASY-INSTALL-SCRIPT: '(.+)','(.+)'", line)
39
+ assert re_match is not None
40
+ dist, script = re_match.groups()
41
+ if "PYTHON_ARGCOMPLETE_OK" in pkg_resources.get_distribution(dist).get_metadata(
42
+ "scripts/" + script
43
+ ):
44
+ return 0
45
+ elif line.startswith("# EASY-INSTALL-ENTRY-SCRIPT"):
46
+ re_match = re.match("# EASY-INSTALL-ENTRY-SCRIPT: '(.+)','(.+)','(.+)'", line)
47
+ assert re_match is not None
48
+ dist, group, name = re_match.groups()
49
+ import pkgutil
50
+
51
+ import pkg_resources
52
+
53
+ entry_point_info = pkg_resources.get_distribution(dist).get_entry_info(group, name)
54
+ assert entry_point_info is not None
55
+ module_name = entry_point_info.module_name
56
+ with open(pkgutil.get_loader(module_name).get_filename()) as mod_fh: # type: ignore
57
+ if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
58
+ return 0
59
+ elif line.startswith("# EASY-INSTALL-DEV-SCRIPT"):
60
+ for line2 in lines:
61
+ if line2.startswith("__file__"):
62
+ re_match = re.match("__file__ = '(.+)'", line2)
63
+ assert re_match is not None
64
+ filename = re_match.group(1)
65
+ with open(filename) as mod_fh:
66
+ if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
67
+ return 0
68
+ elif line.startswith("# PBR Generated"):
69
+ re_match = re.search("from (.*) import", head)
70
+ assert re_match is not None
71
+ module = re_match.groups()[0]
72
+ import pkgutil
73
+
74
+ import pkg_resources
75
+
76
+ with open(pkgutil.get_loader(module).get_filename()) as mod_fh: # type: ignore
77
+ if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
78
+ return 0
79
+
80
+ return 1
81
+
82
+
83
+ if __name__ == "__main__":
84
+ sys.exit(main())
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env python3
2
+ # PYTHON_ARGCOMPLETE_OK
3
+
4
+ # Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors.
5
+ # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
6
+
7
+ """
8
+ Register a Python executable for use with the argcomplete module.
9
+
10
+ To perform the registration, source the output of this script in your bash shell
11
+ (quote the output to avoid interpolation).
12
+
13
+ Example:
14
+
15
+ $ eval "$(register-python-argcomplete my-favorite-script.py)"
16
+
17
+ For Tcsh
18
+
19
+ $ eval `register-python-argcomplete --shell tcsh my-favorite-script.py`
20
+
21
+ For Fish
22
+
23
+ $ register-python-argcomplete --shell fish my-favourite-script.py > ~/.config/fish/my-favourite-script.py.fish
24
+ """
25
+
26
+ import argparse
27
+ import sys
28
+
29
+ import argcomplete
30
+
31
+ # PEP 366
32
+ __package__ = "argcomplete.scripts"
33
+
34
+
35
+ def main():
36
+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
37
+
38
+ parser.add_argument(
39
+ "--no-defaults",
40
+ dest="use_defaults",
41
+ action="store_false",
42
+ default=True,
43
+ help="when no matches are generated, do not fallback to readline's default completion (affects bash only)",
44
+ )
45
+ parser.add_argument(
46
+ "--complete-arguments",
47
+ nargs=argparse.REMAINDER,
48
+ help="arguments to call complete with; use of this option discards default options (affects bash only)",
49
+ )
50
+ parser.add_argument(
51
+ "-s",
52
+ "--shell",
53
+ choices=("bash", "zsh", "tcsh", "fish", "powershell"),
54
+ default="bash",
55
+ help="output code for the specified shell",
56
+ )
57
+ parser.add_argument(
58
+ "-e", "--external-argcomplete-script", help="external argcomplete script for auto completion of the executable"
59
+ )
60
+
61
+ parser.add_argument("executable", nargs="+", help="executable to completed (when invoked by exactly this name)")
62
+
63
+ argcomplete.autocomplete(parser)
64
+
65
+ if len(sys.argv) == 1:
66
+ parser.print_help()
67
+ sys.exit(1)
68
+
69
+ args = parser.parse_args()
70
+
71
+ sys.stdout.write(
72
+ argcomplete.shellcode(
73
+ args.executable, args.use_defaults, args.shell, args.complete_arguments, args.external_argcomplete_script
74
+ )
75
+ )
76
+
77
+
78
+ if __name__ == "__main__":
79
+ sys.exit(main())
@@ -24,9 +24,9 @@ __python_argcomplete_run() {
24
24
 
25
25
  __python_argcomplete_run_inner() {
26
26
  if [[ -z "${_ARC_DEBUG-}" ]]; then
27
- "$@" 8>&1 9>&2 1>/dev/null 2>&1
27
+ "$@" 8>&1 9>&2 1>/dev/null 2>&1 </dev/null
28
28
  else
29
- "$@" 8>&1 9>&2 1>&9 2>&1
29
+ "$@" 8>&1 9>&2 1>&9 2>&1 </dev/null
30
30
  fi
31
31
  }
32
32
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: argcomplete
3
- Version: 3.3.0
3
+ Version: 3.5.0
4
4
  Summary: Bash tab completion for argparse
5
5
  Home-page: https://github.com/kislyuk/argcomplete
6
6
  Author: Andrey Kislyuk
@@ -26,6 +26,7 @@ argcomplete/shell_integration.py
26
26
  argcomplete.egg-info/PKG-INFO
27
27
  argcomplete.egg-info/SOURCES.txt
28
28
  argcomplete.egg-info/dependency_links.txt
29
+ argcomplete.egg-info/entry_points.txt
29
30
  argcomplete.egg-info/not-zip-safe
30
31
  argcomplete.egg-info/requires.txt
31
32
  argcomplete.egg-info/top_level.txt
@@ -33,6 +34,10 @@ argcomplete/bash_completion.d/_python-argcomplete
33
34
  argcomplete/packages/__init__.py
34
35
  argcomplete/packages/_argparse.py
35
36
  argcomplete/packages/_shlex.py
37
+ argcomplete/scripts/__init__.py
38
+ argcomplete/scripts/activate_global_python_argcomplete.py
39
+ argcomplete/scripts/python_argcomplete_check_easy_install_script.py
40
+ argcomplete/scripts/register_python_argcomplete.py
36
41
  contrib/README.rst
37
42
  docs/changelog.rst
38
43
  docs/conf.py
@@ -40,12 +45,10 @@ docs/fish_help_string.png
40
45
  docs/index.rst
41
46
  docs/toc.html
42
47
  docs/examples/describe_github_user.py
43
- scripts/activate-global-python-argcomplete
44
- scripts/python-argcomplete-check-easy-install-script
45
- scripts/register-python-argcomplete
46
48
  test/__init__.py
47
49
  test/inputrc
48
50
  test/prog
51
+ test/stuck
49
52
  test/test.py
50
53
  test/test_contrib_shells.py
51
54
  test/test_package/__init__.py
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ activate-global-python-argcomplete = argcomplete.scripts.activate_global_python_argcomplete:main
3
+ python-argcomplete-check-easy-install-script = argcomplete.scripts.python_argcomplete_check_easy_install_script:main
4
+ register-python-argcomplete = argcomplete.scripts.register_python_argcomplete:main
@@ -34,6 +34,11 @@ classifiers = [
34
34
  "Topic :: Terminals",
35
35
  ]
36
36
 
37
+ [project.scripts]
38
+ activate-global-python-argcomplete = "argcomplete.scripts.activate_global_python_argcomplete:main"
39
+ python-argcomplete-check-easy-install-script = "argcomplete.scripts.python_argcomplete_check_easy_install_script:main"
40
+ register-python-argcomplete = "argcomplete.scripts.register_python_argcomplete:main"
41
+
37
42
  [project.optional-dependencies]
38
43
  test = ["coverage", "pexpect", "wheel", "ruff", "mypy"]
39
44
 
@@ -66,6 +71,8 @@ quote-style = "preserve"
66
71
  files = [
67
72
  "argcomplete"
68
73
  ]
74
+ check_untyped_defs = true
75
+ disallow_incomplete_defs = true
69
76
 
70
77
  [[tool.mypy.overrides]]
71
78
  module = "importlib.*"
@@ -7,7 +7,6 @@ from setuptools import find_packages, setup
7
7
  setup(
8
8
  url="https://github.com/kislyuk/argcomplete",
9
9
  packages=find_packages(exclude=["test", "test.*"]),
10
- scripts=glob.glob("scripts/*"),
11
10
  package_data={"argcomplete": ["bash_completion.d/_python-argcomplete", "py.typed"]},
12
11
  zip_safe=False,
13
12
  include_package_data=True,
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env python
2
+ # PYTHON_ARGCOMPLETE_OK
3
+ from sys import argv
4
+
5
+ if argv[1:] != ["no-input"]:
6
+ input()
@@ -65,6 +65,7 @@ class ArgcompleteREPLWrapper(REPLWrapper):
65
65
 
66
66
  def _repl_sh(command, args, non_printable_insert):
67
67
  os.environ["PS1"] = "$"
68
+ os.environ["TERM"] = ""
68
69
  child = pexpect.spawn(command, args, echo=False, encoding="utf-8")
69
70
  ps1 = PEXPECT_PROMPT[:5] + non_printable_insert + PEXPECT_PROMPT[5:]
70
71
  ps2 = PEXPECT_CONTINUATION_PROMPT[:5] + non_printable_insert + PEXPECT_CONTINUATION_PROMPT[5:]
@@ -73,13 +74,13 @@ def _repl_sh(command, args, non_printable_insert):
73
74
 
74
75
 
75
76
  def bash_repl(command="bash"):
76
- bashrc = os.path.join(os.path.dirname(pexpect.__file__), "replwrap", "bashrc.sh")
77
+ bashrc = os.path.join(os.path.dirname(pexpect.__file__), "bashrc.sh")
77
78
  sh = _repl_sh(command, ["--rcfile", bashrc], non_printable_insert="\\[\\]")
78
79
  return sh
79
80
 
80
81
 
81
82
  def zsh_repl(command="zsh"):
82
- sh = _repl_sh(command, ["--no-rcs", "-V"], non_printable_insert="%(!..)")
83
+ sh = _repl_sh(command, ["--no-rcs", "--no-globalrcs", "-V"], non_printable_insert="%(!..)")
83
84
  # Require two tabs to print all options (some tests rely on this).
84
85
  sh.run_command("setopt BASH_AUTO_LIST")
85
86
  return sh
@@ -1348,6 +1349,10 @@ class TestBashZshGlobalBase(TestBashZshBase):
1348
1349
  self.sh.run_command("cd " + TEST_DIR)
1349
1350
  self.assertEqual(self.sh.run_command("python3 ./pro\tbasic f\t"), "foo\r\n")
1350
1351
 
1352
+ def test_python_stuck(self):
1353
+ self.sh.run_command("cd " + TEST_DIR)
1354
+ self.sh.run_command("python3 ./stuck no\t-input")
1355
+
1351
1356
  def test_python_not_executable(self):
1352
1357
  """Test completing a script that cannot be run directly."""
1353
1358
  prog = os.path.join(TEST_DIR, "prog")
File without changes
@@ -1,63 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- # Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors.
4
- # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
5
-
6
- """
7
- This script is part of the Python argcomplete package (https://github.com/kislyuk/argcomplete).
8
- It is used to check if an EASY-INSTALL-SCRIPT wrapper redirects to a script that contains the string
9
- "PYTHON_ARGCOMPLETE_OK". If you have enabled global completion in argcomplete, the completion hook will run it every
10
- time you press <TAB> in your shell.
11
-
12
- Usage:
13
- python-argcomplete-check-easy-install-script <input executable file>
14
- """
15
-
16
- import sys
17
-
18
- if len(sys.argv) != 2:
19
- sys.exit(__doc__)
20
-
21
- sys.tracebacklimit = 0
22
-
23
- with open(sys.argv[1]) as fh:
24
- line1, head = fh.read(1024).split("\n", 1)[:2]
25
- if line1.startswith("#") and ("py" in line1 or "Py" in line1):
26
- import re
27
-
28
- lines = head.split("\n", 12)
29
- for line in lines:
30
- if line.startswith("# EASY-INSTALL-SCRIPT"):
31
- import pkg_resources
32
-
33
- dist, script = re.match("# EASY-INSTALL-SCRIPT: '(.+)','(.+)'", line).groups()
34
- if "PYTHON_ARGCOMPLETE_OK" in pkg_resources.get_distribution(dist).get_metadata("scripts/" + script):
35
- exit(0)
36
- elif line.startswith("# EASY-INSTALL-ENTRY-SCRIPT"):
37
- dist, group, name = re.match("# EASY-INSTALL-ENTRY-SCRIPT: '(.+)','(.+)','(.+)'", line).groups()
38
- import pkgutil
39
-
40
- import pkg_resources
41
-
42
- module_name = pkg_resources.get_distribution(dist).get_entry_info(group, name).module_name
43
- with open(pkgutil.get_loader(module_name).get_filename()) as mod_fh:
44
- if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
45
- exit(0)
46
- elif line.startswith("# EASY-INSTALL-DEV-SCRIPT"):
47
- for line2 in lines:
48
- if line2.startswith("__file__"):
49
- filename = re.match("__file__ = '(.+)'", line2).group(1)
50
- with open(filename) as mod_fh:
51
- if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
52
- exit(0)
53
- elif line.startswith("# PBR Generated"):
54
- module = re.search("from (.*) import", head).groups()[0]
55
- import pkgutil
56
-
57
- import pkg_resources
58
-
59
- with open(pkgutil.get_loader(module).get_filename()) as mod_fh:
60
- if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
61
- exit(0)
62
-
63
- exit(1)
@@ -1,71 +0,0 @@
1
- #!/usr/bin/env python3
2
- # PYTHON_ARGCOMPLETE_OK
3
-
4
- # Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors.
5
- # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
6
-
7
- """
8
- Register a Python executable for use with the argcomplete module.
9
-
10
- To perform the registration, source the output of this script in your bash shell
11
- (quote the output to avoid interpolation).
12
-
13
- Example:
14
-
15
- $ eval "$(register-python-argcomplete my-favorite-script.py)"
16
-
17
- For Tcsh
18
-
19
- $ eval `register-python-argcomplete --shell tcsh my-favorite-script.py`
20
-
21
- For Fish
22
-
23
- $ register-python-argcomplete --shell fish my-favourite-script.py > ~/.config/fish/my-favourite-script.py.fish
24
- """
25
-
26
- import argparse
27
- import sys
28
-
29
- import argcomplete
30
-
31
- parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
32
-
33
- parser.add_argument(
34
- "--no-defaults",
35
- dest="use_defaults",
36
- action="store_false",
37
- default=True,
38
- help="when no matches are generated, do not fallback to readline's default completion (affects bash only)",
39
- )
40
- parser.add_argument(
41
- "--complete-arguments",
42
- nargs=argparse.REMAINDER,
43
- help="arguments to call complete with; use of this option discards default options (affects bash only)",
44
- )
45
- parser.add_argument(
46
- "-s",
47
- "--shell",
48
- choices=("bash", "zsh", "tcsh", "fish", "powershell"),
49
- default="bash",
50
- help="output code for the specified shell",
51
- )
52
- parser.add_argument(
53
- "-e", "--external-argcomplete-script", help="external argcomplete script for auto completion of the executable"
54
- )
55
-
56
- parser.add_argument("executable", nargs="+", help="executable to completed (when invoked by exactly this name)")
57
-
58
- argcomplete.autocomplete(parser)
59
-
60
- if len(sys.argv) == 1:
61
- parser.print_help()
62
- sys.exit(1)
63
-
64
- args = parser.parse_args()
65
-
66
-
67
- sys.stdout.write(
68
- argcomplete.shellcode(
69
- args.executable, args.use_defaults, args.shell, args.complete_arguments, args.external_argcomplete_script
70
- )
71
- )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes