Skip to content
Myr

Don't include envvar in error hint when envvar not configured

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

authored by Patrick Lannigan · committed by Patrick Lannigan · parent 499bbee · Browse files · 3 files+15 added−1 removed
This commit

State

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

Diff stats

3 files+15 added−1 removed

  • tests:+7 added−0 removed
  • other:+8 added−1 removed

3 files+15 added−1 removed

modified:src/click/core.py+1 added-1 removed
2674 unmodified lines
2675 return info_dict26762677 def get_error_hint(self, ctx: Context) -> str:2678 result = super().get_error_hint(ctx)2679 if self.show_envvar:2679 if self.show_envvar and self.envvar is not None:2680 result += f" (env var: '{self.envvar}')"2681 return result26822683 def _parse_decls(
452 unmodified lines
modified:tests/test_options.py+7 added
590 unmodified lines
591 result = runner.invoke(cli)592 assert result.exit_code == 2593 assert "Error: Missing option '--foo' (env var: 'bar')." in result.output594595 cli = click.Command(596 "cli", params=[click.Option(["--foo"], show_envvar=True, required=True)]597 )598 result = runner.invoke(cli)599 assert result.exit_code == 2600 assert "Error: Missing option '--foo'." in result.output601602603def test_case_insensitive_choice(runner):604 @click.command()605 @click.option("--foo", type=click.Choice(["Orange", "Apple"], case_sensitive=False))606 def cmd(foo):
542 unmodified lines
modified:CHANGES.rst+7 added
1.. currentmodule:: click23Version 8.2.04-------------56Unreleased78- Don't include envvar in error hint when not configured. :issue:`2971`910Version 8.2.111-------------1213Released 2025-05-20
1241 unmodified lines