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

misc: remove unnecessary pyright ignore comments [NFC] #3286

Merged
merged 2 commits into from
Oct 11, 2024
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
4 changes: 2 additions & 2 deletions tests/backend/test_jax_executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_return_annotation_tuple_type():
),
):

@executable # pyright: ignore[reportArgumentType, reportGeneralTypeIssues]
@executable # pyright: ignore[reportArgumentType]
def abs_wrong_tuple_type(a: jax.Array) -> tuple[int]: ... # pyright: ignore[reportUnusedFunction]


Expand All @@ -190,7 +190,7 @@ def test_return_annotation_single():
match="Return annotation is must be jnp.ndarray or a tuple of jnp.ndarray",
):

@executable # pyright: ignore[reportArgumentType, reportGeneralTypeIssues]
@executable # pyright: ignore[reportArgumentType]
def abs_wrong_single_type(a: jax.Array) -> int: ... # pyright: ignore[reportUnusedFunction]


Expand Down
5 changes: 1 addition & 4 deletions tests/dialects/test_riscv_snitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,4 @@ def test_insn_repr(op: RISCVInstruction):
# Limitation of Pyright, see https://github.com/microsoft/pyright/issues/7105
# We are currently stuck on an older version of Pyright, the update is
# tracked in https://github.com/xdslproject/xdsl/issues/2791
assert (
trait.get_insn(op) # pyright: ignore[reportGeneralTypeIssues]
== ground_truth[op.name[13:]]
)
assert trait.get_insn(op) == ground_truth[op.name[13:]]
6 changes: 3 additions & 3 deletions tests/filecheck/frontend/dialects/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_affine_for_IV():
# CHECK: Expected integer constant for loop end, got 'float'.
def test_not_supported_affine_loop_I():
for _ in range(
12.0 # pyright: ignore[reportArgumentType, reportGeneralTypeIssues]
12.0 # pyright: ignore[reportArgumentType]
):
pass
return
Expand All @@ -90,7 +90,7 @@ def test_not_supported_affine_loop_I():
# CHECK: Expected integer constant for loop start, got 'str'.
def test_not_supported_affine_loop_II():
for _ in range(
"boom", # pyright: ignore[reportArgumentType, reportGeneralTypeIssues]
"boom", # pyright: ignore[reportArgumentType]
100,
):
pass
Expand All @@ -108,7 +108,7 @@ def test_not_supported_affine_loop_III():
for _ in range(
0,
100,
1.0, # pyright: ignore[reportArgumentType, reportGeneralTypeIssues]
1.0, # pyright: ignore[reportArgumentType]
):
pass
return
Expand Down
2 changes: 1 addition & 1 deletion tests/irdl/test_declarative_assembly_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_format_and_parse_op():
):

@irdl_op_definition
class FormatAndParseOp(IRDLOperation): # pyright: ignore[reportUnusedClass]
class FormatAndParseOp(IRDLOperation):
name = "test.format_and_parse"

assembly_format = "attr-dict"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def test_parse_block_name():

ctx = MLContext()
parser = Parser(ctx, block_str)
block = parser._parse_block() # pyright: ignore[reportPrivateUsage]
block = parser._parse_block()

assert block.args[0].name_hint == "name"
assert block.args[1].name_hint is None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def test_traits_undefined():
class WrongTraitsType(IRDLOperation):
name = "test.no_traits"

traits = 1 # pyright: ignore[reportGeneralTypeIssues, reportAssignmentType]
traits = 1 # pyright: ignore[reportAssignmentType]


def test_traits_wrong_type():
Expand Down
6 changes: 2 additions & 4 deletions xdsl/dialects/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,8 @@ def print_without_type(self, printer: Printer):
def constr(
cls,
*,
# pyright needs updating, with the new one it works fine
value: AttrConstraint | None = None,
type: GenericAttrConstraint[_IntegerAttrType] = IntegerAttrTypeConstr, # pyright: ignore[reportGeneralTypeIssues]
type: GenericAttrConstraint[_IntegerAttrType] = IntegerAttrTypeConstr,
) -> GenericAttrConstraint[IntegerAttr[_IntegerAttrType]]:
if value is None and type == AnyAttr():
return BaseAttr[IntegerAttr[_IntegerAttrType]](IntegerAttr)
Expand Down Expand Up @@ -1604,8 +1603,7 @@ def constr(
cls,
*,
shape: GenericAttrConstraint[Attribute] | None = None,
# pyright needs updating, with the new one it works fine
element_type: GenericAttrConstraint[_MemRefTypeElement] = AnyAttr(), # pyright: ignore[reportGeneralTypeIssues]
element_type: GenericAttrConstraint[_MemRefTypeElement] = AnyAttr(),
layout: GenericAttrConstraint[Attribute] | None = None,
memory_space: GenericAttrConstraint[Attribute] | None = None,
) -> GenericAttrConstraint[MemRefType[_MemRefTypeElement]]:
Expand Down
3 changes: 1 addition & 2 deletions xdsl/dialects/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def get_element_type(self) -> _StreamTypeElement:
def constr(
cls,
*,
# pyright needs updating, with the new one it works fine
element_type: GenericAttrConstraint[_StreamTypeElement] = AnyAttr(), # pyright: ignore[reportGeneralTypeIssues]
element_type: GenericAttrConstraint[_StreamTypeElement] = AnyAttr(),
) -> GenericAttrConstraint[StreamType[_StreamTypeElement]]:
if element_type == AnyAttr():
return BaseAttr[StreamType[_StreamTypeElement]](StreamType)
Expand Down
48 changes: 24 additions & 24 deletions xdsl/frontend/dialects/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def __add__(
from xdsl.frontend.dialects.arith import addi

return addi(
self, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
self, # pyright: ignore[reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportArgumentType]
)

def __and__(
Expand All @@ -49,8 +49,8 @@ def __and__(
from xdsl.frontend.dialects.arith import andi

return andi(
self, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
self, # pyright: ignore[reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportArgumentType]
)

def __lshift__(
Expand All @@ -59,8 +59,8 @@ def __lshift__(
from xdsl.frontend.dialects.arith import shli

return shli(
self, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
self, # pyright: ignore[reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportArgumentType]
)

def __mul__(
Expand All @@ -69,8 +69,8 @@ def __mul__(
from xdsl.frontend.dialects.arith import muli

return muli(
self, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
self, # pyright: ignore[reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportArgumentType]
)

def __rshift__(
Expand All @@ -79,8 +79,8 @@ def __rshift__(
from xdsl.frontend.dialects.arith import shrsi

return shrsi(
self, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
self, # pyright: ignore[reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportArgumentType]
)

def __sub__(
Expand All @@ -89,8 +89,8 @@ def __sub__(
from xdsl.frontend.dialects.arith import subi

return subi(
self, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportUnknownVariableType, reportArgumentType]
self, # pyright: ignore[reportUnknownVariableType, reportArgumentType]
other, # pyright: ignore[reportArgumentType]
)

def __eq__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand All @@ -99,44 +99,44 @@ def __eq__( # pyright: ignore[reportIncompatibleMethodOverride]
from xdsl.frontend.dialects.arith import cmpi

return cmpi(
self, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
self, # pyright: ignore[reportArgumentType]
other, # pyright: ignore[reportArgumentType]
"eq",
)

def __ge__(self, other: _Integer[_Width, _Signedness]) -> i1:
from xdsl.frontend.dialects.arith import cmpi

return cmpi(
self, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
self, # pyright: ignore[reportArgumentType]
other, # pyright: ignore[reportArgumentType]
"sge",
)

def __gt__(self, other: _Integer[_Width, _Signedness]) -> i1:
from xdsl.frontend.dialects.arith import cmpi

return cmpi(
self, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
self, # pyright: ignore[reportArgumentType]
other, # pyright: ignore[reportArgumentType]
"sgt",
)

def __le__(self, other: _Integer[_Width, _Signedness]) -> i1:
from xdsl.frontend.dialects.arith import cmpi

return cmpi(
self, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
self, # pyright: ignore[reportArgumentType]
other, # pyright: ignore[reportArgumentType]
"sle",
)

def __lt__(self, other: _Integer[_Width, _Signedness]) -> i1:
from xdsl.frontend.dialects.arith import cmpi

return cmpi(
self, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
self, # pyright: ignore[reportArgumentType]
other, # pyright: ignore[reportArgumentType]
"slt",
)

Expand All @@ -146,8 +146,8 @@ def __ne__( # pyright: ignore[reportIncompatibleMethodOverride]
from xdsl.frontend.dialects.arith import cmpi

return cmpi(
self, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
other, # pyright: ignore[reportGeneralTypeIssues, reportArgumentType]
self, # pyright: ignore[reportArgumentType]
other, # pyright: ignore[reportArgumentType]
"ne",
)

Expand Down
2 changes: 1 addition & 1 deletion xdsl/frontend/type_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import (
Any,
TypeAlias,
_GenericAlias, # pyright: ignore[reportPrivateUsage, reportGeneralTypeIssues, reportUnknownVariableType, reportAttributeAccessIssue]
_GenericAlias, # pyright: ignore[reportUnknownVariableType, reportAttributeAccessIssue]
)

import xdsl.dialects.builtin as xdsl_builtin
Expand Down
4 changes: 2 additions & 2 deletions xdsl/irdl/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ def irdl_param_attr_definition(cls: _PAttrTT) -> _PAttrTT:
return runtime_final(
dataclass(frozen=True, init=False)(
type.__new__(
type(cls), # pyright: ignore[reportUnknownArgumentType]
type(cls),
cls.__name__,
(cls,), # pyright: ignore[reportUnknownArgumentType]
(cls,),
{**cls.__dict__, **new_fields},
)
)
Expand Down
2 changes: 1 addition & 1 deletion xdsl/tools/tblgen_to_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def generate_op(self, tblgen_op: TblgenOp, dialect_name: str):
"SizedRegion" in region.superclasses
and region.summary == "region with 1 blocks"
)
match (variadic, single_block): # pyright: ignore[reportMatchNotExhaustive]
match (variadic, single_block):
case (False, False):
fields[name] = "region_def()"
case (False, True):
Expand Down
2 changes: 1 addition & 1 deletion xdsl/transforms/varith_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def match_and_rewrite(self, op: varith.VarithOp, rewriter: PatternRewriter, /):
# instantiate a new varith op of the same type as the old op:
# we can ignore the type error as we know that all VarithOps are instantiated
# with an *arg of their operands
rewriter.replace_matched_op(type(op)(*new_operands)) # pyright: ignore[reportUnknownArgumentType]
rewriter.replace_matched_op(type(op)(*new_operands))

# check all ops that may be erased later:
for old_op in possibly_erased_ops:
Expand Down
Loading