Skip to content

Conversation

@Time0o
Copy link
Contributor

@Time0o Time0o commented Jan 31, 2026

This adds classmethod support to Python code generation so that we can now write e.g. the following instead of having to create a wrapper function:

@ctx.parse_program
def constant_replace_wrapper(matched_operation: arith.ConstantOp):
    Rewriter.erase_op(matched_operation)

@Time0o Time0o marked this pull request as draft January 31, 2026 16:07
@Time0o Time0o force-pushed the timo/support-classmethods branch from 30556a9 to 3f197df Compare January 31, 2026 16:51
@Time0o Time0o marked this pull request as ready for review January 31, 2026 16:57
@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

❌ Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.15%. Comparing base (a4ee22a) to head (93b0a7c).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
xdsl/frontend/pyast/code_generation.py 90.62% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5595   +/-   ##
=======================================
  Coverage   86.15%   86.15%           
=======================================
  Files         392      393    +1     
  Lines       56271    56333   +62     
  Branches     6485     6496   +11     
=======================================
+ Hits        48478    48535   +57     
- Misses       6261     6264    +3     
- Partials     1532     1534    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Time0o
Copy link
Contributor Author

Time0o commented Jan 31, 2026

@superlopuh How critical is code coverage? I suppose the missing else branch could be covered by trying to call something that is neither a function nor classmethod

@Time0o Time0o force-pushed the timo/support-classmethods branch from 3f197df to 93b0a7c Compare February 1, 2026 11:48
@Time0o Time0o requested a review from superlopuh February 1, 2026 11:49
@superlopuh superlopuh added the frontend Frontends label Feb 2, 2026
Copy link
Member

@superlopuh superlopuh left a comment

Choose a reason for hiding this comment

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

Great! Thank you

@superlopuh superlopuh merged commit d7c990a into xdslproject:main Feb 2, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Frontends

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants