Skip to content
Discussion options

You must be logged in to vote

Answer by @hexahedria:

Dataclass actually reads the type annotation, so the code below works fine (even with Any), but fails without any type annotation.

class Foo(nn.Module):
  go : Callable = somefunc

So moral of the story, put type annotations for the things you want to be dataclass attributes

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@marcvanzee
Comment options

Answer selected by marcvanzee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant