Skip to content

Better type Module.apply signature - PR discussion #4779

@Daraan

Description

@Daraan

Following up on #2086 and this recent SO question How to type hint flax.linen.Module.apply's output correctly?.

I would like to add a PR based on my answer and add two typing.overload signatures that make it more clear when to expect a tuple return value - following the contribution guidelines I am opening this issue first.

Based on #2086, the docstring and

flax/flax/core/scope.py

Lines 1080 to 1083 in 893a660

if mutable is not False:
return y, root.mutable_variables()
else:
return y

I am certain that only mutable=False never returns a tuple, otherwise it will always be a tuple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions