Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show_default and default_map don't play nice together #1548

ewjoachim opened this issue May 9, 2020 · 4 comments · Fixed by #1549

show_default and default_map don't play nice together #1548

ewjoachim opened this issue May 9, 2020 · 4 comments · Fixed by #1549


Copy link

#!/usr/bin/env python
import click

    "show_default": True, "default_map": {"a": "b"}
@click.option("-a", default="c")
def func(a):

if __name__ == "__main__":
$ # This is expected
$ ./
$ # This is not (default should be b)
$ ./ --help
Usage: [OPTIONS]

  -a TEXT  [default: c]
  --help   Show this message and exit.  [default: False]

Expected Behavior

I expect the default shown to be identical to the one being used.

Actual Behavior

The default shown was the value provided as default, without taking the default_map into account


  • Python version: 3.7
  • Click version: click==7.1.2
Copy link
Contributor Author

I may be able to make a failing test or a PR if you point me to the right direction. Would calling lookup_default instead of .default in this line be enough ?

default_string = self.default

Copy link

davidism commented May 9, 2020

Seems plausible, happy to review a PR.

Copy link
Contributor Author

Ok, I'll try to remember to communicate here whether it happens or not. If I have neither said nor committed anything by May 17th, assume I have forgotten about it and you're free to go :)

Copy link
Contributor Author

Yay, done :)

@davidism davidism added this to the 8.0.0 milestone Oct 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging a pull request may close this issue.

3 participants