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

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

show_default and default_map don't play nice together #1548

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

Comments

@ewjoachim
Copy link
Contributor

#!/usr/bin/env python
import click

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

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

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

Environment

  • Python version: 3.7
  • Click version: click==7.1.2
@ewjoachim
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

@davidism
Copy link
Member

davidism commented May 9, 2020

Seems plausible, happy to review a PR.

@ewjoachim
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 :)

@ewjoachim
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.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants