Skip to content

Relax type for structurelist argument to TrajectoryData - #7536

Open
danielhollas wants to merge 2 commits into
aiidateam:mainfrom
danielhollas:structurelist-type
Open

Relax type for structurelist argument to TrajectoryData#7536
danielhollas wants to merge 2 commits into
aiidateam:mainfrom
danielhollas:structurelist-type

Conversation

@danielhollas

Copy link
Copy Markdown
Collaborator

Found when trying to typecheck my AiiDAlab application, where I am passing a tuple[StructureData] as the structurelist argument to TrajectoryData

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 744c3de0-0d64-420a-8d09-c398f07b4ed9

📥 Commits

Reviewing files that changed from the base of the PR and between 1212ee9 and 2bdf63a.

📒 Files selected for processing (1)
  • src/aiida/orm/nodes/data/array/trajectory.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/aiida/orm/nodes/data/array/trajectory.py

📝 Walkthrough

Walkthrough

TrajectoryData now accepts generic sequences of StructureData. Structure lookup converts generated step indices to integers before indexing.

Changes

Trajectory structure sequence support

Layer / File(s) Summary
Sequence input handling
src/aiida/orm/nodes/data/array/trajectory.py
TrajectoryData.__init__ and set_structurelist accept Sequence[StructureData]. Structure lookup converts generated step indices to integers.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: accepting broader sequence types for the TrajectoryData structurelist argument.
Description check ✅ Passed The description explains the type-checking issue caused by passing a tuple to TrajectoryData and directly relates to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/aiida/orm/nodes/data/array/trajectory.py (1)

221-226: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the set_structurelist docstring for sequence input.

set_structurelist now accepts t.Sequence[StructureData], but the summary and :param structurelist: entry still describe a list. Change both descriptions to “sequence” and mention tuple support. Otherwise, the generated documentation contradicts the public type contract.

As per coding guidelines, keep the accepted type in the annotation and describe the parameter consistently in the Sphinx prose.

Proposed documentation update
-        """Create trajectory from the list of
+        """Create trajectory from a sequence of
             :py:class:`aiida.orm.nodes.data.structure.StructureData` instances.
...
-        :param structurelist: a list of
+        :param structurelist: a sequence of
             :py:class:`aiida.orm.nodes.data.structure.StructureData` instances.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/aiida/orm/nodes/data/array/trajectory.py` around lines 221 - 226, Update
the set_structurelist docstring summary and its :param structurelist:
description to say “sequence” instead of “list,” explicitly noting that tuples
are supported, while preserving the existing t.Sequence[StructureData]
annotation.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/aiida/orm/nodes/data/array/trajectory.py`:
- Around line 221-226: Update the set_structurelist docstring summary and its
:param structurelist: description to say “sequence” instead of “list,”
explicitly noting that tuples are supported, while preserving the existing
t.Sequence[StructureData] annotation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 968be460-6349-4df9-82ce-91233be57361

📥 Commits

Reviewing files that changed from the base of the PR and between 299e945 and 1212ee9.

📒 Files selected for processing (1)
  • src/aiida/orm/nodes/data/array/trajectory.py

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.69%. Comparing base (299e945) to head (2bdf63a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7536      +/-   ##
==========================================
+ Coverage   80.68%   80.69%   +0.02%     
==========================================
  Files         581      581              
  Lines       47068    47068              
==========================================
+ Hits        37972    37977       +5     
+ Misses       9096     9091       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant