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

ci[cartesian]: mypy warns about unused ignores #1823

Merged
merged 1 commit into from
Jan 27, 2025
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ allow_incomplete_defs = true
allow_untyped_defs = true
follow_imports = 'silent'
module = 'gt4py.cartesian.*'
warn_unused_ignores = false

[[tool.mypy.overrides]]
ignore_errors = true
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/cartesian/backend/cuda_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class CudaBackend(BaseGTBackend, CLIBackendMixin):
}
languages = {"computation": "cuda", "bindings": ["python"]}
storage_info = gt_storage.layout.CUDALayout
PYEXT_GENERATOR_CLASS = CudaExtGenerator # type: ignore
PYEXT_GENERATOR_CLASS = CudaExtGenerator
MODULE_GENERATOR_CLASS = CUDAPyExtModuleGenerator
GT_BACKEND_T = "gpu"

Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/cartesian/backend/dace_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ class DaCeCUDAPyExtModuleGenerator(DaCePyExtModuleGenerator, CUDAPyExtModuleGene

class BaseDaceBackend(BaseGTBackend, CLIBackendMixin):
GT_BACKEND_T = "dace"
PYEXT_GENERATOR_CLASS = DaCeExtGenerator # type: ignore
PYEXT_GENERATOR_CLASS = DaCeExtGenerator

def generate(self) -> Type[StencilObject]:
self.check_options(self.builder.options)
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/cartesian/backend/gtcpp_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def apply(cls, root, *, module_name="stencil", **kwargs) -> str:

class GTBaseBackend(BaseGTBackend, CLIBackendMixin):
options = BaseGTBackend.GT_BACKEND_OPTS
PYEXT_GENERATOR_CLASS = GTExtGenerator # type: ignore
PYEXT_GENERATOR_CLASS = GTExtGenerator

def _generate_extension(self, uses_cuda: bool) -> Tuple[str, str]:
return self.make_extension(stencil_ir=self.builder.gtir, uses_cuda=uses_cuda)
Expand Down
10 changes: 5 additions & 5 deletions src/gt4py/cartesian/gtc/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class GTCPreconditionError(eve.exceptions.EveError, RuntimeError):
message_template = "GTC pass precondition error: [{info}]"

def __init__(self, *, expected: str, **kwargs: Any) -> None:
super().__init__(expected=expected, **kwargs) # type: ignore
super().__init__(expected=expected, **kwargs)


class GTCPostconditionError(eve.exceptions.EveError, RuntimeError):
message_template = "GTC pass postcondition error: [{info}]"

def __init__(self, *, expected: str, **kwargs: Any) -> None:
super().__init__(expected=expected, **kwargs) # type: ignore
super().__init__(expected=expected, **kwargs)


class AssignmentKind(eve.StrEnum):
Expand Down Expand Up @@ -267,7 +267,7 @@ def verify_and_get_common_dtype(
) -> Optional[DataType]:
assert len(exprs) > 0
if all(e.dtype is not DataType.AUTO for e in exprs):
dtypes: List[DataType] = [e.dtype for e in exprs] # type: ignore # guaranteed to be not None
dtypes: List[DataType] = [e.dtype for e in exprs] # guaranteed to be not None
dtype = dtypes[0]
if strict:
if all(dt == dtype for dt in dtypes):
Expand Down Expand Up @@ -908,7 +908,7 @@ def op_to_ufunc(
@functools.lru_cache(maxsize=None)
def typestr_to_data_type(typestr: str) -> DataType:
if not isinstance(typestr, str) or len(typestr) < 3 or not typestr[2:].isnumeric():
return DataType.INVALID # type: ignore
return DataType.INVALID
table = {
("b", 1): DataType.BOOL,
("i", 1): DataType.INT8,
Expand All @@ -919,4 +919,4 @@ def typestr_to_data_type(typestr: str) -> DataType:
("f", 8): DataType.FLOAT64,
}
key = (typestr[1], int(typestr[2:]))
return table.get(key, DataType.INVALID) # type: ignore
return table.get(key, DataType.INVALID)
8 changes: 4 additions & 4 deletions src/gt4py/cartesian/gtc/cuir/cuir.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ class Stmt(common.Stmt):
pass


class Literal(common.Literal, Expr): # type: ignore
class Literal(common.Literal, Expr):
pass


class ScalarAccess(common.ScalarAccess, Expr): # type: ignore
class ScalarAccess(common.ScalarAccess, Expr):
pass


class VariableKOffset(common.VariableKOffset[Expr]):
pass


class FieldAccess(common.FieldAccess[Expr, VariableKOffset], Expr): # type: ignore
class FieldAccess(common.FieldAccess[Expr, VariableKOffset], Expr):
pass


Expand Down Expand Up @@ -113,7 +113,7 @@ class TernaryOp(common.TernaryOp[Expr], Expr):
_dtype_propagation = common.ternary_op_dtype_propagation(strict=True)


class Cast(common.Cast[Expr], Expr): # type: ignore
class Cast(common.Cast[Expr], Expr):
pass


Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/cartesian/gtc/dace/daceir.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ class TernaryOp(common.TernaryOp[Expr], Expr):
_dtype_propagation = common.ternary_op_dtype_propagation(strict=True)


class Cast(common.Cast[Expr], Expr): # type: ignore
class Cast(common.Cast[Expr], Expr):
pass


Expand Down
3 changes: 1 addition & 2 deletions src/gt4py/cartesian/gtc/dace/expansion/daceir_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,7 @@ def visit_HorizontalExecution(
k_interval,
**kwargs: Any,
):
# skip type checking due to https://github.com/python/mypy/issues/5485
extent = global_ctx.library_node.get_extents(node) # type: ignore
extent = global_ctx.library_node.get_extents(node)
decls = [self.visit(decl, **kwargs) for decl in node.declarations]
targets: Set[str] = set()
stmts = [
Expand Down
8 changes: 4 additions & 4 deletions src/gt4py/cartesian/gtc/gtcpp/gtcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ class Offset(common.CartesianOffset):
pass


class Literal(common.Literal, Expr): # type: ignore
class Literal(common.Literal, Expr):
pass


class LocalAccess(common.ScalarAccess, Expr): # type: ignore
class LocalAccess(common.ScalarAccess, Expr):
pass


class VariableKOffset(common.VariableKOffset[Expr]):
pass


class AccessorRef(common.FieldAccess[Expr, VariableKOffset], Expr): # type: ignore
class AccessorRef(common.FieldAccess[Expr, VariableKOffset], Expr):
pass


Expand Down Expand Up @@ -88,7 +88,7 @@ class NativeFuncCall(common.NativeFuncCall[Expr], Expr):
_dtype_propagation = common.native_func_call_dtype_propagation(strict=True)


class Cast(common.Cast[Expr], Expr): # type: ignore
class Cast(common.Cast[Expr], Expr):
pass


Expand Down
8 changes: 4 additions & 4 deletions src/gt4py/cartesian/gtc/gtir.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ class BlockStmt(common.BlockStmt[Stmt], Stmt):
pass


class Literal(common.Literal, Expr): # type: ignore
class Literal(common.Literal, Expr):
pass


class VariableKOffset(common.VariableKOffset[Expr]):
pass


class ScalarAccess(common.ScalarAccess, Expr): # type: ignore
class ScalarAccess(common.ScalarAccess, Expr):
pass


class FieldAccess(common.FieldAccess[Expr, VariableKOffset], Expr): # type: ignore
class FieldAccess(common.FieldAccess[Expr, VariableKOffset], Expr):
pass


Expand Down Expand Up @@ -163,7 +163,7 @@ class TernaryOp(common.TernaryOp[Expr], Expr):
_dtype_propagation = common.ternary_op_dtype_propagation(strict=False)


class Cast(common.Cast[Expr], Expr): # type: ignore
class Cast(common.Cast[Expr], Expr):
pass


Expand Down
8 changes: 4 additions & 4 deletions src/gt4py/cartesian/gtc/oir.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ class Stmt(common.Stmt):
pass


class Literal(common.Literal, Expr): # type: ignore
class Literal(common.Literal, Expr):
pass


class ScalarAccess(common.ScalarAccess, Expr): # type: ignore
class ScalarAccess(common.ScalarAccess, Expr):
pass


class VariableKOffset(common.VariableKOffset[Expr]):
pass


class FieldAccess(common.FieldAccess[Expr, VariableKOffset], Expr): # type: ignore
class FieldAccess(common.FieldAccess[Expr, VariableKOffset], Expr):
pass


Expand Down Expand Up @@ -88,7 +88,7 @@ class TernaryOp(common.TernaryOp[Expr], Expr):
_dtype_propagation = common.ternary_op_dtype_propagation(strict=True)


class Cast(common.Cast[Expr], Expr): # type: ignore
class Cast(common.Cast[Expr], Expr):
pass


Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/cartesian/gtc/passes/gtir_upcaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _upcast_node(target_dtype: DataType, node: Expr) -> Expr:

def _upcast_nodes(*exprs: Expr, upcasting_rule: Callable) -> Iterator[Expr]:
assert all(e.dtype for e in exprs)
dtypes: List[DataType] = [e.dtype for e in exprs] # type: ignore # guaranteed to be not None
dtypes: List[DataType] = [e.dtype for e in exprs] # guaranteed to be not None
target_dtypes = upcasting_rule(*dtypes)
return iter(_upcast_node(target_dtype, arg) for target_dtype, arg in zip(target_dtypes, exprs))

Expand Down
5 changes: 1 addition & 4 deletions src/gt4py/cartesian/stencil_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ def __init__(
frontend: Optional[Type[FrontendType]] = None,
):
self._definition = definition_func
# type ignore explanation: Attribclass generated init not recognized by mypy
self.options = options or BuildOptions( # type: ignore
**self.default_options_dict(definition_func)
)
self.options = options or BuildOptions(**self.default_options_dict(definition_func))
backend = backend or "numpy"
backend = gt4pyc.backend.from_name(backend) if isinstance(backend, str) else backend
if backend is None:
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/cartesian/stencil_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def _normalize_origins(
*((0,) * len(field_info.data_dims)),
)
elif (info_origin := getattr(array_infos.get(name), "origin", None)) is not None:
origin[name] = info_origin # type: ignore
origin[name] = info_origin
else:
origin[name] = (0,) * field_info.ndim

Expand Down
Loading