feat: converter = None as the sentinel#996
feat: converter = None as the sentinel#996patrick-kidger merged 2 commits intopatrick-kidger:devfrom
Conversation
|
Looks reasonable to me! Let's get #994 in and then this one. |
7569e8f to
20158eb
Compare
|
@patrick-kidger. Ready! |
patrick-kidger
left a comment
There was a problem hiding this comment.
One comment only, but otherwise LGTM!
equinox/_module.py
Outdated
| for f in dataclasses.fields(cls): | ||
| if f.name not in cls.__init__.__annotations__: | ||
| continue # Odd behaviour, so skip. | ||
|
|
There was a problem hiding this comment.
Actually, I think I'm noticing a bug in the existing code here -- I think we should only be running all of this if has_dataclass_init? Worth fixing up here, if you agree?
There was a problem hiding this comment.
Sure! Then the check becomes if not f.init: continue.
1. Easier for users to access instead of a private sentinel. 2. simplifies later performance-related logic changes. 3. Broadens support to allow `dataclasses.field(metadata=dict(converter=None))`, not just `eqx.field`. Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
20158eb to
de28410
Compare
equinox/_module.py
Outdated
| cls.__init__.__annotations__[f.name] = converter_annotation | ||
| cls.__init__.__annotations__[f.name] = converter_annotation |
There was a problem hiding this comment.
I think this is an unintentional indent? (Or am I maybe misunderstanding the logic here?)
Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
de28410 to
7972df3
Compare
|
Okay, great! All looks good me, so merged. :) Heads-up for other PRs in the near future,I've just spun up a |
* feat: converter = None as the sentinel 1. Easier for users to access instead of a private sentinel. 2. simplifies later performance-related logic changes. 3. Broadens support to allow `dataclasses.field(metadata=dict(converter=None))`, not just `eqx.field`. Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com> * refactor: only set annotations if datclass init Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com> --------- Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
* feat: converter = None as the sentinel 1. Easier for users to access instead of a private sentinel. 2. simplifies later performance-related logic changes. 3. Broadens support to allow `dataclasses.field(metadata=dict(converter=None))`, not just `eqx.field`. Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com> * refactor: only set annotations if datclass init Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com> --------- Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
* feat: converter = None as the sentinel 1. Easier for users to access instead of a private sentinel. 2. simplifies later performance-related logic changes. 3. Broadens support to allow `dataclasses.field(metadata=dict(converter=None))`, not just `eqx.field`. Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com> * refactor: only set annotations if datclass init Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com> --------- Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
* feat: converter = None as the sentinel 1. Easier for users to access instead of a private sentinel. 2. simplifies later performance-related logic changes. 3. Broadens support to allow `dataclasses.field(metadata=dict(converter=None))`, not just `eqx.field`. Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com> * refactor: only set annotations if datclass init Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com> --------- Signed-off-by: Nathaniel Starkman <nstarman@users.noreply.github.com>
dataclasses.field(metadata=dict(converter=None)), not justeqx.field.Follow up to #994.