Skip to content

style: add autopep8 pre-commit hook and apply PEP 8 formatting fixes#4524

Open
windreamer wants to merge 2 commits intoInternLM:mainfrom
windreamer:style-yapf
Open

style: add autopep8 pre-commit hook and apply PEP 8 formatting fixes#4524
windreamer wants to merge 2 commits intoInternLM:mainfrom
windreamer:style-yapf

Conversation

@windreamer
Copy link
Copy Markdown
Collaborator

@windreamer windreamer commented Apr 14, 2026

Summary

Add autopep8 as a pre-commit formatting hook and apply its auto-fixes across the codebase to enforce consistent PEP 8 style.

Changes

  • Add autopep8 v2.3.2 hook to .pre-commit-config.yaml (runs before the existing Ruff linter)
  • Configure autopep8 in pyproject.toml with max_line_length = 120 and aggressive = 3 to match the project's existing line-length convention

Copilot AI review requested due to automatic review settings April 14, 2026 04:06
Copy link
Copy Markdown
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.

Pull request overview

This PR updates the repository’s Python formatting workflow by adding autopep8 to pre-commit and applying automated style-only formatting fixes across Python source and test files.

Changes:

  • Add autopep8 as a pre-commit hook and configure autopep8 in pyproject.toml (line length 120, aggressive mode).
  • Apply autopep8-driven whitespace/indentation fixes across various modules, kernels, CLI utilities, and tests.
  • Minor formatting cleanup (string concatenation layout, hanging indents, spacing around operators).

Reviewed changes

Copilot reviewed 9 out of 41 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_lmdeploy/test_vl/test_nonhf_chat_template.py Auto-format string literal continuation in test fixture.
tests/pytorch/spec_decode/test_reject_sample.py Auto-format tensor construction indentation.
tests/pytorch/kernel/test_fill_kv_cache.py Auto-format pytest parametrize indentation.
tests/pytorch/engine/test_logits_process.py Auto-format tensor literal indentation.
pyproject.toml Add [tool.autopep8] configuration (line length/aggressive).
lmdeploy/vl/model/xcomposer2.py Spacing tweak inside f-string expression.
lmdeploy/vl/model/llava.py Indentation cleanup in torch.cat call.
lmdeploy/vl/model/interns1_pro.py Remove stray whitespace-only line.
lmdeploy/vl/__init__.py Reformat multi-import block.
lmdeploy/turbomind/turbomind.py Reformat multi-line assert message indentation.
lmdeploy/serve/proxy/proxy.py Reformat json.dump argument indentation.
lmdeploy/serve/core/async_engine.py Indentation cleanup and remove stray blank line.
lmdeploy/pytorch/strategies/ar_spec/model_agent.py Spacing in tensor indexing/slicing expression.
lmdeploy/pytorch/models/qwen3_5.py Reformat long call indentation; remove extra blank line.
lmdeploy/pytorch/models/glm4moe_mtp.py Spacing inside f-string expression.
lmdeploy/pytorch/models/glm4_moe.py Spacing inside f-string expression.
lmdeploy/pytorch/models/deepseek_v2.py Spacing inside f-string expression.
lmdeploy/pytorch/models/deepseek_mtp.py Spacing inside f-string expression.
lmdeploy/pytorch/kernels/cuda/w8a8_triton_kernels.py Indentation adjustment in benchmark config literal.
lmdeploy/pytorch/kernels/cuda/w8a8_fused_moe.py Indentation cleanup in Triton config list.
lmdeploy/pytorch/kernels/cuda/rms_norm.py Replace explicit \ string concatenation with implicit literal concat formatting.
lmdeploy/pytorch/kernels/cuda/fused_moe.py Indentation cleanup in Triton config list.
lmdeploy/pytorch/kernels/cuda/causal_conv1d.py Indentation cleanup for a wrapped argument.
lmdeploy/pytorch/kernels/cuda/blocked_gemm_fp8.py Indentation cleanup for decorator arguments.
lmdeploy/pytorch/kernels/__init__.py Reformat multi-import block.
lmdeploy/pytorch/engine/model_agent/agent.py Remove double-space in assignment.
lmdeploy/pytorch/backends/dlinfer/maca/op_backend.py Indentation cleanup for continued expression.
lmdeploy/profiler.py Spacing around arithmetic operators inside f-strings.
lmdeploy/pipeline.py Expand one-line if to block for readability.
lmdeploy/model.py Indentation cleanup for line-continued f-strings.
lmdeploy/metrics/loggers.py Remove extra spaces in f-string expressions.
lmdeploy/messages.py Indentation cleanup in asserts / continuation lines.
lmdeploy/lite/utils/__init__.py Reformat multi-import block.
lmdeploy/cli/utils.py Reformat asserts/help strings; remove help=\ style.
lmdeploy/api.py Docstring formatting tweak for noqa spacing.
autotest/tools/pipeline/mllm_case.py Spacing inside f-string expression.
autotest/interface/restful/test_restful_generate.py Spacing inside f-string expression.
autotest/interface/restful/test_restful_chat_completions_v1.py Re-indent long string literal continuation.
.pre-commit-config.yaml Add autopep8 pre-commit hook.
.github/scripts/eval_chat_config.py Indentation cleanup in function call.
.github/scripts/action_tools.py Spacing inside f-string expression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .pre-commit-config.yaml
Comment thread pyproject.toml
@windreamer windreamer changed the title style yapf style: add autopep8 pre-commit hook and apply PEP 8 formatting fixes Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants