Skip to content
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

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

Closed
gouzil opened this issue Aug 1, 2024 · 8 comments
Assignees
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/close 已关闭 type/others 其他问题

Comments

@gouzil
Copy link
Member

gouzil commented Aug 1, 2024

任务背景

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

任务认领方式

⭐️ 提交PR 模版 ⭐️:

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

或者多个任务:

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

Note

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

[Typing][PEP585 Upgrade][BUAA][261] Use standard collections for type hints in `python/paddle/distribution/beta.py`
[Typing][PEP585 Upgrade][BUAA][1-3] Use standard 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!
🙋: 报名
🟢:审核完毕待合入,合入之后完成!
🔵:可认领!
🟡:当前阶段不需要人力继续跟进,下阶段推进
🚧:迁移中,单测还没有过,还没有审核完。

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

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

看板信息

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

排名不分先后 @enkilee(3) @Caogration(47) @Fripping(50) @Whsjrczr(49) @SigureMo(2) @BHmingyang(50) @MufanColin(60)

拓展延伸

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

Footnotes

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

@gouzil gouzil added status/new-issue 新建 type/others 其他问题 labels Aug 1, 2024
@SigureMo SigureMo changed the title [Typing][PEP585 Upgrade] PEP 585 标准库泛型支持升级——Python 3.8 退场前瞻任务 [Typing][PEP585 Upgrade] PEP 585 标准集合泛型支持升级——Python 3.8 退场前瞻任务 Aug 1, 2024
@SigureMo SigureMo changed the title [Typing][PEP585 Upgrade] PEP 585 标准集合泛型支持升级——Python 3.8 退场前瞻任务 [Typing][PEP585 Upgrade] PEP 585 标准集合泛型支持升级——Python 3.8 退场前瞻特别任务 Aug 1, 2024
@paddle-bot paddle-bot bot added the PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc label Aug 1, 2024
@megemini
Copy link
Contributor

megemini commented Aug 2, 2024

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

旧类型 新类型
typing.Tuple tuple
typing.List list
typing.Dict dict
typing.Set set
typing.FrozenSet frozenset
typing.Type type
typing.Deque collections.deque
typing.DefaultDict collections.defaultdict
typing.OrderedDict collections.OrderedDict
typing.Counter collections.Counter
typing.ChainMap collections.ChainMap
typing.Awaitable collections.abc.Awaitable
typing.Coroutine collections.abc.Coroutine
typing.AsyncIterable collections.abc.AsyncIterable
typing.AsyncIterator collections.abc.AsyncIterator
typing.AsyncGenerator collections.abc.AsyncGenerator
typing.Iterable collections.abc.Iterable
typing.Iterator collections.abc.Iterator
typing.Generator collections.abc.Generator
typing.Reversible collections.abc.Reversible
typing.Container collections.abc.Container
typing.Collection collections.abc.Collection
typing.Callable collections.abc.Callable
typing.AbstractSet collections.abc.Set
typing.MutableSet collections.abc.MutableSet
typing.Mapping collections.abc.Mapping
typing.MutableMapping collections.abc.MutableMapping
typing.Sequence collections.abc.Sequence
typing.MutableSequence collections.abc.MutableSequence
typing.MappingView collections.abc.MappingView
typing.KeysView collections.abc.KeysView
typing.ItemsView collections.abc.ItemsView
typing.ValuesView collections.abc.ValuesView
typing.ContextManager contextlib.AbstractContextManager
typing.AsyncContextManager contextlib.AbstractAsyncContextManager
typing.Pattern re.Pattern
typing.re.Pattern re.Pattern
typing.Match re.Match
typing.re.Match re.Match

关联 #65008 (comment)

@enkilee
Copy link
Contributor

enkilee commented Aug 2, 2024

【报名】:1

@Whsjrczr
Copy link
Contributor

Whsjrczr commented Aug 2, 2024

【报名】:100-150

@BHmingyang
Copy link
Contributor

BHmingyang commented Aug 2, 2024

【报名】:151-200

@MufanColin
Copy link
Contributor

MufanColin commented Aug 2, 2024

【报名】:201-260

@Fripping
Copy link
Contributor

Fripping commented Aug 2, 2024

【报名】:51-100

@Caogration
Copy link
Contributor

【报名】:4-50

@luotao1
Copy link
Contributor

luotao1 commented Aug 13, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/close 已关闭 type/others 其他问题
Projects
Development

No branches or pull requests

10 participants