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

Remove unused type:ignore-s #193

Merged
merged 1 commit into from
Nov 29, 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
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def linkcode_resolve(domain, info):
try:
source, line_number = inspect.getsourcelines(_object)
except OSError:
line_number = None # type: ignore
line_number = None

if line_number:
linespec = f"#L{line_number}-L{line_number + len(source) - 1}"
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ python_version = "3.9"
ignore_missing_imports = true
no_implicit_optional = true
check_untyped_defs = true
warn_unused_ignores = true

[tool.pytest.ini_options]
# This will be pytest's future default.
Expand Down
2 changes: 1 addition & 1 deletion src/spox/_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def infer_output_types(self) -> dict[str, Type]:
)
self.func_attrs[name] = attr

self.func_inputs = self.Inputs(**self.func_args) # type: ignore
self.func_inputs = self.Inputs(**self.func_args)
self.func_outputs = self.constructor(self.func_attrs, self.func_inputs)
self.func_graph = _graph.results(**self.func_outputs.get_vars()).with_arguments(
*self.func_args.values()
Expand Down
2 changes: 1 addition & 1 deletion src/spox/_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def to_onnx_model(
"Consider adding an Identity operator if you are just copying arguments."
)

opset_req: list[tuple[str, int]] = list(opsets.items()) # type: ignore
opset_req: list[tuple[str, int]] = list(opsets.items())
function_protos: dict[tuple[str, str], onnx.FunctionProto] = {}
for fun in self._get_build_result().functions:
proto = fun.to_onnx_function(extra_opset_req=opset_req)
Expand Down
2 changes: 1 addition & 1 deletion src/spox/_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def _init_output_vars(self) -> BaseOutputs:
outputs[variadic] = [
Var(self, None, None) for _ in range(self.out_variadic)
]
return self.Outputs(**outputs) # type: ignore
return self.Outputs(**outputs)

@property
def dependencies(self) -> Iterable[Var]:
Expand Down
2 changes: 1 addition & 1 deletion src/spox/_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _get_schemas_versioned(
"""Get a map into a list of schemas for all domain/names."""
return {
domain: {
name: sorted(op_group, key=lambda s: s.since_version) # type: ignore
name: sorted(op_group, key=lambda s: s.since_version)
for name, op_group in _key_groups(domain_group, lambda s: s.name)
}
for domain, domain_group in _key_groups(all_schemas, lambda s: s.domain)
Expand Down
4 changes: 2 additions & 2 deletions src/spox/opset/ai/onnx/ml/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def infer_output_types(self) -> dict[str, Type]:
raise InferenceError("Input `Y` must be of rank 1.")
if len(xt.shape) == 1:
return {"Z": Tensor(xt.dtype, (1, yt.shape[-1]))}
shape = tuple(list(xt.shape[:-1]) + [yt.shape[-1]]) # type: ignore
shape = tuple(list(xt.shape[:-1]) + [yt.shape[-1]])
return {"Z": Tensor(xt.dtype, shape)}

op_type = OpType("ArrayFeatureExtractor", "ai.onnx.ml", 1)
Expand Down Expand Up @@ -132,7 +132,7 @@ def infer_output_types(self) -> dict[str, Type]:
if len(cats1.value) != len(cats2.value):
raise InferenceError("Categories lists have mismatched lengths.")
t = self.inputs.X.unwrap_tensor()
(elem_type,) = {np.int64, np.str_} - {t.dtype.type} # type: ignore
(elem_type,) = {np.int64, np.str_} - {t.dtype.type}
return {"Y": Tensor(elem_type, t.shape)}

op_type = OpType("CategoryMapper", "ai.onnx.ml", 1)
Expand Down
2 changes: 1 addition & 1 deletion tools/generate_opset.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def get_attributes(
name=name,
_member_type=member_type,
constructor_type_hint=constructor_type_hint,
constructor_default=default, # type: ignore
constructor_default=default,
subgraph_solution=subgraph_solutions.get(name),
allow_extra=allow_extra,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ if len(yt.shape) != 1:
raise InferenceError("Input `Y` must be of rank 1.")
if len(xt.shape) == 1:
return {"Z": Tensor(xt.dtype, (1, yt.shape[-1]))}
shape = tuple(list(xt.shape[:-1]) + [yt.shape[-1]]) # type: ignore
shape = tuple(list(xt.shape[:-1]) + [yt.shape[-1]])
return {"Z": Tensor(xt.dtype, shape)}
2 changes: 1 addition & 1 deletion tools/templates/type_inference/categorymapper1.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ if cats1 is None or cats2 is None:
if len(cats1.value) != len(cats2.value):
raise InferenceError("Categories lists have mismatched lengths.")
t = self.inputs.X.unwrap_tensor()
(elem_type,) = {np.int64, np.str_} - {t.dtype.type} # type: ignore
(elem_type,) = {np.int64, np.str_} - {t.dtype.type}
return {"Y": Tensor(elem_type, t.shape)}