Skip to content

next: dimension types are not valid types for static type checking purposes #2503

@DropD

Description

@DropD

Problem

from gt4py import next as gtx

KDim = gtx.Dimension("KDim", kind=gtx.DimensionKind.VERTICAL)

@gtx.field_operator
def foo(a: gtx.Field[gtx.Dims[KDim], gtx.int32]) -> gtx.Field[gtx.Dims[KDim], gtx.int32]:
    return a

leads to

error: Variable "KDim" is not valid as a type  [valid-type]

This blocks client projects from type checking stencils effectively.

Proposed Solution

See #2484 for a minimal mypy plugin, which selecively ignores (treats as Any) any type hint with a name ending in "Dim".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions