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

pip prod(deps): bump pyright from 1.1.335 to 1.1.336 #1796

Merged
merged 9 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ textual-dev==1.2.1
pytest-asyncio==0.21.1
# pyright version has to be fixed with `==`. The CI parses this file
# and installs the according version for typechecking.
pyright==1.1.335
pyright==1.1.337
-e .[extras]
36 changes: 22 additions & 14 deletions xdsl/dialects/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
overload,
)

from typing_extensions import Self
from typing_extensions import Self, assert_never

from xdsl.ir import (
Attribute,
Expand Down Expand Up @@ -417,20 +417,28 @@ def from_int_and_width(value: int, width: int) -> IntegerAttr[IntegerType]:
def from_index_int_value(value: int) -> IntegerAttr[IndexType]:
return IntegerAttr(value, IndexType())

@staticmethod
def _get_value_range(int_type: IntegerType) -> tuple[int, int]:
signedness = int_type.signedness.data
width = int_type.width.data

if signedness == Signedness.SIGNLESS:
min_value = -(1 << width)
max_value = 1 << width
elif signedness == Signedness.SIGNED:
min_value = -(1 << (width - 1))
max_value = (1 << (width - 1)) - 1
elif signedness == Signedness.UNSIGNED:
min_value = 0
max_value = (1 << width) - 1
else:
assert_never(signedness)

return min_value, max_value

def verify(self) -> None:
if isinstance(self.type, IntegerType):
match self.type.signedness.data:
case Signedness.SIGNLESS:
min_value = -(1 << self.type.width.data)
max_value = 1 << self.type.width.data
case Signedness.SIGNED:
min_value = -(1 << (self.type.width.data - 1))
max_value = (1 << (self.type.width.data - 1)) - 1
case Signedness.UNSIGNED:
min_value = 0
max_value = (1 << self.type.width.data) - 1
case _:
assert False, "unreachable"
if isinstance(int_type := self.type, IntegerType):
min_value, max_value = self._get_value_range(int_type)

if not (min_value <= self.value.data <= max_value):
raise VerifyException(
Expand Down
13 changes: 7 additions & 6 deletions xdsl/ir/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,19 @@ def print_parameters(self, printer: Printer) -> None:
"""Print the attribute parameters."""
printer.print_paramattr_parameters(self.parameters)

def _verify(self):
# Verifier generated by irdl_attr_def
attr_def = type(self).irdl_definition
attr_def.verify(self)
super()._verify()

@classmethod
@property
def irdl_definition(cls) -> ParamAttrDef:
"""Get the IRDL attribute definition."""
...

def _verify(self):
# Verifier generated by irdl_attr_def
t: type[ParametrizedAttribute] = type(self)
attr_def = t.irdl_definition
attr_def.verify(self)
super()._verify()


@dataclass(init=False)
class IRNode(ABC):
Expand Down
5 changes: 1 addition & 4 deletions xdsl/irdl/irdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1947,10 +1947,7 @@ def fun(self: Any, idx: int = arg_idx, previous_vars: int = previous_variadics):
)


TypeIRDLOperationInvT = TypeVar("TypeIRDLOperationInvT", bound=type[IRDLOperation])


def irdl_op_definition(cls: TypeIRDLOperationInvT) -> TypeIRDLOperationInvT:
def irdl_op_definition(cls: type[IRDLOperationInvT]) -> type[IRDLOperationInvT]:
"""Decorator used on classes to define a new operation definition."""

assert issubclass(
Expand Down