Skip to content

support annotated assign#344

Merged
Roger-luo merged 2 commits into
mainfrom
roger/ann-assign
Apr 3, 2025
Merged

support annotated assign#344
Roger-luo merged 2 commits into
mainfrom
roger/ann-assign

Conversation

@Roger-luo
Copy link
Copy Markdown
Collaborator

@Roger-luo Roger-luo commented Apr 2, 2025

closes #324

This PR continues the previous refactor that we change how we dispatch lowering transform for a given ast.Call, instead we use lowerking.akin to register the lowering pass for a corresponding Python callable. This allows smoother integration with existing packages, e.g for numpy we can create an IR that mimics numpy's API and compile functions calling numpy.

In this PR, we support lowering e.g ilist.IList constructor into ilist.New statement, so that we can write something like the following

@basic_no_opt.add(ilist)
def list_assign():
    xs: ilist.IList[float, Literal[3]] = ilist.IList([1, 2, 3], elem=types.Float)
    return xs

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
9242 8123 88% 0% 🟢

New Files

File Coverage Status
src/kirin/rewrite/type_assert.py 93% 🟢
TOTAL 93% 🟢

Modified Files

File Coverage Status
src/kirin/dialects/ilist/interp.py 93% 🟢
src/kirin/dialects/ilist/lowering.py 84% 🟢
src/kirin/dialects/ilist/stmts.py 100% 🟢
src/kirin/dialects/lowering/func.py 95% 🟢
src/kirin/dialects/lowering/range.py 94% 🟢
src/kirin/dialects/py/assign.py 83% 🟢
src/kirin/dialects/py/attr.py 92% 🟢
src/kirin/dialects/py/builtin.py 90% 🟢
src/kirin/dialects/py/iterable.py 77% 🟢
src/kirin/dialects/py/len.py 87% 🟢
src/kirin/dialects/py/slice.py 93% 🟢
src/kirin/lowering/_init_.py 100% 🟢
src/kirin/lowering/python/dialect.py 89% 🟢
src/kirin/lowering/python/lowering.py 91% 🟢
src/kirin/passes/typeinfer.py 100% 🟢
src/kirin/registry.py 78% 🟢
src/kirin/rewrite/_init_.py 100% 🟢
TOTAL 91% 🟢

updated for commit: c4c4fba by action🐍

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2025

PR Preview Action v1.6.0
Preview removed because the pull request was closed.
2025-04-03 23:16 UTC

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/kirin/dialects/py/assign.py 73.13% 18 Missing ⚠️
src/kirin/dialects/ilist/lowering.py 73.68% 5 Missing ⚠️
src/kirin/registry.py 78.26% 5 Missing ⚠️
src/kirin/lowering/python/dialect.py 90.00% 4 Missing ⚠️
src/kirin/rewrite/type_assert.py 93.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Roger-luo Roger-luo added category: enhancement Category: this is an enhancement of an existing feature. area: python lowering Area: Python lowering related issues. area: dialect python Area: Python statement dialect related issues. area: dialect python types Area: issues related to builtin dialect py.types. labels Apr 3, 2025
@Roger-luo Roger-luo merged commit 040e26a into main Apr 3, 2025
11 checks passed
@Roger-luo Roger-luo deleted the roger/ann-assign branch April 3, 2025 23:15
@Roger-luo Roger-luo added category: breaking change Category: breaking changes or proposed changes to APIs. need docs labels Apr 3, 2025
Roger-luo added a commit that referenced this pull request Apr 5, 2025
Roger-luo added a commit that referenced this pull request Nov 6, 2025
This was removed as part of #344, so I'm not sure if it should be added
back. However, without this change we always get `IList[AnyType]` unless
explicitly specifying the element type in `ilist.New`. This breaks a
bunch of tests (and code, really) in bloqade-circuit. Adding this back
seemed like the much easier change than explicitly setting the
`elem_type` everywhere.

---------

Co-authored-by: Roger-luo <rogerluo.rl18@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: dialect python types Area: issues related to builtin dialect py.types. area: dialect python Area: Python statement dialect related issues. area: python lowering Area: Python lowering related issues. category: breaking change Category: breaking changes or proposed changes to APIs. category: enhancement Category: this is an enhancement of an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow inline type annotations when lowering from Python AST

1 participant