rich-click 1.8.0.dev0__tar.gz → 1.8.0.dev2__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 (30) hide show
  1. {rich-click-1.8.0.dev0/src/rich_click.egg-info → rich-click-1.8.0.dev2}/PKG-INFO +2 -2
  2. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/README.md +1 -1
  3. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/__init__.py +1 -1
  4. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/cli.py +49 -10
  5. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/rich_command.py +0 -2
  6. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2/src/rich_click.egg-info}/PKG-INFO +2 -2
  7. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/tests/test_rich_click_cli.py +1 -0
  8. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/LICENSE +0 -0
  9. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/pyproject.toml +0 -0
  10. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/setup.cfg +0 -0
  11. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/__main__.py +0 -0
  12. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/_compat_click.py +0 -0
  13. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/decorators.py +0 -0
  14. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/patch.py +0 -0
  15. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/py.typed +0 -0
  16. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/rich_click.py +0 -0
  17. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/rich_context.py +0 -0
  18. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/rich_group.py +0 -0
  19. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/rich_help_configuration.py +0 -0
  20. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/rich_help_formatter.py +0 -0
  21. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/rich_help_rendering.py +0 -0
  22. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click/utils.py +0 -0
  23. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click.egg-info/SOURCES.txt +0 -0
  24. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click.egg-info/dependency_links.txt +0 -0
  25. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click.egg-info/entry_points.txt +0 -0
  26. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click.egg-info/requires.txt +0 -0
  27. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/src/rich_click.egg-info/top_level.txt +0 -0
  28. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/tests/test_config.py +0 -0
  29. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/tests/test_exit_code.py +0 -0
  30. {rich-click-1.8.0.dev0 → rich-click-1.8.0.dev2}/tests/test_help.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rich-click
3
- Version: 1.8.0.dev0
3
+ Version: 1.8.0.dev2
4
4
  Summary: Format click help output nicely with rich
5
5
  Author-email: Phil Ewels <phil@ewels.co.uk>
6
6
  Maintainer-email: Phil Ewels <phil@ewels.co.uk>, Daniel Reeves <xdanielreeves@gmail.com>
@@ -83,7 +83,7 @@ Requires-Dist: mkdocstrings[python]; extra == "docs"
83
83
  ---
84
84
 
85
85
  <p align="center">
86
- <a href="https://ewels.github.io/rich-click">Documentation</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Source Code</a>&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Changelog</a>
86
+ <a href="https://ewels.github.io/rich-click">Documentation</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Source Code</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Changelog</a>
87
87
  </p>
88
88
 
89
89
  ---
@@ -16,7 +16,7 @@
16
16
  ---
17
17
 
18
18
  <p align="center">
19
- <a href="https://ewels.github.io/rich-click">Documentation</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Source Code</a>&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Changelog</a>
19
+ <a href="https://ewels.github.io/rich-click">Documentation</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Source Code</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Changelog</a>
20
20
  </p>
21
21
 
22
22
  ---
@@ -6,7 +6,7 @@ The intention is to provide attractive help output from Click, formatted with Ri
6
6
  customisation required.
7
7
  """
8
8
 
9
- __version__ = "1.8.0dev0"
9
+ __version__ = "1.8.0dev2"
10
10
 
11
11
  # Import the entire click API here.
12
12
  # We need to manually import these instead of `from click import *` to force
@@ -110,6 +110,14 @@ class _RichHelpConfigurationParamType(click.ParamType):
110
110
  type=click.Choice(["html", "svg"], case_sensitive=False),
111
111
  help="Optionally render help text as HTML or SVG. By default, help text is rendered normally.",
112
112
  )
113
+ @click.option(
114
+ "--suppress-warnings/--do-not-suppress-warnings",
115
+ is_flag=True,
116
+ default=False,
117
+ hidden=True,
118
+ help="Suppress warnings when there are conflicting entry_points."
119
+ " (This option is hidden because this situation is extremely rare).",
120
+ )
113
121
  @click.option(
114
122
  # The rich-click CLI uses a special implementation of --help,
115
123
  # which is aware of the --rich-config object.
@@ -132,6 +140,7 @@ def main(
132
140
  ctx: RichContext,
133
141
  script_and_args: List[str],
134
142
  output: Literal[None, "html", "svg"],
143
+ suppress_warnings: bool,
135
144
  rich_config: Optional[RichHelpConfiguration],
136
145
  show_help: bool,
137
146
  ) -> None:
@@ -164,20 +173,50 @@ def main(
164
173
  click.echo(ctx.get_help(), color=ctx.color)
165
174
  ctx.exit()
166
175
 
167
- sys.path.append(".")
168
-
169
176
  script, *args = script_and_args
170
177
 
171
- _from_entry_points = False
172
-
173
- scripts = {script.name: script for script in entry_points(group="console_scripts")}
174
- if script in scripts:
175
- module_path, function_name = scripts[script].value.split(":", 1)
176
- _from_entry_points = True
177
- elif ":" in script:
178
+ _selected: List[str] = []
179
+ module_path = ""
180
+ function_name = ""
181
+
182
+ for s in entry_points(group="console_scripts"):
183
+ if script == s.name:
184
+ if not _selected:
185
+ module_path, function_name = s.value.split(":", 1)
186
+ if suppress_warnings:
187
+ break
188
+ if s.value not in _selected:
189
+ _selected.append(s.value)
190
+
191
+ if len(_selected) > 1 and not suppress_warnings:
192
+ # This is an extremely rare edge case that comes up when the user sets the PYTHONPATH themselves.
193
+ if script in sys.argv:
194
+ _args = sys.argv.copy()
195
+ _args[_args.index(script)] = f"{module_path}:{function_name}"
196
+ else:
197
+ _args = ["rich-click", f"{module_path}:{function_name}"]
198
+
199
+ click.echo(
200
+ click.style(
201
+ f"WARNING: Multiple entry_points correspond with script '{script}': {_selected!r}."
202
+ "\nThis can happen when an 'egg-info' directory exists, you're using a virtualenv,"
203
+ " and you have set a custom PYTHONPATH."
204
+ f"\n\nThe selected script is '{module_path}:{function_name}', which is being executed now."
205
+ "\n\nIt is safer and recommended that you specify the MODULE:CLICK_COMMAND"
206
+ f" ('{module_path}:{function_name}') instead of the script ('{script}'), like this:"
207
+ f"\n\n>>> rich-click {' '.join(_args)}"
208
+ "\n\nAlternatively, you can pass --suppress-warnings to the rich-click CLI,"
209
+ " which will disable this message.",
210
+ fg="red",
211
+ ),
212
+ file=sys.stderr,
213
+ )
214
+
215
+ if ":" in script and not module_path:
178
216
  # the path to a function was passed
179
217
  module_path, function_name = script.split(":", 1)
180
- else:
218
+
219
+ if not module_path:
181
220
  raise click.ClickException(f"No such script: {script_and_args[0]}")
182
221
 
183
222
  prog = module_path.split(".", 1)[0]
@@ -406,5 +406,3 @@ def prevent_incompatible_overrides(
406
406
  if hasattr(cmd.__class__, "format_commands"):
407
407
  if method_is_from_subclass_of(cmd.__class__, cls, "format_commands"):
408
408
  getattr(RichMultiCommand, "format_commands")(cmd, ctx, formatter)
409
- else:
410
- getattr(cmd, "format_commands")(ctx, formatter)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rich-click
3
- Version: 1.8.0.dev0
3
+ Version: 1.8.0.dev2
4
4
  Summary: Format click help output nicely with rich
5
5
  Author-email: Phil Ewels <phil@ewels.co.uk>
6
6
  Maintainer-email: Phil Ewels <phil@ewels.co.uk>, Daniel Reeves <xdanielreeves@gmail.com>
@@ -83,7 +83,7 @@ Requires-Dist: mkdocstrings[python]; extra == "docs"
83
83
  ---
84
84
 
85
85
  <p align="center">
86
- <a href="https://ewels.github.io/rich-click">Documentation</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Source Code</a>&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Changelog</a>
86
+ <a href="https://ewels.github.io/rich-click">Documentation</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Source Code</a>&nbsp&nbsp·&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Changelog</a>
87
87
  </p>
88
88
 
89
89
  ---
@@ -82,6 +82,7 @@ def test_simple_rich_click_cli(simple_script: Path, assert_str: AssertStr, comma
82
82
  res = subprocess.run(
83
83
  [sys.executable, "-m", "src.rich_click", "mymodule:cli", "--help"],
84
84
  stdout=subprocess.PIPE,
85
+ stderr=subprocess.PIPE,
85
86
  env={**os.environ, "TERMINAL_WIDTH": "100", "FORCE_COLOR": "False"},
86
87
  )
87
88
  assert res.returncode == 0
File without changes