CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[CodeStyle][3.8] Replace {**A, **B}
with A | B
(PEP 584)
#72891
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
[CodeStyle][3.8] Replace {**A, **B}
with A | B
(PEP 584)
#72891
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
python/paddle/jit/utils.py
Outdated
**{item: None for item in self if item not in other}, | ||
**{item: None for item in other if item not in self}, | ||
self._data = {item: None for item in self if item not in other} | { | ||
item: None for item in other if item not in self | ||
} |
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.
上面的注释瞅一眼啊,直接删掉注释
test/sot/test_10_build_unpack.py
Outdated
@@ -57,7 +57,7 @@ def build_tuple_unpack_with_call_inner( | |||
|
|||
|
|||
def build_map_unpack(x: dict[str, paddle.Tensor], y: dict[str, paddle.Tensor]): | |||
z = {**x, **y} | |||
z = x | y |
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.
这里不能改啊,不过后面给 dict
支持下 operator.or_
来支持这种 case
test/sot/test_functools.py
Outdated
@@ -74,7 +74,7 @@ def test_reduce_list(self): | |||
def test_reduce_dict(self): | |||
d1 = {"a": 1, "b": 2} | |||
d2 = {"a": 3, "c": 4} | |||
self.assert_results(try_reduce, lambda a, b: {**a, **b}, [d1, d2]) | |||
self.assert_results(try_reduce, lambda a, b: a | b, [d1, d2]) |
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.
这里可以改,因为在转静代码外
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.
啊,这里也不能改,这是个函数,在 try_reduce
里才执行
$A|$B
replace {**$A, **$B}
{**A, **B}
with A | B
{**A, **B}
with A | B
{**A, **B}
with A | B
(PEP 584)
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.
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 updates dictionary merging to use the PEP 584 union operator (A | B
) instead of the older unpack syntax ({**A, **B}
), aligning with the removal of Python 3.8 support.
- Replace
{**A, **B}
patterns withA | B
across tools, tests, and core library code - Remove obsolete comments and conditional unpack workarounds for older Python versions
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tools/sampcd_processor.py | Use ` |
test/prim/model/test_comp_model_simple_net.py | Update feed dict construction to ` |
test/legacy_test/prim_op_test.py | Replace unpacked dicts with union in no_grad_vars |
test/legacy_test/auto_parallel_op_test.py | Use `inputs_dict |
test/deprecated/prim/prim/vjp/static/test_comp_multiply_grad_deprecated.py | Apply union operator in feed dict for deprecated test |
test/deprecated/legacy_test/auto_parallel_op_test.py | Update no_grad_vars dict merge to ` |
python/paddle/jit/utils.py | Remove TODO and switch _data assignment to ` |
python/paddle/jit/sot/opcode_translator/executor/variables/base.py | Change info dict merge to ` |
python/paddle/distributed/fleet/meta_parallel/parallel_layers/pp_layers.py | Use `self.kwargs |
python/paddle/cinn/runtime/utils.py | Merge function scope dicts using ` |
paddle/fluid/primitive/codegen/decomp_vjp_gen.py | Convert list-comprehension dict merges to ` |
paddle/fluid/primitive/codegen/decomp_rule_gen.py | Use `api |
paddle/fluid/pir/dialect/op_generator/api_gen.py | Simplify mapping_name_to_type merge to ` |
Comments suppressed due to low confidence (1)
tools/sampcd_processor.py:380
- The dictionary union operator (
|
) requires Python >= 3.9. Ensure that the project’s minimum Python version is updated accordingly in the CI and documentation.
self.config = XDOCTEST_CONFIG | (config or {})
PR Category
Execute Infrastructure
PR Types
Deprecations
Description
在 python3.8 以上版本,使用 dict union 替代
{**$A, **$B}
写法。python 3.8 已经退场Link: https://peps.python.org/pep-0584/