piptools._compat._click_compat module

Compatibility helpers and wrappers for working with click.

piptools._compat._click_compat._close_intelligently(fileobj: BinaryIO) → None

Close the file if it defines should_close and gives it a truthy value.

This relies on click’s internal LazyFile type’s should_close behavior, and suppresses errors which may occur when closing a file.

piptools._compat._click_compat._defer_lazy_file_close(ctx: Context, fileobj: BinaryIO) → None

Setup a click “lazy file” to close on exit.

piptools._compat._click_compat.open_output_file(ctx: Context, filename: str) → BinaryIO

Open a file with the desirable flags set for writing output.

The file will be lazy and atomic unless it’s stdout.