Skip to content

Comments

fix[next]: Explicitly import fbuiltin members in gt4py.next#2484

Open
DropD wants to merge 1 commit intoGridTools:mainfrom
DropD:explicit-fbuiltins-imports
Open

fix[next]: Explicitly import fbuiltin members in gt4py.next#2484
DropD wants to merge 1 commit intoGridTools:mainfrom
DropD:explicit-fbuiltins-imports

Conversation

@DropD
Copy link
Contributor

@DropD DropD commented Feb 18, 2026

Description

Radically reduce the amount of required type ignores in client code which uses the from gt4py import next as gtx pattern.

Requirements

  • All fixes and/or new features come with corresponding tests.
  • Important design decisions have been documented in the appropriate ADR inside the docs/development/ADRs/ folder.

Radically reduce the amount of required type ignores in client code
which uses the `from gt4py import next as gtx` pattern.
@DropD DropD requested a review from egparedes February 18, 2026 10:42
Copy link
Contributor

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I just have a comment and a question

)
from .program_processors.runners.roundtrip import default as itir_python


Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add some kind of automated test to make sure we do not forget to reexport content form fbuiltins if we modified that file. Just as an example draft:

Suggested change
assert not (missing := ({*fbuiltins.__all__} - globals().keys())), f"Missing reexports of gt4py.next builtins: {missing}"

# mypy can not see through runtime logic in "fbuiltins"
disable_error_code = ["attr-defined"]
module = 'gt4py.next'

Copy link
Contributor

Choose a reason for hiding this comment

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

Question: why is this needed? What error is mypy generating here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

one of these for each member:

src/gt4py/next/__init__.py:42:1: error: Module "gt4py.next.ffront.fbuiltins" does not explicitly export attribute "uint32"  [attr-defined]

I theorize it is because to determine which attributes are actually in fbuiltins.__all__, mypy would have to execute code. We are generating and concatenating lists, no idea why we do all of that dynamically at import time...

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.

2 participants