Skip to content

Support comma-separated rules in # clint: disable= comments#20651

Merged
harupy merged 3 commits intomasterfrom
copilot/support-multiple-rules-disable-comment
Feb 8, 2026
Merged

Support comma-separated rules in # clint: disable= comments#20651
harupy merged 3 commits intomasterfrom
copilot/support-multiple-rules-disable-comment

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

Related Issues/PRs

N/A

What changes are proposed in this pull request?

The # clint: disable= comment only disabled the first rule when multiple comma-separated rules were specified (e.g., # clint: disable=rule1,rule2 only disabled rule1). The regex pattern captured a single rule name and ignored everything after the first comma.

Changes:

  • Updated DISABLE_COMMENT_REGEX to match comma-separated rule names: ([a-z0-9-]+(?:\s*,\s*[a-z0-9-]+)*)
  • Modified ignore_map() to split captured group on commas and strip whitespace
  • Pattern now consistent with existing NOQA_REGEX implementation

Example:

# All three forms now work correctly:
foo()  # clint: disable=rule-a
foo()  # clint: disable=rule-a,rule-b
foo()  # clint: disable=rule-a, rule-b

How is this PR tested?

  • Existing unit/integration tests (231 tests pass)
  • New unit/integration tests
  • Manual tests

Added 6 unit tests for ignore_map() covering single-rule, multi-rule, spacing variations, and 1 integration test verifying end-to-end linting behavior.

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Updated dev/clint/README.md with comma-separated syntax example.

Does this PR require updating the MLflow Skills repository?

  • No. You can skip the rest of this section.
  • Yes. Please link the corresponding PR or explain how you plan to update it.

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

The # clint: disable= comment now supports comma-separated rule names to disable multiple linter rules on a single line (e.g., # clint: disable=rule-a,rule-b).

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)
Original prompt

Support multiple rules in a single # clint: disable= comment

Created by Claude Code for handoff.

Patch release: No

Summary

Currently # clint: disable=rule1,rule2 only disables rule1 because the regex captures a single rule name. Users must write separate comments or lines to disable multiple rules on one line, which is cumbersome. The # noqa: regex in comments.py already supports comma-separated rules — the # clint: disable= regex should follow the same pattern.

Codebase Analysis

  • dev/clint/src/clint/linter.py:23DISABLE_COMMENT_REGEX = re.compile(r"clint:\s*disable=([a-z0-9-]+)") captures only one rule name. The [a-z0-9-]+ character class excludes commas, so everything after the first comma is silently ignored.
  • dev/clint/src/clint/linter.py:36-43ignore_map() uses m.group(1) to get the single captured rule name and maps it to the line number. This needs to iterate over all comma-separated rules.
  • dev/clint/src/clint/comments.py:12NOQA_REGEX already supports comma-separated rules with the pattern ([A-Z]\d+(?:\s*,\s*[A-Z]\d+)*). This is the pattern to follow.
  • dev/clint/README.md:30-36 — Documentation shows single-rule syntax only; needs updating.

Success Criteria

  • # clint: disable=rule1,rule2 disables both rule1 and rule2 on that line
  • # clint: disable=rule1, rule2 (with spaces) also works
  • Single-rule # clint: disable=rule1 continues to work unchanged
  • Tests cover single-rule, multi-rule, and multi-rule-with-spaces cases
  • README updated to show multi-rule syntax

Implementation Notes

  1. Update the regex in linter.py:23:
# Before
DISABLE_COMMENT_REGEX = re.compile(r"clint:\s*disable=([a-z0-9-]+)")

# After — match comma-separated list of rule names
DISABLE_COMMENT_REGEX = re.compile(r"clint:\s*disable=([a-z0-9-]+(?:\s*,\s*[a-z0-9-]+)*)")
  1. Update ignore_map() in linter.py:36-43 to split the captured group on commas:
if m := DISABLE_COMMENT_REGEX.search(tok.string):
    line = tok.start[0] - 1
    for rule in m.group(1).split(","):
        mapping.setdefault(rule.strip(), set()).add(line)
  1. Add tests — add a test case in the appropriate test file (e.g., alongside the existing test_markdown_link.py disable tests or as a new test_ignore_map unit test) that verifies:

    • # clint: disable=rule-a,rule-b disables both rules
    • # clint: disable=rule-a, rule-b (with whitespace) disables both rules
  2. Update README (dev/clint/README.md) to mention the comma-separated syntax:

foo()  # clint: disable=rule-a,rule-b

PR

Title: Support comma-separated rules in # clint: disable= comments

Body: The # clint: disable= comment currently only supports a single rule name. This change extends the regex and ignore_map() to support comma-separated rules (e.g., # clint: disable=rule-a,rule-b), consistent with how # noqa: already works.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@harupy harupy marked this pull request as ready for review February 8, 2026 15:42
Copilot AI review requested due to automatic review settings February 8, 2026 15:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Copilot AI and others added 2 commits February 8, 2026 15:43
- Updated DISABLE_COMMENT_REGEX to match comma-separated rule names
- Modified ignore_map() to split and process multiple rules
- Added comprehensive tests for single/multi-rule and spacing variants
- Updated README with multi-rule syntax examples
- Fixed lint issues (added return type annotations, removed single-line docstrings)

Co-authored-by: harupy <17039389+harupy@users.noreply.github.com>
Renamed test_ignore_map_mixed_spacing to test_ignore_map_handles_various_spacing_around_commas for better descriptiveness

Co-authored-by: harupy <17039389+harupy@users.noreply.github.com>
Copilot AI changed the title [WIP] Update clint regex to support multiple rules in disable comment Support comma-separated rules in # clint: disable= comments Feb 8, 2026
Copilot AI requested a review from harupy February 8, 2026 15:45
@github-actions github-actions bot added area/build Build and test infrastructure for MLflow rn/feature Mention under Features in Changelogs. labels Feb 8, 2026
@harupy harupy added this pull request to the merge queue Feb 8, 2026
Merged via the queue into master with commit 4b571a6 Feb 8, 2026
49 checks passed
@harupy harupy deleted the copilot/support-multiple-rules-disable-comment branch February 8, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Build and test infrastructure for MLflow rn/feature Mention under Features in Changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants