Skip to content

AtomisticModel doesn't support using builtins as annotations #351

Description

@pfebrer

In this section:

if annotations["systems"] != List[System]:
raise TypeError(
"`systems` argument must be a list of metatomic `System`, "
f"not `{_format_annotation(annotations['systems'])}`"
)
if annotations["outputs"] != Dict[str, ModelOutput]:
raise TypeError(
"`outputs` argument must be `Dict[str, ModelOutput]`, "
f"not `{_format_annotation(annotations['outputs'])}`"
)
if annotations["selected_atoms"] != Optional[Labels]:
raise TypeError(
"`selected_atoms` argument must be `Optional[Labels]`, "
f"not `{_format_annotation(annotations['selected_atoms'])}`"
)
if annotations["return"] != Dict[str, TensorMap]:
raise TypeError(
"`forward()` must return a `Dict[str, TensorMap]`, "
f"not `{_format_annotation(annotations['return'])}`"
)
AtomisticModel checks the annotations of the model, and it only allows the typing objects (List, Dict...) when it should also allow the builtins (list, dict...)

Activity

  1. added theissue type on Oct 12, 2026
  2. Luthaf commented on Oct 12, 2026

    @Luthaf
    Member

    True, this code is a bit old fashioned! We should update it

  3. kumar-miskin commented on Oct 22, 2026

    @kumar-miskin
    Contributor

    I reproduced this with an eager AtomisticModel using list[System] and dict annotations: the Python signature check rejects the systems argument before wrapping. I plan to compare the list/dict origins and type arguments rather than their typing aliases, keeping the existing rejection of wrong element/key/value types. I will add eager and TorchScript coverage, plus mixed typing/builtin annotations. This would stay scoped to the legacy AtomisticModel check, separate from the TorchModel rewrite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions