fix(annotations): module annotations are needed at runtime#1377
Merged
paul-nechifor merged 1 commit intodevfrom Feb 28, 2026
Merged
fix(annotations): module annotations are needed at runtime#1377paul-nechifor merged 1 commit intodevfrom
paul-nechifor merged 1 commit intodevfrom
Conversation
leshy
approved these changes
Feb 28, 2026
Contributor
Greptile SummaryThis PR fixes a runtime annotation resolution bug in Key changes:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Module subclass defined\n(e.g. GraspingModule)"] --> B["Module.__init_subclass__ called"]
B --> C["get_type_hints(cls, include_extras=True)"]
C --> D{NameError?}
D -->|"Yes (pre-fix: type behind TYPE_CHECKING)"| E["hints = {}\nIn/Out streams NOT wired"]
D -->|"No (post-fix: types in module globals)"| F["Iterate annotations"]
F --> G{origin is In or Out?}
G -->|Yes| H["setattr(cls, name, None)\n(class-level placeholder for Dask proxy)"]
G -->|No| I[Skip]
subgraph "ruff enforcement (new)"
J["runtime-evaluated-base-classes:\n dimos.core.module.Module"]
J --> K["Ruff TCxxx rules: imports used\nin Module annotations\nMUST NOT be behind TYPE_CHECKING"]
end
K -.->|guarantees| C
Last reviewed commit: 3c37fac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
if TYPE_CHECKING,get_type_hintscannot read them.Closes DIM-636
Solution
Basically remove the hack and just add:
...to get ruff to enforce that annotations to modules always use real types, not types behind TYPE_CHECKING.
Breaking Changes
None.
How to Test
In a module file, move the import for
In/OuttoTYPE_CHECKING. Then run:It should be moved back outside.
Contributor License Agreement