Paddle [Typing][PEP585 Upgrade] PEP 585 标准集合泛型支持升级——Python 3.8 退场前瞻特别任务

kyxcudwk  于 5个月前  发布在  Python
关注(0)|答案(7)|浏览(87)

任务背景

此次任务为 为 Paddle 框架 API 添加类型提示(Type Hints) 以及 Python 版本退场中 Ruff 升级部分的联合企划。

Python 3.8 EOL 在即1,是时候开始考虑 Python 3.8 退场的一些事情了。但是先别急,正式退场还需要一段时间,但我们可以考虑一些现阶段可以做的事情了~

自引入 Ruff 以来,每退场一个旧版本时必做的事情就是调整 target-version 了,我们现在所使用的 target-versionpy38 ,也就是表明我们最低支持的 Python 版本是 3.8。当然,在我们正式退场 3.8 时需要将其调整为 py39

经过简单的测试,我们发现升级 py39 居然有 1000 多个问题需要修复,这么庞大的数量对于我们退场 3.8 来说是有一点小小的阻力的

$ ruff check . --statistics --output-format concise --target-version=py39
691     UP006   [*] non-pep585-annotation
375     UP035   [ ] deprecated-import
3     UP036   [*] outdated-version-block

一般来说,只有真正能退场 3.8 的时候才可以修复这些问题,因为这些问题是 3.9 引入了一些新特性,而 3.8 并不支持……但我们这次的报错是有一些不同的,这里的报错基本都是 PEP 585 的升级问题,即使用类似 listcollections.abc.Sequence 这种标准泛型来替代 typing.Listtyping.Sequence 这种泛型,虽然直接使用仍然会报错,但是 PEP 585 明确提到了,如果使用 PEP 563 (即 from __future__ import annotations ),那么我们是可以在「类型注解语义」下使用这些标准泛型的。而刚好,我们的类型提示本就是将使用 PEP 563 作为规范的一部分的,因此我们完全可以在当前还支持 3.8 的情况下,通过使用 PEP 563,在「类型注解语义」的 case 下,来修复 PEP 585 弃用掉的类型

因此本次希望与大家一起推动 PEP 585 升级,退场掉大部分弃用的 typing 泛型使用

任务目标

让我们来看看具体要怎么做吧~

示例一

from typing import List

def code_block(self, lang: str, block: List[str]):
    ...

修改为

from __future__ import annotations

def code_block(self, lang: str, block: list[str]):
    ...

Note

一定要在文件开头加上 from __future__ import annotations ,否则如上所述,这在 3.8 下会报错的哦~

如果不清楚使用方式, 请搜索仓库中存量的 from __future__ import annotations 来查看使用方法。

示例二

from typing import Sequence

def transpose(
    x: Tensor, perm: Sequence[int], name: str | None = None
) -> Tensor:
    ...

修改为

from __future__ import annotations

from collections.abc import Sequence

def transpose(
    x: Tensor, perm: Sequence[int], name: str | None = None
) -> Tensor:
    ...

示例三

如果需要替换的对象出现在 「非类型注解语义」 的场景下不能进行修改, 如果一个文件所有 case 都处于「非类型注解语义」下,请在本 issue 评论区留言或在提交 PR 时指出即可。

from __future__ import annotations

from collections.abc import Iterable

IterableInt = Iterable[int] # 非类型注解语义,这里运行时会执行
class Foo(Iterable[int]): ... # 非类型注解语义,同样会执行

def foo() -> Iterable[int]: ... # 类型注解语义,PEP 563 下会延迟计算
def foo(input: Iterable[int]): ... # 类型注解语义,PEP 563 下会延迟计算

当然我们大多数类型提示都是在「类型注解语义」下使用的,「非类型注解语义」下使用的很少,所以大多数可以放心替换~

你也可以参考 PR #66941 来查看一个完整的 PR 大概要如何修改

实施步骤

安装 ruff v0.5.0

首先我们需要能够复现这 1000 多个问题,首先就需要自己安装一下 Ruff

目前 paddle 所使用的 ruff 版本为 0.5.0,请使用相同版本确保问题的可复现性:

$ pip install ruff==0.5.0

问题复现

python/paddle/tensor/linalg.py 为例

$ ruff check python/paddle/tensor/linalg.py --target-version=py39
python/paddle/tensor/linalg.py:16:1: UP035 [*] Import from `collections.abc` instead: `Sequence`
|
14 | from __future__ import annotations
15 |
16 | from typing import TYPE_CHECKING, Literal, Sequence, overload
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035
17 |
18 | import numpy as np
|
= help: Import from `collections.abc`

Found 1 error.
[*] 1 fixable with the `--fix` option.

UP035 为错误码,可以参考「示例二」进行修改,也可以在 ruff rules 查找错误码对应的规则。

Note

PEP 585 只对应 UP006UP035 两条 rule,如果遇到 UP036 则直接跳过,当前 Python 3.8 未退场的情况下无法提前修复 UP036

任务列表

序号文件认领人 Github idPR 链接
✅1paddle/fluid/ir_adaptor/translator/op_compat_gen.py✅@enkilee#66965
🟢2paddle/fluid/operators/generator/filters.py🟢@enkilee#66968
🟢3paddle/fluid/operators/generator/parse_utils.py🟢@enkilee#66968
🙋4paddle/fluid/pir/dialect/op_generator/ops_onednn_extra_parser.py🙋@Caogration
🙋5paddle/phi/api/generator/api_base.py🙋@Caogration
🙋6paddle/phi/kernels/fusion/cutlass/memory_efficient_attention/generate_kernels.py🙋@Caogration
🙋7paddle/phi/kernels/fusion/cutlass/memory_efficient_attention/generate_variable_forward_kernels.py🙋@Caogration
🙋8python/paddle/amp/auto_cast.py🙋@Caogration
🙋9python/paddle/amp/debugging.py🙋@Caogration
🙋10python/paddle/audio/backends/backend.py🙋@Caogration
🙋11python/paddle/audio/backends/init_backend.py🙋@Caogration
🙋12python/paddle/audio/backends/wave_backend.py🙋@Caogration
🙋13python/paddle/audio/datasets/dataset.py🙋@Caogration
🙋14python/paddle/audio/datasets/esc50.py🙋@Caogration
🙋15python/paddle/audio/datasets/tess.py🙋@Caogration
🙋16python/paddle/audio/functional/window.py🙋@Caogration
🙋17python/paddle/autograd/autograd.py🙋@Caogration
🙋18python/paddle/autograd/backward_mode.py🙋@Caogration
🙋19python/paddle/autograd/py_layer.py🙋@Caogration
🙋20python/paddle/base/dygraph/base.py🙋@Caogration
🙋21python/paddle/base/framework.py🙋@Caogration
🙋22python/paddle/batch.py🙋@Caogration
🙋23python/paddle/decomposition/recompute.py🙋@Caogration
🙋24python/paddle/distributed/auto_parallel/api.py🙋@Caogration
🙋25python/paddle/distributed/auto_parallel/interface.py🙋@Caogration
🙋26python/paddle/distributed/auto_tuner/recorder.py🙋@Caogration
🙋27python/paddle/distributed/auto_tuner/utils.py🙋@Caogration
🙋28python/paddle/distributed/checkpoint/load_state_dict.py🙋@Caogration
🙋29python/paddle/distributed/checkpoint/metadata.py🙋@Caogration
🙋30python/paddle/distributed/checkpoint/utils.py🙋@Caogration
🙋31python/paddle/distributed/fleet/meta_parallel/pipeline_parallel.py🙋@Caogration
🙋32python/paddle/distributed/parallel.py🙋@Caogration
🙋33python/paddle/distributed/passes/auto_parallel_gradient_merge.py🙋@Caogration
🙋34python/paddle/distributed/passes/auto_parallel_master_grad.py🙋@Caogration
🙋35python/paddle/distribution/bernoulli.py🙋@Caogration
🙋36python/paddle/distribution/beta.py🙋@Caogration
🙋37python/paddle/distribution/categorical.py🙋@Caogration
🙋38python/paddle/distribution/cauchy.py🙋@Caogration
🙋39python/paddle/distribution/dirichlet.py🙋@Caogration
🙋40python/paddle/distribution/distribution.py🙋@Caogration
🙋41python/paddle/distribution/exponential.py🙋@Caogration
🙋42python/paddle/distribution/gamma.py🙋@Caogration
🙋43python/paddle/distribution/geometric.py🙋@Caogration
🙋44python/paddle/distribution/gumbel.py🙋@Caogration
🙋45python/paddle/distribution/independent.py🙋@Caogration
🙋46python/paddle/distribution/laplace.py🙋@Caogration
🙋47python/paddle/distribution/lognormal.py🙋@Caogration
🙋48python/paddle/distribution/normal.py🙋@Caogration
🙋49python/paddle/distribution/transform.py🙋@Caogration
🙋50python/paddle/distribution/transformed_distribution.py🙋@Caogration
🙋51python/paddle/distribution/uniform.py🙋@Fripping
🙋52python/paddle/distribution/variable.py🙋@Fripping
🙋53python/paddle/fft.py🙋@Fripping
🙋54python/paddle/framework/random.py🙋@Fripping
🙋55python/paddle/hapi/callbacks.py🙋@Fripping
🙋56python/paddle/hapi/hub.py🙋@Fripping
🙋57python/paddle/hapi/model.py🙋@Fripping
🙋58python/paddle/hapi/model_summary.py🙋@Fripping
🙋59python/paddle/incubate/asp/asp.py🙋@Fripping
🙋60python/paddle/incubate/autograd/functional.py🙋@Fripping
🙋61python/paddle/incubate/autograd/primapi.py🙋@Fripping
🙋62python/paddle/incubate/autograd/primx.py🙋@Fripping
🙋63python/paddle/incubate/framework/random.py🙋@Fripping
🙋64python/paddle/incubate/nn/attn_bias.py🙋@Fripping
🙋65python/paddle/inference/wrapper.py🙋@Fripping
🙋66python/paddle/io/dataloader/batch_sampler.py🙋@Fripping
🙋67python/paddle/io/dataloader/dataset.py🙋@Fripping
🙋68python/paddle/io/dataloader/sampler.py🙋@Fripping
🙋69python/paddle/io/reader.py🙋@Fripping
🙋70python/paddle/jit/dy2static/ast_utils.py🙋@Fripping
🙋71python/paddle/jit/sot/opcode_translator/executor/dispatcher.py🙋@Fripping
🙋72python/paddle/jit/sot/opcode_translator/executor/executor_cache.py🙋@Fripping
🙋73python/paddle/jit/sot/opcode_translator/executor/function_graph.py🙋@Fripping
🙋74python/paddle/jit/sot/opcode_translator/executor/tracker.py🙋@Fripping
🙋75python/paddle/jit/sot/opcode_translator/executor/variables/iter.py🙋@Fripping
🙋76python/paddle/jit/utils.py🙋@Fripping
🙋77python/paddle/metric/metrics.py🙋@Fripping
🙋78python/paddle/nn/functional/conv.py🙋@Fripping
🙋79python/paddle/nn/functional/flash_attention.py🙋@Fripping
🙋80python/paddle/nn/functional/loss.py🙋@Fripping
🙋81python/paddle/nn/functional/norm.py🙋@Fripping
🙋82python/paddle/nn/functional/pooling.py🙋@Fripping
🙋83python/paddle/nn/initializer/assign.py🙋@Fripping
🙋84python/paddle/nn/layer/container.py🙋@Fripping
🙋85python/paddle/nn/layer/conv.py🙋@Fripping
🙋86python/paddle/nn/layer/layers.py🙋@Fripping
🙋87python/paddle/nn/layer/norm.py🙋@Fripping
🙋88python/paddle/nn/layer/pooling.py🙋@Fripping
🙋89python/paddle/nn/layer/transformer.py🙋@Fripping
🙋90python/paddle/nn/quant/format.py🙋@Fripping
🙋91python/paddle/nn/utils/clip_grad_norm_.py🙋@Fripping
🙋92python/paddle/nn/utils/clip_grad_value_.py🙋@Fripping
🙋93python/paddle/nn/utils/transform_parameters.py🙋@Fripping
🙋94python/paddle/optimizer/adadelta.py🙋@Fripping
🙋95python/paddle/optimizer/adagrad.py🙋@Fripping
🙋96python/paddle/optimizer/adam.py🙋@Fripping
🙋97python/paddle/optimizer/adamax.py🙋@Fripping
🙋98python/paddle/optimizer/adamw.py🙋@Fripping
🙋99python/paddle/optimizer/asgd.py🙋@Fripping
🙋100python/paddle/optimizer/lamb.py🙋@Fripping🙋@Whsjrczr
🙋101python/paddle/optimizer/lbfgs.py🙋@Whsjrczr
🙋102python/paddle/optimizer/lr.py🙋@Whsjrczr
🙋103python/paddle/optimizer/momentum.py🙋@Whsjrczr
🙋104python/paddle/optimizer/nadam.py🙋@Whsjrczr
🙋105python/paddle/optimizer/optimizer.py🙋@Whsjrczr
🙋106python/paddle/optimizer/radam.py🙋@Whsjrczr
🙋107python/paddle/optimizer/rmsprop.py🙋@Whsjrczr
🙋108python/paddle/optimizer/rprop.py🙋@Whsjrczr
🙋109python/paddle/optimizer/sgd.py🙋@Whsjrczr
🙋110python/paddle/profiler/profiler.py🙋@Whsjrczr
🙋111python/paddle/quantization/config.py🙋@Whsjrczr
🙋112python/paddle/reader/decorator.py🙋@Whsjrczr
🙋113python/paddle/sparse/nn/functional/conv.py🙋@Whsjrczr
🙋114python/paddle/sparse/nn/layer/conv.py🙋@Whsjrczr
🙋115python/paddle/sparse/unary.py🙋@Whsjrczr
🙋116python/paddle/tensor/array.py🙋@Whsjrczr
🙋117python/paddle/tensor/creation.py🙋@Whsjrczr
🙋118python/paddle/tensor/einsum.py🙋@Whsjrczr
🙋119python/paddle/tensor/linalg.py🙋@Whsjrczr
🙋120python/paddle/tensor/manipulation.py🙋@Whsjrczr
🙋121python/paddle/tensor/math.py🙋@Whsjrczr
🙋122python/paddle/tensor/stat.py🙋@Whsjrczr
🙋123python/paddle/utils/cpp_extension/cpp_extension.py🙋@Whsjrczr
🙋124python/paddle/vision/datasets/cifar.py🙋@Whsjrczr
🙋125python/paddle/vision/datasets/flowers.py🙋@Whsjrczr
🙋126python/paddle/vision/datasets/folder.py🙋@Whsjrczr
🙋127python/paddle/vision/datasets/mnist.py🙋@Whsjrczr
🙋128python/paddle/vision/datasets/voc2012.py🙋@Whsjrczr
🙋129python/paddle/vision/models/_utils.py🙋@Whsjrczr
✅130python/paddle/vision/ops.py🙋@Whsjrczr✅@SigureMo#66941
🙋131test/auto_parallel/hybrid_strategy/semi_auto_parallel_llama_model.py🙋@Whsjrczr
🙋132test/deprecated/legacy_test/auto_parallel_op_test.py🙋@Whsjrczr
🙋133test/dygraph_to_static/check_approval.py🙋@Whsjrczr
🙋134test/dygraph_to_static/test_dynamic_shape_infermeta.py🙋@Whsjrczr
🙋135test/dygraph_to_static/test_typehint.py🙋@Whsjrczr
🙋136test/dygraph_to_static/test_typing.py🙋@Whsjrczr
🙋137test/ipu/op_test_ipu.py🙋@Whsjrczr
🙋138test/ir/inference/auto_scan_test.py🙋@Whsjrczr
🙋139test/ir/inference/program_config.py🙋@Whsjrczr
🙋140test/ir/inference/test_trt_convert_activation.py🙋@Whsjrczr
🙋141test/ir/inference/test_trt_convert_affine_channel.py🙋@Whsjrczr
🙋142test/ir/inference/test_trt_convert_anchor_generator.py🙋@Whsjrczr
🙋143test/ir/inference/test_trt_convert_arg_max.py🙋@Whsjrczr
🙋144test/ir/inference/test_trt_convert_arg_min.py🙋@Whsjrczr
🙋145test/ir/inference/test_trt_convert_argsort.py🙋@Whsjrczr
🙋146test/ir/inference/test_trt_convert_assign.py🙋@Whsjrczr
🙋147test/ir/inference/test_trt_convert_batch_norm.py🙋@Whsjrczr
🙋148test/ir/inference/test_trt_convert_bilinear_interp_v2.py🙋@Whsjrczr
🙋149test/ir/inference/test_trt_convert_bitwise_and.py🙋@Whsjrczr
🙋150test/ir/inference/test_trt_convert_bitwise_not.py🙋@Whsjrczr
🙋151test/ir/inference/test_trt_convert_bitwise_or.py🙋@BHmingyang
🙋152test/ir/inference/test_trt_convert_bmm.py🙋@BHmingyang
🙋153test/ir/inference/test_trt_convert_cast.py🙋@BHmingyang
🙋154test/ir/inference/test_trt_convert_clip.py🙋@BHmingyang
🙋155test/ir/inference/test_trt_convert_compare_and_logical.py🙋@BHmingyang
🙋156test/ir/inference/test_trt_convert_concat.py🙋@BHmingyang
🙋157test/ir/inference/test_trt_convert_conv2d.py🙋@BHmingyang
🙋158test/ir/inference/test_trt_convert_conv2d_transpose.py🙋@BHmingyang
🙋159test/ir/inference/test_trt_convert_conv3d_transpose.py🙋@BHmingyang
🙋160test/ir/inference/test_trt_convert_cross_multihead_matmul.py🙋@BHmingyang
🙋161test/ir/inference/test_trt_convert_cumsum.py🙋@BHmingyang
🙋162test/ir/inference/test_trt_convert_deformable_conv.py🙋@BHmingyang
🙋163test/ir/inference/test_trt_convert_depthwise_conv2d.py🙋@BHmingyang
🙋164test/ir/inference/test_trt_convert_depthwise_conv2d_transpose.py🙋@BHmingyang
🙋165test/ir/inference/test_trt_convert_dropout.py🙋@BHmingyang
🙋166test/ir/inference/test_trt_convert_einsum.py🙋@BHmingyang
🙋167test/ir/inference/test_trt_convert_elementwise.py🙋@BHmingyang
🙋168test/ir/inference/test_trt_convert_elementwiseadd_transpose.py🙋@BHmingyang
🙋169test/ir/inference/test_trt_convert_emb_eltwise_layernorm.py🙋@BHmingyang
🙋170test/ir/inference/test_trt_convert_equal.py🙋@BHmingyang
🙋171test/ir/inference/test_trt_convert_expand_as_v2.py🙋@BHmingyang
🙋172test/ir/inference/test_trt_convert_expand_v2.py🙋@BHmingyang
🙋173test/ir/inference/test_trt_convert_fill_any_like.py🙋@BHmingyang
🙋174test/ir/inference/test_trt_convert_fill_constant.py🙋@BHmingyang
🙋175test/ir/inference/test_trt_convert_flash_multihead_matmul.py🙋@BHmingyang
🙋176test/ir/inference/test_trt_convert_flatten_contiguous_range.py🙋@BHmingyang
🙋177test/ir/inference/test_trt_convert_flip.py🙋@BHmingyang
🙋178test/ir/inference/test_trt_convert_fused_conv2d_add_act.py🙋@BHmingyang
🙋179test/ir/inference/test_trt_convert_fused_token_prune.py🙋@BHmingyang
🙋180test/ir/inference/test_trt_convert_gather.py🙋@BHmingyang
🙋181test/ir/inference/test_trt_convert_gather_nd.py🙋@BHmingyang
🙋182test/ir/inference/test_trt_convert_gelu.py🙋@BHmingyang
🙋183test/ir/inference/test_trt_convert_grid_sampler.py🙋@BHmingyang
🙋184test/ir/inference/test_trt_convert_group_norm.py🙋@BHmingyang
🙋185test/ir/inference/test_trt_convert_hard_sigmoid.py🙋@BHmingyang
🙋186test/ir/inference/test_trt_convert_hard_swish.py🙋@BHmingyang
🙋187test/ir/inference/test_trt_convert_index_select.py🙋@BHmingyang
🙋188test/ir/inference/test_trt_convert_instance_norm.py🙋@BHmingyang
🙋189test/ir/inference/test_trt_convert_inverse.py🙋@BHmingyang
🙋190test/ir/inference/test_trt_convert_layer_norm.py🙋@BHmingyang
🙋191test/ir/inference/test_trt_convert_leaky_relu.py🙋@BHmingyang
🙋192test/ir/inference/test_trt_convert_lookup_table.py🙋@BHmingyang
🙋193test/ir/inference/test_trt_convert_lookup_table_v2.py🙋@BHmingyang
🙋194test/ir/inference/test_trt_convert_matmul.py🙋@BHmingyang
🙋195test/ir/inference/test_trt_convert_matmul_v2.py🙋@BHmingyang
🙋196test/ir/inference/test_trt_convert_multiclass_nms.py🙋@BHmingyang
🙋197test/ir/inference/test_trt_convert_multiclass_nms3.py🙋@BHmingyang
🙋198test/ir/inference/test_trt_convert_multihead_matmul.py🙋@BHmingyang
🙋199test/ir/inference/test_trt_convert_multihead_matmul_roformer.py🙋@BHmingyang
🙋200test/ir/inference/test_trt_convert_nearest_interp.py🙋@BHmingyang
🚧201test/ir/inference/test_trt_convert_nearest_interp_v2.py🚧@MufanColin#66972
🚧202test/ir/inference/test_trt_convert_one_hot.py🚧@MufanColin#66975
🚧203test/ir/inference/test_trt_convert_p_norm.py🚧@MufanColin#66975
🚧204test/ir/inference/test_trt_convert_pad.py🚧@MufanColin#66975
🚧205test/ir/inference/test_trt_convert_pad3d.py🚧@MufanColin#66975
🚧206test/ir/inference/test_trt_convert_pool2d.py🚧@MufanColin#66975
🙋207test/ir/inference/test_trt_convert_preln_residual_bias.py🙋@MufanColin
🙋208test/ir/inference/test_trt_convert_preln_residual_no_bias.py🙋@MufanColin
🙋209test/ir/inference/test_trt_convert_prelu.py🙋@MufanColin
🙋210test/ir/inference/test_trt_convert_qk_multihead_matmul.py🙋@MufanColin
🙋211test/ir/inference/test_trt_convert_quantize_dequantize_linear.py🙋@MufanColin
🙋212test/ir/inference/test_trt_convert_range.py🙋@MufanColin
🙋213test/ir/inference/test_trt_convert_reduce.py🙋@MufanColin
🙋214test/ir/inference/test_trt_convert_reshape.py🙋@MufanColin
🙋215test/ir/inference/test_trt_convert_rnn.py🙋@MufanColin
🙋216test/ir/inference/test_trt_convert_roi_align.py🙋@MufanColin
🙋217test/ir/inference/test_trt_convert_roll.py🙋@MufanColin
🙋218test/ir/inference/test_trt_convert_scale.py🙋@MufanColin
🙋219test/ir/inference/test_trt_convert_scatter.py🙋@MufanColin
🙋220test/ir/inference/test_trt_convert_scatter_nd_add.py🙋@MufanColin
🙋221test/ir/inference/test_trt_convert_shape.py🙋@MufanColin
🙋222test/ir/inference/test_trt_convert_share_data.py🙋@MufanColin
🙋223test/ir/inference/test_trt_convert_shuffle_channel.py🙋@MufanColin
🙋224test/ir/inference/test_trt_convert_size.py🙋@MufanColin
🙋225test/ir/inference/test_trt_convert_slice.py🙋@MufanColin
🙋226test/ir/inference/test_trt_convert_softmax.py🙋@MufanColin
🙋227test/ir/inference/test_trt_convert_solve.py🙋@MufanColin
🙋228test/ir/inference/test_trt_convert_split.py🙋@MufanColin
🙋229test/ir/inference/test_trt_convert_square.py🙋@MufanColin
🙋230test/ir/inference/test_trt_convert_squeeze2.py🙋@MufanColin
🙋231test/ir/inference/test_trt_convert_stack.py🙋@MufanColin
🙋232test/ir/inference/test_trt_convert_strided_slice.py🙋@MufanColin
🙋233test/ir/inference/test_trt_convert_sum.py🙋@MufanColin
🙋234test/ir/inference/test_trt_convert_swish.py🙋@MufanColin
🙋235test/ir/inference/test_trt_convert_take_along_axis.py🙋@MufanColin
🙋236test/ir/inference/test_trt_convert_temporal_shift.py🙋@MufanColin
🙋237test/ir/inference/test_trt_convert_tile.py🙋@MufanColin
🙋238test/ir/inference/test_trt_convert_top_k.py🙋@MufanColin
🙋239test/ir/inference/test_trt_convert_top_k_v2.py🙋@MufanColin
🙋240test/ir/inference/test_trt_convert_trans_layernorm.py🙋@MufanColin
🙋241test/ir/inference/test_trt_convert_transpose.py🙋@MufanColin
🙋242test/ir/inference/test_trt_convert_unary.py🙋@MufanColin
🙋243test/ir/inference/test_trt_convert_unbind.py🙋@MufanColin
🙋244test/ir/inference/test_trt_convert_unfold.py🙋@MufanColin
🙋245test/ir/inference/test_trt_convert_unsqueeze2.py🙋@MufanColin
🙋246test/ir/inference/test_trt_convert_where.py🙋@MufanColin
🙋247test/ir/inference/test_trt_convert_yolo_box.py🙋@MufanColin
🙋248test/ir/inference/test_trt_convert_yolo_box_head.py🙋@MufanColin
🙋249test/ir/inference/test_trt_float64.py🙋@MufanColin
🙋250test/ir/inference/test_trt_int64.py🙋@MufanColin
🙋251test/ir/inference/test_trt_ops_fp32_mix_precision.py🙋@MufanColin
🙋252test/ir/pir/cinn/llama_test_model.py🙋@MufanColin
🙋253test/legacy_test/auto_parallel_op_test.py🙋@MufanColin
🙋254test/legacy_test/test_gast_with_compatibility.py🙋@MufanColin
🙋255test/legacy_test/test_memory_efficient_attention.py🙋@MufanColin
🙋256test/legacy_test/utils.py🙋@MufanColin
🙋257test/prim/model/bert.py🙋@MufanColin
🙋258test/quantization/test_customized_quanter.py🙋@MufanColin
🙋259test/sot/test_builtin_map.py🙋@MufanColin
🙋260tools/cinn/gen_c++_tutorial.py🙋@MufanColin
✅261tools/sampcd_processor.py✅@SigureMo#66941

任务认领方式

⭐️ 提交PR 模版 ⭐️:

  • // ------- PR 标题 --------
[Typing][PEP585 Upgrade][261] Use stardand collections for type hints in `python/paddle/distribution/beta.py`

或者多个任务:

[Typing][PEP585 Upgrade][1-3] Use stardand collections for type hints in `test/ir/inference/*`

Note

北航同学请注意在任务标题中添加 [BUAA] ,如:

[Typing][PEP585 Upgrade][BUAA][261] Use stardand collections for type hints in `python/paddle/distribution/beta.py`
[Typing][PEP585 Upgrade][BUAA][1-3] Use stardand collections for type hints in `test/ir/inference/*`

⭐️ 认领方式 ⭐️:
请大家以 comment 的形式认领任务,如:

【报名】:1、3、5-7

Note

建议前期先只提 1 个 PR 熟悉流程,如果被 reviewer approve 了,那么后续可以每个 PR 修改 5-10 个文件,避免提交太多 PR, 以避免重复问题。
Warning

单个 PR 提交禁止修改超过 10 个文件, 否则会被 reviewer close。
提交 PR 模版

<!-- TemplateReference: https://github.com/PaddlePaddle/Paddle/wiki/PULL-REQUEST-TEMPLATE--REFERENCE -->
<!-- Demo: https://github.com/PaddlePaddle/Paddle/pull/24810 -->

### PR Category
<!-- One of [ User Experience | Execute Infrastructure | Operator Mechanism | CINN | Custom Device | Performance Optimization | Distributed Strategy | Parameter Server | Communication Library | Auto Parallel | Inference | Environment Adaptation ] -->

User Experience

### PR Types
<!-- One of [ New features | Bug fixes | Improvements | Performance | BC Breaking | Deprecations | Docs | Devs | Not User Facing | Security | Deprecations | Others ] -->

Devs

### Description
<!-- Describe what you’ve done -->

为如下文件添加 PEP 563,并进行 PEP 585 升级:

- xxx.py
- xxx.py

### Related links

- #66936

@gouzil

状态介绍
✅:已经完全迁移,所有单测都OK!
🙋: 报名
🟢:审核完毕待合入,合入之后完成!
🔵:可认领!
🟡:当前阶段不需要人力继续跟进,下阶段推进
🚧:迁移中,单测还没有过,还没有审核完。

大致正常流程为:
🔵 -> 🙋 -> 🚧 -> 🟢 -> ✅

异常流程为:
🔵 -> 🙋 -> 🚧 -> 🟡

看板信息

任务数量🔵可认领🚧迁移中🟢待合入✅完成🟡下阶段推进🏁完成率
261062301.1%

排名不分先后 @enkilee(1) @SigureMo(2)

拓展延伸

感兴趣的同学可以了解下 PEP 649PEP 749 ,看看未来 Python(3.14+)又是使用了什么方案来替代 PEP 563 的~

Footnotes

  1. https://devguide.python.org/versions/
w8biq8rn

w8biq8rn1#

python 3.8 至 python 3.9 类型标注映射表

旧类型新类型
typing.Tupletuple
typing.Listlist
typing.Dictdict
typing.Setset
typing.FrozenSetfrozenset
typing.Typetype
typing.Dequecollections.deque
typing.DefaultDictcollections.defaultdict
typing.OrderedDictcollections.OrderedDict
typing.Countercollections.Counter
typing.ChainMapcollections.ChainMap
typing.Awaitablecollections.abc.Awaitable
typing.Coroutinecollections.abc.Coroutine
typing.AsyncIterablecollections.abc.AsyncIterable
typing.AsyncIteratorcollections.abc.AsyncIterator
typing.AsyncGeneratorcollections.abc.AsyncGenerator
typing.Iterablecollections.abc.Iterable
typing.Iteratorcollections.abc.Iterator
typing.Generatorcollections.abc.Generator
typing.Reversiblecollections.abc.Reversible
typing.Containercollections.abc.Container
typing.Collectioncollections.abc.Collection
typing.Callablecollections.abc.Callable
typing.AbstractSetcollections.abc.Set
typing.MutableSetcollections.abc.MutableSet
typing.Mappingcollections.abc.Mapping
typing.MutableMappingcollections.abc.MutableMapping
typing.Sequencecollections.abc.Sequence
typing.MutableSequencecollections.abc.MutableSequence
typing.MappingViewcollections.abc.MappingView
typing.KeysViewcollections.abc.KeysView
typing.ItemsViewcollections.abc.ItemsView
typing.ValuesViewcollections.abc.ValuesView
typing.ContextManagercontextlib.AbstractContextManager
typing.AsyncContextManagercontextlib.AbstractAsyncContextManager
typing.Patternre.Pattern
typing.re.Patternre.Pattern
typing.Matchre.Match
typing.re.Matchre.Match

关联 #65008 (comment)

bbuxkriu

bbuxkriu3#

【报名】:100-150

zwghvu4y

zwghvu4y4#

【报名】:151-200

js81xvg6

js81xvg65#

【报名】:201-260

zkure5ic

zkure5ic6#

【报名】:51-100

相关问题