Skip to content

chore: enforce future annotations in src - #940

Open
chethanuk wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
chethanuk:chore/enforce-future-annotations
Open

chethanuk wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
chethanuk:chore/enforce-future-annotations

Conversation

@chethanuk

Copy link
Copy Markdown

📋 Summary

AGENTS.md and STYLEGUIDE.md require from __future__ import annotations in every source file, but nothing enforces it, and 16 __init__.py files under packages/*/src don't have it. This adds ruff's required-imports (I002) for packages/*/src and adds the import to those files.

🔗 Related Issue

Closes #760

🔄 Changes

  • Uses I002 instead of the FA102 the issue suggests. FA102 only fires for targets below py310, so with target-version = "py310" it passes on main even with these files missing the import.
  • "!packages/*/src/**" = ["I002"] in per-file-ignores keeps tests, tests_e2e and scripts out of scope.
  • I002 skips files with no statements, so 14 of the 16 files (header-only stubs) get the import but aren't guarded until they have code.

🧪 Testing

  • make test passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)
  • make lint passes. Deleting the import from engine/storage/__init__.py gives I002 Missing required import; an existing tests file without it (config/analysis/conftest.py) is not flagged.
  • The touched packages import cleanly, and pytest packages/data-designer-engine/tests/engine/storage packages/data-designer/tests/integrations passes (158 tests).

✅ Checklist

  • Follows commit message conventions
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

AGENTS.md and STYLEGUIDE.md require `from __future__ import annotations`
in every source file, but no lint rule checked it. Turn on ruff's
isort required-imports (I002) for packages/*/src and add the import to
the 16 src __init__.py files that lacked it.

FA102 would not help here: it only fires when the target is Python 3.9
or older, and the project targets py310. I002 skips files with no
statements, so it guards every src file with code, including re-export
__init__.py modules; the header-only stubs get the import anyway.

Signed-off-by: ChethanUK <chethanuk@outlook.com>
@chethanuk
chethanuk requested a review from a team as a code owner September 16, 2026 20:09
@github-actions

Copy link
Copy Markdown
Contributor

Linked Issue Check

Issue #760 has not been triaged yet. A maintainer needs to review
the issue and add the triaged label for this check to pass.

You can continue working on the PR in the meantime. The check will
re-run automatically once the issue is triaged.

@greptile-apps

greptile-apps Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge. No concrete bug was found.

Summary

This PR makes Ruff enforce from __future__ import annotations across package source files. It also adds the import to 16 affected __init__.py files while keeping tests, scripts, and end-to-end checks outside this rule.

  • Adds Ruff's I002 required-import check for packages/*/src.
  • Excludes tests, scripts, and end-to-end files from that check.
  • Updates the affected package initializers without changing their existing exports.
Diagram
sequenceDiagram
    actor Dev
    participant Ruff
    participant Config as pyproject.toml
    actor User
    participant Python
    participant Package

    Dev->>Ruff: Run ruff check
    Ruff->>Config: Load lint rules
    alt "File is under packages/*/src"
        Config-->>Ruff: Require future annotations import
        alt File has statements and misses the import
            Ruff-->>Dev: Report I002
        else Import exists or file has no statements
            Ruff-->>Dev: Pass I002
        end
    else File is outside package src
        Config-->>Ruff: Ignore I002
    end

    User->>Python: Import a changed package
    Python->>Package: Run __init__.py
    Package->>Python: Enable postponed annotations for this module
    Package-->>User: Keep existing exports
Loading

Reviews (1) · Last reviewed commit: "chore: enforce future annotations in src"

@github-actions

Copy link
Copy Markdown
Contributor

Stale PR reminder

This PR has had failing checks for 7 days without activity.

Failing checks: check

Please push an update or leave a comment if you're still working on this.
Otherwise, this PR will be automatically closed in 7 days.

To prevent auto-close, add the keep-open label.

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.

enforce \from future import annotations via ruff FA102 rule

1 participant