Skip to content

Commit

Permalink
core: make all constr methods classmethods (#3826)
Browse files Browse the repository at this point in the history
Makes every constr method (found with ripgrep `def\ constr`) a
classmethod instead of a staticmethod. This is in preparation for adding
a default `constr` method to `Attribute`.
  • Loading branch information
alexarice authored Feb 4, 2025
1 parent a345d2a commit df20509
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/irdl/test_declarative_assembly_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2364,8 +2364,9 @@ class ParamOne(ParametrizedAttribute, TypeAttribute, Generic[_T]):
p: ParameterDef[_T]
q: ParameterDef[Attribute]

@staticmethod
@classmethod
def constr(
cls,
*,
n: GenericAttrConstraint[Attribute] | None = None,
p: GenericAttrConstraint[_ConstrT] | None = None,
Expand Down Expand Up @@ -2409,8 +2410,9 @@ class ParamOne(ParametrizedAttribute, TypeAttribute, Generic[_T]):
name = "test.param_one"
p: ParameterDef[_T]

@staticmethod
@classmethod
def constr(
cls,
*,
p: GenericAttrConstraint[_ConstrT] | None = None,
) -> BaseAttr[ParamOne[Attribute]] | ParamAttrConstraint[ParamOne[_ConstrT]]:
Expand Down
6 changes: 4 additions & 2 deletions xdsl/dialects/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,9 @@ def print_without_type(self, printer: Printer):
def get_type(self) -> Attribute:
return self.type

@staticmethod
@classmethod
def constr(
cls,
*,
value: AttrConstraint | None = None,
type: GenericAttrConstraint[_IntegerAttrTypeConstrT] = IntegerAttrTypeConstr,
Expand Down Expand Up @@ -1952,8 +1953,9 @@ def get_strides(self) -> Sequence[int | None] | None:
case _:
return self.layout.get_strides()

@staticmethod
@classmethod
def constr(
cls,
*,
shape: GenericAttrConstraint[Attribute] | None = None,
element_type: GenericAttrConstraint[_MemRefTypeElementConstrT] = AnyAttr(),
Expand Down

0 comments on commit df20509

Please sign in to comment.