Repository navigation
Make unimported utilities explicitely private #3099
Description
Activity
Yes, and in the future I'd lean towards not exposing anything new to the top level (or public) without very deliberate consideration.
Reacted by Mike TorresI will also add private to the doc strings since they have no leading _.
Reacted by David LordMaybe we can even move them to the
_utils.pyfile.- added a parent issue
on Nov 22, 2025 I think we should rename them with leading _ and move into _utils if there is not a better spot for them.
Reacted by Kevin DeldyckeAnother proposal: if we have a lot of file-related private utilities, we can move them all to an
_io.pyfile. Which can also anticipate a future public facingio.pyfile.Apologies for butting in, but if
LazyFileis being made private, is there a more appropriate type hint for parameters receiving lazily-opened files? In my own CLIs, I'm currently using it in that fashion, e.g.:from typing import TYPE_CHECKING import click from . import cook_the_data if TYPE_CHECKING: from io import BufferedReader from click.utils import LazyFile @click.command() @click.argument("in_file", type=click.File("r")) @click.argument("out_file", type=click.File("w")) # Implicitly lazy. def do_stuff(*, in_file: BufferedReader, out_file: LazyFile) -> None: raw_data = in_file.read() cooked_data = cook_the_data(raw_data) with out_file.open() as out_file_writer: out_file_writer.write(cooked_data)
It would suck to lose the ability to correctly type-hint
out_file, here. 🙂It should not matter if the file is lazy or not, it has the same interface as a regular file.
Reacted by Ben BlankOkay, I see where my misunderstanding was; I had missed
LazyFile.__getattr__and thought lazy files needed to be explicitly.open()ed before use. Thanks for helping clear that up!- linked a pull request that will close this issueMark clearly functions private status. Deprecated Python 2 utilities. #3695
on Jul 16, 2026 - changed the title
[-]Are unimported utilities intentional[/-][+]Make unimported utilities explicitely private[/+]on Jul 17, 2026 - addeddocsUpdates to documentation, readme, docstrings, typosUpdates to documentation, readme, docstrings, typostypingType annotations and stubsType annotations and stubs
on Jul 17, 2026 - locked as resolved and limited conversation to collaborators
on Aug 1, 2026
This utilities are not imported in init:
Is that intentional?