style: add autopep8 pre-commit hook and apply PEP 8 formatting fixes#4524
Open
windreamer wants to merge 2 commits intoInternLM:mainfrom
Open
style: add autopep8 pre-commit hook and apply PEP 8 formatting fixes#4524windreamer wants to merge 2 commits intoInternLM:mainfrom
windreamer wants to merge 2 commits intoInternLM:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add autopep8 as a pre-commit formatting hook and apply its auto-fixes across the codebase to enforce consistent PEP 8 style.
Changes
autopep8 v2.3.2hook to.pre-commit-config.yaml(runs before the existing Ruff linter)autopep8in pyproject.tomlwithmax_line_length = 120andaggressive = 3to match the project's existing line-length convention