Skip to content

Commit

Permalink
misc: make VSCode Pylance happy with int type (#1879)
Browse files Browse the repository at this point in the history
Pyright and Pylance are out of sync for some reason, this small
refactoring seems to fix things.
  • Loading branch information
superlopuh authored Dec 17, 2023
1 parent 6f4395f commit c568614
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions xdsl/dialects/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,17 @@ def _get_value_range(int_type: IntegerType) -> tuple[int, int]:
return min_value, max_value

def verify(self) -> None:
if isinstance(int_type := self.type, IntegerType):
min_value, max_value = self._get_value_range(int_type)
if isinstance(int_type := self.type, IndexType):
return

if not (min_value <= self.value.data <= max_value):
raise VerifyException(
f"Integer value {self.value.data} is out of range for "
f"type {self.type} which supports values in the "
f"range [{min_value}, {max_value}]"
)
min_value, max_value = self._get_value_range(int_type)

if not (min_value <= self.value.data <= max_value):
raise VerifyException(
f"Integer value {self.value.data} is out of range for "
f"type {self.type} which supports values in the "
f"range [{min_value}, {max_value}]"
)


AnyIntegerAttr: TypeAlias = IntegerAttr[IntegerType | IndexType]
Expand Down

0 comments on commit c568614

Please sign in to comment.