CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[CodeStyle][SIM117] Combine multiple with
statements (part1)
#73338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 refactors the code by combining multiple nested with statements into a single, multi-context manager block in order to reduce unnecessary indentation and improve readability. The changes span several test files and utility modules to streamline context management, enhancing overall code maintainability.
Reviewed Changes
Copilot reviewed 108 out of 108 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
test/deprecated/legacy_test/test_entry_attr2_deprecated.py | Combined nested with statements into a single block to reduce indentation. |
test/deprecated/legacy_test/test_dataset_dataloader_deprecated.py | Unified multiple with statements for clearer context management. |
test/deprecated/legacy_test/test_conv3d_layer_deprecated.py | Reduced nesting by combining with statements for unique name guards and program guards. |
test/deprecated/legacy_test/test_conv2d_transpose_layer_deprecated.py | Simplified context management by merging with statements in both base_layer and functional methods. |
test/deprecated/legacy_test/test_conv2d_layer_deprecated.py | Combined nested with statements for improved readability in base_layer and functional methods. |
test/deprecated/ir/inference/test_trt_matmul_quant_dequant_deprecated.py | Refactored with statements to use multi-context blocks for program guards and unique name guards. |
test/deprecated/ir/inference/test_trt_fc_fuse_quant_dequant_pass_deprecated.py | Merged with statements to streamline guard usage for both main and test programs. |
test/deprecated/ir/inference/test_trt_conv_quant_dequant_pass_deprecated.py | Combined with statements to reduce nesting in the setup of program and unique name guards. |
test/deprecated/auto_parallel/auto_parallel_pass_test_base_deprecated.py | Unified with statements for program guard, scope guard, and unique name guard in a single block. |
test/amp/test_amp_o2_embedding_model.py | Merged with statements for unique name and program guards in the AMP model setup. |
test/amp/test_amp_master_weight.py | Combined with statements to simplify context management in the AMP master weight test. |
test/amp/test_amp_list.py | Refactored with statements to group IR guards and program guards, reducing nested block structure. |
test/amp/test_amp_decorate.py | Unified with statements for IR guard and program guard in the AMP decorate test. |
test/amp/test_amp_api.py | Combined with statements to streamline guard usage across different AMP API tests. |
python/paddle/tensorrt/util.py | Refactored with statements by grouping IR guard and program guard for better clarity. |
python/paddle/nn/layer/rnn.py | Merged with statements to combine program_guard and no_grad contexts, improving readability. |
python/paddle/jit/dy2static/utils.py | Combined nested with statements in composed_guard for a cleaner implementation. |
python/paddle/distributed/fleet/recompute/recompute.py | Combined nested with statements to handle AMP auto_cast and RNG state management more succinctly. |
python/paddle/distributed/auto_parallel/static/tuner/rule_based_tuner.py | Streamlined context management by merging with statements for program_guard and name generator switching. |
python/paddle/cinn/compiler/compute_code_generator.py | Consolidated with statements for variable table and loop context management, reducing unnecessary nesting. |
skip-reason: codestyle only |
with
statements (part1)
PR Category
User Experience
PR Types
Improvements
Description
准备引入 Ruff SIM1171,将连续多个
with
语句合并为一个,减少代码缩进层级,此为 part1Tracker
with
statements (part1) #73338Footnotes
https://docs.astral.sh/ruff/rules/multiple-with-statements/ ↩