-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 doesn't close file options during shell completion #2644
Comments
@gregorias, if you have some time. Could you create a test case that can reproduce the issue? I'm having a hard time exactly reproducing the error that you're seeing. Doesn't have to be a test case, but even an example CLI and what to call it with would be sufficient. Then I can look into this. |
You can find the repro repo + instructions at https://github.com/gregorias/click-2644. It’s crucial to enable the dev mode to see warnings with |
@gregorias thank you so much. I'll give it a look. I have some experience with the resource warnings and the dev mode settings from at work where we're also doing some things around it. |
It seems that the reason why I couldn't get it to repro was because when the file ( |
Signing off for today. I haven't had the time to try and confirm your example is fixed now too, but it likely should be. I used it as an inspiration for the new test case. Let me know if you still see an issue! Thanks once again for the repro! |
Click doesn't close file options during shell completion, which causes a resource warning if a program uses a file option.
For example, I have group like this:
and I get this warning:
Details
I don't come with reproduction steps, but I can give something equally valuable, I can explain how this bug comes to be.
The issue stems from allocating a context in
core.py
outside of awith
statement during shell completion. Here's a stack-trace of how that happens:This context gets returned to
get_completions
, butget_completions
or its caller never call the context's__exit__
function.Calling the
__exit__
function is essential, becausetypes.File
depends on it for cleanup:click/src/click/types.py
Line 740 in ca5e1c3
Environment
The text was updated successfully, but these errors were encountered: