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

Click evaluates default callbacks during tab-completion #2614

Open
danielhollas opened this issue Sep 28, 2023 · 0 comments
Open

Click evaluates default callbacks during tab-completion #2614

danielhollas opened this issue Sep 28, 2023 · 0 comments

Comments

@danielhollas
Copy link

In our app we pass certain defaults via callbacks because they are expensive to calculate. Specifically we want a snappy tab completion. However, it seems that since Click 8.0 the defaults are evaluated even during the tab-autocompletion. I am not sure if this is an expected behaviour or a bug?

It seems that before v8 the behaviour was different. You can see that in the API docs, in an (apparently outdated) comment about resilient_parsing context parameter. https://click.palletsprojects.com/en/8.1.x/api/#click.Context

resilient_parsing (bool) – if this flag is enabled then Click will parse without any interactivity or callback invocation. Default values will also be ignored. This is useful for implementing things such as completion support.

But looking through the core.py code, this flag does not seem honored in the relevant code paths AFAIK. Before that there was even an explicit flag ignore_default_values, which was removed here. 02202b6#diff-89531a2fdd908d78f3d3e9bb04de62cb9ad7fd27454da83249937ac29c6f683aR1438

If this is an expected behaviour, I would appreciate advice as to how to override it. Thanks!

Environment:

  • Python version: 3.10.6
  • Click version: 8.1.3
@danielhollas danielhollas changed the title Click evaluates defaults during tab-completion Click evaluates default callbacks during tab-completion Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant