Skip to content

[FEA]: Support AnnAssign AST node #45

@XOR-op

Description

@XOR-op

Is this a new feature, an improvement, or a change to existing functionality?

Improvement

How would you describe the priority of this feature request?

Medium

Please provide a clear description of problem this feature solves

Allow developers to add type annotations for expressions. This helps improve code clarity and reduce LSP warning/error given that current function signatures have multiple possible return types.

Feature Description

@ct.kernel
def foo(x: ct.Array, y: ct.Array):
    # ...
    x_exp = ct.exp2(x) # Currently returns ct.Tile | int | float | ScalarProtocol 
   # Or
   x_exp: ct.Tile = ct.exp2(x) # cuda.tile._exception.TileSyntaxError: Unsupported syntax <class 'ast.AnnAssign'>

Describe your ideal solution

Given the type annotation is optional and not enforced at runtime, it's acceptable to treat ast.AnnAssign as an ordinary ast.Assign.

Describe any alternatives you have considered

No response

Additional context

No response

Contributing Guidelines

  • I agree to follow cuTile Python's contributing guidelines
  • I have searched the open feature requests and have found no duplicates for this feature request

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions