Skip to content

[Bug] CI lint appears to be not executing correctly #19552

Description

@ConvolutedDog

Before this change (https://github.com/apache/tvm/pull/19535/changes#diff-99b18a9138d30ae5ee7f4f2bc8ebe1e3629024386488d38b9e65bfdcd60226d8L327), CI lint did not report this syntax error:

tests/python/s_tir/meta_schedule/test_meta_schedule_search_strategy.py:327:107: SyntaxError: Expected ':', found newline
    |
327 | def test_meta_schedule_evolutionary_search_skip_invalid_measured_trace()  # pylint: disable = invalid-name
    |                                                                                                           ^
328 |     # Construct an incompatible measured trace: it references block name "other",
329 |     # which doesn't exist in Matmul. Replaying this trace should fail and be skipped.
330 |     wrong_sch = Schedule(OtherBlock)
    |

The following issues are reported locally:

check ASF Header.........................................................Passed
check file types.........................................................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for merge conflicts................................................Passed
check for broken symlinks............................(no files to check)Skipped
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing docs/arch/pass_infra.rst

mixed line ending........................................................Passed
fix requirements.txt.................................(no files to check)Skipped
trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing tests/python/relax/test_frontend_from_exported_program.py
Fixing python/tvm/relax/frontend/tflite/tflite_frontend.py
Fixing python/tvm/relax/frontend/torch/fx_translator.py
Fixing tests/python/relax/test_frontend_tflite.py
Fixing tests/python/relax/test_frontend_onnx.py
Fixing python/tvm/relax/frontend/onnx/onnx_frontend.py
Fixing python/tvm/relax/frontend/nn/core.py

check yaml...............................................................Passed
check toml...............................................................Passed
yamllint.................................................................Passed
taplo-format.............................................................Passed
ruff check...............................................................Failed
- hook id: ruff-check
- exit code: 1
- files were modified by this hook

docs/how_to/tutorials/mix_python_and_tvm_with_pymodule.py:391:43: RUF003 Comment contains ambiguous `` (EN DASH). Did you mean `-` (HYPHEN-MINUS)?
    |
389 | # TIR and Relax functions, and Relax functions can call Python functions. We have already seen:
390 | #
391 | # - Python → TIR via ``call_tir`` (Steps 1–3)
    |                                           ^ RUF003
392 | # - Python → packed function via ``call_dps_packed`` (Step 3)
393 | # - Relax → Python via ``R.call_py_func`` (Step 5)
    |

python/tvm/relax/frontend/nn/core.py:649:101: E501 Line too long (105 > 100)
    |
647 |             raise TypeError(f"ParameterDict keys must be strings, but got {type(key).__name__}")
648 |         if not isinstance(param, Parameter):
649 |             raise TypeError(f"ParameterDict values must be nn.Parameter, but got {type(param).__name__}")
    |                                                                                                     ^^^^^ E501
650 |         self.params[key] = param
    |

python/tvm/relax/frontend/nn/core.py:734:101: E501 Line too long (107 > 100)
    |
732 |     def __setitem__(self, idx: int, param: Parameter) -> None:
733 |         if not isinstance(param, Parameter):
734 |             raise TypeError(f"ParameterList elements must be nn.Parameter, but got {type(param).__name__}")
    |                                                                                                     ^^^^^^^ E501
735 |         self.params[idx] = param
    |

python/tvm/relax/frontend/nn/core.py:743:101: E501 Line too long (107 > 100)
    |
741 |         """Add a parameter to the end of the ParameterList"""
742 |         if not isinstance(param, Parameter):
743 |             raise TypeError(f"ParameterList elements must be nn.Parameter, but got {type(param).__name__}")
    |                                                                                                     ^^^^^^^ E501
744 |         self.params.append(param)
    |

python/tvm/relax/frontend/onnx/onnx_frontend.py:4626:9: F841 Local variable `split_is_scalar` is assigned to but never used
     |
4624 |         input_tensor = inputs[0]
4625 |         input_shape = input_tensor.struct_info.shape
4626 |         split_is_scalar = False
     |         ^^^^^^^^^^^^^^^ F841
4627 |
4628 |         if len(inputs) == 1:
     |
     = help: Remove assignment to unused variable `split_is_scalar`

python/tvm/relax/frontend/onnx/onnx_frontend.py:4643:16: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
     |
4641 |             dim_size = input_shape[axis]
4642 |
4643 |             if isinstance(dim_size, (int, tirx.IntImm)):
     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038
4644 |                 dim_size_int = int(dim_size)
4645 |                 split = math.ceil(dim_size_int / chunk_size)
     |
     = help: Convert to `X | Y`

python/tvm/relax/frontend/tflite/tflite_flexbuffer.py:113:101: E501 Line too long (101 > 100)
    |
111 |             value_bit_width = BitWidth(value_type_packed & 3)
112 |             value_byte_width = 1 << value_bit_width
113 |             value_bytes = self.buffer[end + i * byte_width : end + i * byte_width + value_byte_width]
    |                                                                                                     ^ E501
114 |             if value_type == FlexBufferType.FBT_BOOL:
115 |                 value = bool(value_bytes[0])
    |

python/tvm/relax/frontend/tflite/tflite_frontend.py:568:101: E501 Line too long (102 > 100)
    |
566 |             dims_ndim = int(self.get_tensor_shape(shape_tensor)[0])
567 |             dims_dtype = self.get_tensor_type_str(shape_tensor.tensor.Type())
568 |             dims_expr = self.bb.match_cast(dims_expr, relax.TensorStructInfo([dims_ndim], dims_dtype))
    |                                                                                                     ^^ E501
569 |             dims_expr = self.bb.normalize(relax.op.astype(dims_expr, "int64"))
570 |             shape_dataflow_var = self.bb.emit(relax.op.tensor_to_shape(dims_expr))
    |

python/tvm/relax/frontend/tflite/tflite_frontend.py:906:101: E501 Line too long (109 > 100)
    |
904 |         pooled = self.bb.normalize(_op.reshape(pooled, data_shape))
905 |         denom = relax.op.power(
906 |             relax.op.add(relax.const(bias, in_type), relax.op.multiply(relax.const(alpha, in_type), pooled)),
    |                                                                                                     ^^^^^^^^^ E501
907 |             relax.const(beta, in_type),
908 |         )
    |

python/tvm/relax/frontend/tflite/tflite_frontend.py:999:101: E501 Line too long (105 > 100)
     |
 997 |                     # Keep dynamic scalar RANGE explicit until frontend support is added.
 998 |                     raise tvm.error.OpNotImplemented(
 999 |                         "TFLite RANGE with dynamic scalar inputs is not supported in Relax frontend yet."
     |                                                                                                     ^^^^^ E501
1000 |                     )
1001 |             else:
     |

python/tvm/relax/frontend/tflite/tflite_frontend.py:4488:101: E501 Line too long (101 > 100)
     |
4486 |         output_dtype = self.get_tensor_type_str(output_tensor.tensor.Type())
4487 |
4488 |         # topi.matrix_set_diag(input, diagonal, k1, k2, super_diag_right_align, sub_diag_right_align)
     |                                                                                                     ^ E501
4489 |         # TFLite MATRIX_SET_DIAG only sets the main diagonal, so k1=0, k2=0
4490 |         out = relax.op.call_dps_packed(
     |

python/tvm/relax/frontend/tflite/tflite_frontend.py:4492:101: E501 Line too long (112 > 100)
     |
4490 |         out = relax.op.call_dps_packed(
4491 |             "topi.matrix_set_diag",
4492 |             (input_expr, diagonal_expr, relax.const(0), relax.const(0), relax.const(False), relax.const(False)),
     |                                                                                                     ^^^^^^^^^^^^ E501
4493 |             out_sinfo=relax.TensorStructInfo(output_shape, output_dtype),
4494 |         )
     |

python/tvm/relax/frontend/tflite/tflite_frontend.py:4520:101: E501 Line too long (101 > 100)
     |
4518 |         zeros_expr = relax.op.zeros(output_shape, output_dtype)
4519 |
4520 |         # topi.matrix_set_diag(input, diagonal, k1, k2, super_diag_right_align, sub_diag_right_align)
     |                                                                                                     ^ E501
4521 |         # TFLite MATRIX_DIAG only sets the main diagonal, so k1=0, k2=0
4522 |         out = relax.op.call_dps_packed(
     |

python/tvm/relax/frontend/tflite/tflite_frontend.py:4524:101: E501 Line too long (112 > 100)
     |
4522 |         out = relax.op.call_dps_packed(
4523 |             "topi.matrix_set_diag",
4524 |             (zeros_expr, diagonal_expr, relax.const(0), relax.const(0), relax.const(False), relax.const(False)),
     |                                                                                                     ^^^^^^^^^^^^ E501
4525 |             out_sinfo=relax.TensorStructInfo(output_shape, output_dtype),
4526 |         )
     |

python/tvm/relax/frontend/torch/base_fx_graph_translator.py:1701:14: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
     |
1699 |         elif isinstance(dim, int):
1700 |             axes = [dim]
1701 |         elif isinstance(dim, (list, tuple)) and all(isinstance(a, int) for a in dim):
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038
1702 |             axes = list(dim)
1703 |         else:
     |
     = help: Convert to `X | Y`

python/tvm/relax/op/nn/nn.py:590:101: E501 Line too long (110 > 100)
    |
588 |     --------
589 |     conv3d : Forward 3D convolution (default ``OIDHW`` weights vs. ``IODHW`` here).
590 |     conv2d_transpose : 2D analogue; legalization supports the same TOPI subset (canonical layout, dilation 1).
    |                                                                                                     ^^^^^^^^^^ E501
591 |
592 |     Returns
    |

python/tvm/relax/transform/legalize_ops/image.py:60:16: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
   |
58 | def _image_affine_grid(bb: BlockBuilder, call: Call) -> Expr:
59 |     for v in call.args[1].values:
60 |         if not isinstance(v, (int, tirx.IntImm)):
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038
61 |             raise ValueError(
62 |                 "affine_grid legalization requires static target_shape, "
   |
   = help: Convert to `X | Y`

python/tvm/relax/transform/legalize_ops/nn.py:225:101: E501 Line too long (103 > 100)
    |
223 | @register_legalize("relax.nn.conv3d_transpose")
224 | def _nn_conv3d_transpose(bb: BlockBuilder, call: Call) -> Expr:
225 |     # Keep policy in sync with _nn_conv2d_transpose: only lower when TOPI supports the layout/dilation.
    |                                                                                                     ^^^ E501
226 |     if call.attrs.out_layout != call.attrs.data_layout:
227 |         logging.info(
    |

python/tvm/s_tir/meta_schedule/relax_integration.py:466:20: RUF005 Consider iterable unpacking instead of concatenation
    |
464 |       @tvm.transform.module_pass(opt_level=3)
465 |       def _ms_pipeline(mod: tvm.ir.IRModule, _ctx: tvm.transform.PassContext) -> tvm.ir.IRModule:
466 |           fuse_seq = dispatch_passes + [
    |  ____________________^
467 | |             relax.transform.LegalizeOps(enable_warning=enable_warning),
468 | |             relax.transform.AnnotateTIROpPattern(),
469 | |             relax.transform.FoldConstant(),
470 | |             relax.transform.FuseOps(),
471 | |             relax.transform.FuseTIR(),
472 | |         ]
    | |_________^ RUF005
473 |           mod = tvm.transform.Sequential(fuse_seq)(mod)
474 |           mod = MetaScheduleApplyDatabase(enable_warning=enable_warning)(mod)
    |
    = help: Replace with iterable unpacking

python/tvm/topi/vision/multibox_transform_loc.py:77:9: E741 Ambiguous variable name: `l`
   |
76 |     def decode_bbox(b, a, k):
77 |         l = anchor[0, a, 0]
   |         ^ E741
78 |         t = anchor[0, a, 1]
79 |         r = anchor[0, a, 2]
   |

python/tvm/topi/vision/nms.py:555:8: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
    |
553 |     if isinstance(max_output_size, int):
554 |         max_output_size = tvm.tirx.const(max_output_size, dtype="int32")
555 |     if isinstance(iou_threshold, (float, int)):
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038
556 |         iou_threshold = tvm.tirx.const(iou_threshold, dtype=data.dtype)
    |
    = help: Convert to `X | Y`

python/tvm/topi/vision/nms_util.py:311:12: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
    |
309 |             selected_scores = T.buffer_proxy(selected_scores)
310 |
311 |         if isinstance(iou_threshold, (float, int)):
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038
312 |             iou_threshold = tvm.tirx.FloatImm("float32", float(iou_threshold))
313 |         elif isinstance(iou_threshold, te.Tensor):
    |
    = help: Convert to `X | Y`

tests/python/relax/test_frontend_from_exported_program.py:7407:30: E741 Ambiguous variable name: `l`
     |
7405 | def test_index_put_with_tuple_output():
7406 |     class IndexPutTupleOutput(Module):
7407 |         def forward(self, x, l, idx):
     |                              ^ E741
7408 |             values = x
7409 |             l[..., idx, idx] = values
     |

tests/python/relax/test_frontend_from_exported_program.py:7437:13: E741 Ambiguous variable name: `l`
     |
7435 |         def forward(self, x):
7436 |             b, k, n = 2, 3, 5
7437 |             l = x.new_zeros(b, k, n, n)
     |             ^ E741
7438 |             idx = torch.arange(n, device=x.device)
     |

tests/python/relax/test_frontend_from_exported_program.py:7461:48: RUF003 Comment contains ambiguous `×` (MULTIPLICATION SIGN). Did you mean `x` (LATIN SMALL LETTER X)?
     |
7459 |     # x: (2, 3, 5) → x[..., :1]: (2, 3, 1)
7460 |     assert any(len(f.shape) == 3 and int(f.shape[-1]) == 1 for f in tensor_fields)
7461 |     # l: (2, 3, 5, 5) → 4-D with spatial dims 5×5
     |                                                ^ RUF003
7462 |     assert any(
7463 |         len(f.shape) == 4 and int(f.shape[-2]) == 5 and int(f.shape[-1]) == 5
     |

tests/python/relax/test_frontend_tflite.py:3385:5: F811 Redefinition of unused `test_prelu` from line 738
     |
3383 |     ],
3384 | )
3385 | def test_prelu(shared_axes):
     |     ^^^^^^^^^^ F811
3386 |     inputs = tf.keras.Input(shape=(4, 4, 3), batch_size=1, dtype=tf.float32)
3387 |     prelu_kwargs = {
     |
     = help: Remove definition: `test_prelu`

tests/python/s_tir/meta_schedule/test_meta_schedule_search_strategy.py:327:107: SyntaxError: Expected ':', found newline
    |
327 | def test_meta_schedule_evolutionary_search_skip_invalid_measured_trace()  # pylint: disable = invalid-name
    |                                                                                                           ^
328 |     # Construct an incompatible measured trace: it references block name "other",
329 |     # which doesn't exist in Matmul. Replaying this trace should fail and be skipped.
330 |     wrong_sch = Schedule(OtherBlock)
    |

Found 48 errors (21 fixed, 27 remaining).
No fixes available (7 hidden fixes can be enabled with the `--unsafe-fixes` option).

ruff format..............................................................Failed
- hook id: ruff-format
- exit code: 2
- files were modified by this hook

error: Failed to parse tests/python/s_tir/meta_schedule/test_meta_schedule_search_strategy.py:327:107: Expected ':', found newline
28 files reformatted, 1377 files left unchanged

clang-format.............................................................Failed
- hook id: clang-format
- files were modified by this hook
cython-lint..........................................(no files to check)Skipped
double-quote Cython strings..........................(no files to check)Skipped

Environment

TVM: main branch
Python: v3.10.12
pre_commit: v4.6.0

Steps to reproduce

pre-commit run --all-files

Triage

Please refer to the list of label tags here to find the relevant tags and add them below in a bullet format (example below).

  • needs-triage

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions