Skip to content

Commit

Permalink
Add a comment to force_name to avoid overuse.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 582654523
  • Loading branch information
hamzamerzic authored and copybara-github committed Nov 15, 2023
1 parent f1e4f5f commit ce05309
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion haiku/_src/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ def next_module_number(name: str) -> int:
def force_name(name: str) -> str:
"""Forces Haiku to use this name, ignoring all context information.
NOTE: This method is intended for advanced use cases only and should be
avoided whenever possible as it effectively enforces a singleton pattern when
setting absolute names.
Haiku names modules according to where they are created (e.g. the stack of
modules that created them, or the current :func:`~haiku.name_scope`). This
function allows you to create modules that ignore all of this and have
Expand All @@ -578,7 +582,6 @@ def force_name(name: str) -> str:
Args:
name: String name for the module. For example ``"foo"`` or ``"foo/bar"``.
Returns:
A value suitable to pass into the ``name`` argument of any Haiku module
constructor.
Expand Down

0 comments on commit ce05309

Please sign in to comment.