Skip to content

Enable ruff format preview and replace black/blacken-docs - #21484

Merged
harupy merged 2 commits into
mlflow:masterfrom
harupy:ruff-format-md
Mar 9, 2026
Merged

harupy merged 2 commits into
mlflow:masterfrom
harupy:ruff-format-md

Conversation

@harupy

@harupy harupy commented Mar 9, 2026

Copy link
Copy Markdown
Member

Related Issues/PRs

Relates to astral-sh/ruff#23434, astral-sh/ruff#23574

What changes are proposed in this pull request?

Enable preview = true for [tool.ruff.format] and remove black/blacken-docs dependencies. Ruff's preview formatter now supports formatting Python code blocks in Markdown files, making blacken-docs redundant. Also adds extension = { mdx = "markdown" } so ruff treats .mdx files as Markdown.

How is this PR tested?

  • Existing unit/integration tests
  • Manual tests

Pre-commit hooks pass on all files.

Does this PR require documentation update?

  • No.

Does this PR require updating the MLflow Skills repository?

  • No.

Release Notes

Is this a user-facing change?

  • No.

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

Components

  • area/build: Build and test infrastructure for MLflow

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

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)

🤖 Generated with Claude Code

- Enable `preview = true` in `[tool.ruff.format]` to format Python code
  blocks in Markdown files
- Add `extension = { mdx = "markdown" }` for MDX file support
- Remove `black` and `blacken-docs` dependencies
- Remove `blacken-docs` pre-commit hook (replaced by ruff format)
- Update format pre-commit hook to include md/mdx files

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 9, 2026 03:10
@harupy harupy added the only-latest If applied, only test the latest version of each group in cross-version tests. label Mar 9, 2026
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor
🛠 DevTools 🛠

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/21484/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/21484/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/21484/merge

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@github-actions github-actions Bot added area/build Build and test infrastructure for MLflow rn/none List under Small Changes in Changelogs. size/XL Extra-large PR (500+ LoC) labels Mar 9, 2026
Comment thread pyproject.toml
Comment on lines 292 to 294
[tool.ruff.format]
preview = true
docstring-code-format = true

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Enable preview mode for the formatter to unlock Markdown code block formatting (replaces blacken-docs). See astral-sh/ruff#23434 — as of ruff 0.15.x, *.md is now included by default in file discovery when preview is enabled.

🤖 Generated with Claude

Comment thread pyproject.toml
required-version = "0.15.5"
force-exclude = true
extend-include = ["*.ipynb"]
extension = { mdx = "markdown" }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Map .mdx files to the markdown language so ruff discovers and formats Python code blocks in them automatically. See astral-sh/ruff#23574 for the documented approach.

🤖 Generated with Claude

Comment thread pyproject.toml
Comment on lines 178 to 180
lint = [
"ruff==0.15.5",
"black==23.7.0",
"blacken-docs==1.18.0",
"pre-commit==4.0.1",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed black and blacken-docs — both are now fully replaced by ruff format with preview mode enabled.

🤖 Generated with Claude

Comment thread .pre-commit-config.yaml
entry: uv run --only-group lint dev/format.py
language: system
files: '\.(py|ipynb)$'
files: '\.(py|ipynb|md|mdx)$'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Extended the format hook to cover md and mdx files (previously only py and ipynb). This replaces the removed blacken-docs hook which handled rst|md|mdx. RST is excluded here because ruff does not support RST formatting.

🤖 Generated with Claude

@harupy

harupy commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

Most of the changes in this PR are auto-generated by ruff format with the new preview mode enabled. The only manual changes are in pyproject.toml, .pre-commit-config.yaml, and requirements/lint-requirements.txt.

@harupy harupy added allow-whitespace-only team-review Trigger a team review request labels Mar 9, 2026
@github-actions

github-actions Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Documentation preview for b4916e3 is available at:

Changed Pages (102)
More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

@WeichenXu123 WeichenXu123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@harupy
harupy enabled auto-merge March 9, 2026 05:54
@harupy
harupy disabled auto-merge March 9, 2026 06:12
@harupy
harupy merged commit 19e75d3 into mlflow:master Mar 9, 2026
52 of 54 checks passed
@harupy
harupy deleted the ruff-format-md branch March 9, 2026 06:13
kriscon-db pushed a commit to kriscon-db/mlflow that referenced this pull request Mar 20, 2026
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-whitespace-only area/build Build and test infrastructure for MLflow only-latest If applied, only test the latest version of each group in cross-version tests. rn/none List under Small Changes in Changelogs. size/XL Extra-large PR (500+ LoC) team-review Trigger a team review request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants