Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Add shorthand type for types that can be converted to IRDL #3836

Merged
merged 3 commits into from
Feb 10, 2025

Conversation

math-fehr
Copy link
Collaborator

@math-fehr math-fehr commented Feb 5, 2025

Stacked PRs:


core: Add shorthand type for types that can be converted to IRDL

There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

math-fehr added a commit that referenced this pull request Feb 5, 2025
@math-fehr math-fehr changed the base branch from math-fehr/stack/1 to main February 5, 2025 09:11
math-fehr added a commit that referenced this pull request Feb 5, 2025
There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

stack-info: PR: #3836, branch: math-fehr/stack/2
@math-fehr math-fehr changed the base branch from main to math-fehr/stack/1 February 5, 2025 09:12
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.26%. Comparing base (cba173c) to head (e87e139).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3836      +/-   ##
==========================================
- Coverage   91.26%   91.26%   -0.01%     
==========================================
  Files         465      465              
  Lines       57911    57920       +9     
  Branches     5578     5579       +1     
==========================================
+ Hits        52851    52858       +7     
- Misses       3634     3635       +1     
- Partials     1426     1427       +1     

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

@@ -93,7 +93,9 @@ def isa(arg: Any, hint: "TypeForm[_T]") -> TypeGuard[_T]:
from xdsl.irdl import GenericData, irdl_to_attr_constraint

if (origin is not None) and issubclass(origin, GenericData | ParametrizedAttribute):
constraint = irdl_to_attr_constraint(hint)
constraint = irdl_to_attr_constraint(
hint # pyright: ignore[reportArgumentType]
Copy link
Member

Choose a reason for hiding this comment

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

why this? what's the error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

pyright cannot understand that hint is either a GenericData or a ParametrizedAttribute. That's because the typing we deduce for origin doesn't spread to hint.

math-fehr added a commit that referenced this pull request Feb 5, 2025
There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

stack-info: PR: #3836, branch: math-fehr/stack/2
math-fehr added a commit that referenced this pull request Feb 5, 2025
There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

stack-info: PR: #3836, branch: math-fehr/stack/2
@math-fehr math-fehr changed the base branch from math-fehr/stack/1 to main February 5, 2025 09:31
@math-fehr math-fehr changed the base branch from main to math-fehr/stack/1 February 5, 2025 09:32
Copy link
Collaborator

@alexarice alexarice left a comment

Choose a reason for hiding this comment

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

Pyright errors seem to suggest a missing default value on the UnrankedMemrefType (Will need to rebase past Memref -> MemRef (sorry)) generic

xdsl/irdl/attributes.py Show resolved Hide resolved
xdsl/irdl/attributes.py Outdated Show resolved Hide resolved
xdsl/irdl/attributes.py Show resolved Hide resolved
xdsl/irdl/operations.py Outdated Show resolved Hide resolved
math-fehr added a commit that referenced this pull request Feb 6, 2025
There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

stack-info: PR: #3836, branch: math-fehr/stack/2
@math-fehr math-fehr changed the base branch from math-fehr/stack/1 to main February 6, 2025 18:19
@math-fehr math-fehr changed the base branch from main to math-fehr/stack/1 February 6, 2025 18:19
math-fehr added a commit that referenced this pull request Feb 6, 2025
There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

stack-info: PR: #3836, branch: math-fehr/stack/2
math-fehr added a commit that referenced this pull request Feb 6, 2025
There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

stack-info: PR: #3836, branch: math-fehr/stack/2
@math-fehr math-fehr changed the base branch from math-fehr/stack/1 to main February 6, 2025 18:58
@math-fehr math-fehr changed the base branch from main to math-fehr/stack/1 February 6, 2025 18:58
This includes default to AttributeInvT and AttributeCovT.

stack-info: PR: #3835, branch: math-fehr/stack/1
math-fehr added a commit that referenced this pull request Feb 6, 2025
There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

stack-info: PR: #3836, branch: math-fehr/stack/2
@math-fehr math-fehr changed the base branch from math-fehr/stack/1 to main February 6, 2025 19:09
@math-fehr math-fehr changed the base branch from main to math-fehr/stack/1 February 6, 2025 19:09
@math-fehr math-fehr changed the base branch from math-fehr/stack/1 to main February 6, 2025 19:20
@math-fehr math-fehr changed the base branch from main to math-fehr/stack/1 February 6, 2025 19:20
@math-fehr math-fehr mentioned this pull request Feb 6, 2025
There was a lot of inconsistencies in the typing of functions that are
using the type to constraint conversion. Having a shorthand makes this
more explicit.

stack-info: PR: #3836, branch: math-fehr/stack/2
@math-fehr math-fehr changed the base branch from math-fehr/stack/1 to main February 6, 2025 19:23
@math-fehr math-fehr changed the base branch from main to math-fehr/stack/1 February 6, 2025 19:23
@math-fehr math-fehr changed the base branch from math-fehr/stack/1 to main February 10, 2025 17:00
@math-fehr math-fehr merged commit 21f8f17 into main Feb 10, 2025
16 checks passed
@math-fehr math-fehr deleted the math-fehr/stack/2 branch February 10, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants