fix[next]: Reduce type ignores in client code#2484
fix[next]: Reduce type ignores in client code#2484DropD wants to merge 47 commits intoGridTools:mainfrom
Conversation
Radically reduce the amount of required type ignores in client code which uses the `from gt4py import next as gtx` pattern.
egparedes
left a comment
There was a problem hiding this comment.
Thanks for the PR. I just have a comment and a question
pyproject.toml
Outdated
| # mypy can not see through runtime logic in "fbuiltins" | ||
| disable_error_code = ["attr-defined"] | ||
| module = 'gt4py.next' | ||
|
|
There was a problem hiding this comment.
Question: why is this needed? What error is mypy generating here?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
My guess is that this ignore won't be needed after the suggestion above about defining fbuiltins.__all__ statically
There was a problem hiding this comment.
Still no, the problem being that we don't sin = make_builtin("sin") etc, but instead we do globals()[key] = BuiltInFunction(val) in a loop.
One way to fix this would be to do the analog of sin = math.sin for each of these in an if TYPE_CHECKING block. The other would be to do it more manually in the first place.
There was a problem hiding this comment.
I am going with manually unrolling the loops for now (the asserts will catch if there is a forgotten assignment)
fbuiltin members in gt4py.next|
cscs-ci run default |
egparedes
left a comment
There was a problem hiding this comment.
Looks correct to me, thanks! I have some comments and questions, many of them optional or just for my own understanding.
pyproject.toml
Outdated
| source-file = "src/gt4py/__about__.py" | ||
|
|
||
| [tool.versioningit.vcs] | ||
| default-tag = "v1.1.6" |
There was a problem hiding this comment.
I would remove this from this PR. I'll try to create a tiny PR later to fix properly the versioningit warnings following this strategy.
There was a problem hiding this comment.
This is only here so I can run CI in the meantime.
…void any output being written
|
cscs-ci run default |
Description
Partner-PR in icon4py: C2SM/icon4py#1096 (make sure this passes tests first)
Radically reduce the amount of required type ignores in client code which uses the
from gt4py import next as gtxpattern.Experimenting with this in icon4py reveals more ways in which gt4py blocks client code type checking, which have not been addressed in this PR so far:
Requirements