diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e916caff91064a108c7093b4557e5a9b8e82f5e4..bd09715e0a7077e140c78dceb1fc8bae39de4582 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ exclude: | paddle/fluid/framework/fleet/heter_ps/cudf/.+| paddle/fluid/distributed/ps/thirdparty/round_robin.h| python/paddle/utils/gast/.+| - .+_py2\.py| + .+_pb2\.py| python/paddle/fluid/tests/unittests/npu/.+| python/paddle/fluid/tests/unittests/mlu/.+ )$ diff --git a/python/paddle/distributed/fleet/utils/http_server.py b/python/paddle/distributed/fleet/utils/http_server.py index 4caab0efaa536e5aaf04e6710480e8373610111e..c284e9779df93b8e64c5291a3d0d676d43686055 100644 --- a/python/paddle/distributed/fleet/utils/http_server.py +++ b/python/paddle/distributed/fleet/utils/http_server.py @@ -16,8 +16,6 @@ import http.server as SimpleHTTPServer import logging import threading - -# NOTE: HTTPServer has a different name in python2 and python3 from http.server import HTTPServer __all__ = [] diff --git a/python/paddle/fluid/dataloader/dataloader_iter.py b/python/paddle/fluid/dataloader/dataloader_iter.py index e47d75326b357fdccced84c9d3bffdfdf17ba068..620bd5137815b5db5bcd5b8cfba8261699f7e91a 100644 --- a/python/paddle/fluid/dataloader/dataloader_iter.py +++ b/python/paddle/fluid/dataloader/dataloader_iter.py @@ -28,7 +28,6 @@ from paddle.fluid.framework import ( set_flags, ) -# NOTE: queue has a different name in python2 and python3 import queue import paddle diff --git a/python/paddle/fluid/dataloader/worker.py b/python/paddle/fluid/dataloader/worker.py index 64ec697cf5308ec7d4218d41ad5ea295c6d87696..e63a5d5f9344142626cf6f8093e509183b92d732 100644 --- a/python/paddle/fluid/dataloader/worker.py +++ b/python/paddle/fluid/dataloader/worker.py @@ -28,7 +28,6 @@ from ..multiprocess_utils import ( from ..framework import _non_static_mode, _in_eager_without_dygraph_check from .flat import _flatten_batch -# NOTE: queue has a different name in python2 and python3 import queue __all__ = ['get_worker_info'] diff --git a/python/paddle/fluid/dygraph/checkpoint.py b/python/paddle/fluid/dygraph/checkpoint.py index 8103f1f82bbe5790a465773e7fc339fe56716cd6..2078f0fcf0491f68af0e288ec1714b2690bb4fa8 100644 --- a/python/paddle/fluid/dygraph/checkpoint.py +++ b/python/paddle/fluid/dygraph/checkpoint.py @@ -248,7 +248,6 @@ def load_dygraph(model_path, **configs): ) # 2. load layer parameters & buffers - # NOTE: using fluid.dygraph.guard() here will cause import error in py2 with guard(): persistable_var_dict = _construct_params_and_buffers( model_prefix, diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 4f56306e5e38e0389bbe529b944326480df461e4..383cf6eb61a24d9c845fe6cc346b7467ea92924a 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -1290,7 +1290,7 @@ def _varbase_creator( shape=None, dtype=None, persistable=None, - **kwargs + **kwargs, ): if dtype is not None: if not isinstance(dtype, core.VarDesc.VarType): @@ -1412,7 +1412,7 @@ class Variable(metaclass=VariableMetaClass): is_data=False, need_check_feed=False, belong_to_optimizer=False, - **kwargs + **kwargs, ): self.block = block if name is None: @@ -2953,11 +2953,8 @@ class Operator: in_arg_names.append(arg.name) else: raise TypeError( - "The type of '%s' in operator %s should be " - "one of [basestring(), str, Varibale] in python2, " - "or one of [str, bytes, Variable] in python3." - "but received : %s" - % (in_proto.name, type, arg) + f"The type of '%{in_proto.name}' in operator {type} should be " + f"one of [str, bytes, Variable]. but received : {arg}" ) self.desc.set_input(in_proto.name, in_arg_names) else: @@ -6887,7 +6884,7 @@ class Parameter(Variable, metaclass=ParameterMetaClass): shape, dtype, type=core.VarDesc.VarType.LOD_TENSOR, - **kwargs + **kwargs, ): if shape is None: raise ValueError("The shape of Parameter should not be None") @@ -6908,7 +6905,7 @@ class Parameter(Variable, metaclass=ParameterMetaClass): shape=shape, dtype=dtype, type=type, - **kwargs + **kwargs, ) self.trainable = kwargs.get('trainable', True) diff --git a/python/paddle/fluid/incubate/fleet/utils/http_server.py b/python/paddle/fluid/incubate/fleet/utils/http_server.py index 79b436ff40c8323de4bfe29324ab3b7de94a25ff..4da8afcaaebaee984bd299d3a7e338737722490e 100644 --- a/python/paddle/fluid/incubate/fleet/utils/http_server.py +++ b/python/paddle/fluid/incubate/fleet/utils/http_server.py @@ -15,7 +15,6 @@ import logging -# NOTE: HTTPServer has a different name in python2 and python3 from http.server import HTTPServer import http.server as SimpleHTTPServer import time diff --git a/python/paddle/fluid/multiprocess_utils.py b/python/paddle/fluid/multiprocess_utils.py index deca95457e61c87b1495e33c50ac2c59aed91db1..bc7d58d1284f1ffc7cb93bf16920f7404b935707 100644 --- a/python/paddle/fluid/multiprocess_utils.py +++ b/python/paddle/fluid/multiprocess_utils.py @@ -18,7 +18,6 @@ import atexit from . import core -# NOTE: queue has a different name in python2 and python3 import queue # multi-process worker check indices queue interval, avoid diff --git a/python/paddle/fluid/reader.py b/python/paddle/fluid/reader.py index 104ac8d864fb3bedd77d8f3c8d0a3adc421c4aca..90e5f71b4f0730411a765a031c33f0f37732a0f1 100644 --- a/python/paddle/fluid/reader.py +++ b/python/paddle/fluid/reader.py @@ -64,7 +64,6 @@ import os import multiprocessing import signal -# NOTE: queue has a different name in python2 and python3 import queue # NOTE: [ avoid hanging & failed quickly ] These value is used in getting data from another process diff --git a/tools/sampcd_processor.py b/tools/sampcd_processor.py index 742cb3f7c78caea3055aedf0802de41723ffe40c..fb09e4e258027794da8138dc53d6b8724ed83716 100644 --- a/tools/sampcd_processor.py +++ b/tools/sampcd_processor.py @@ -16,7 +16,7 @@ please make sure to run in the tools path usage: python sample_test.py {cpu or gpu} {cpu or gpu}: running in cpu version or gpu version -for example, you can run cpu version python2 testing like this: +for example, you can run cpu version testing like this: python sampcd_processor.py cpu diff --git a/tools/test_print_signatures.py b/tools/test_print_signatures.py index 0c3e17c7fa729ded6343e3682648fd84fb88bca2..92ca9deedd979ced7ec4fa73c0715e08758f0ad6 100644 --- a/tools/test_print_signatures.py +++ b/tools/test_print_signatures.py @@ -67,9 +67,7 @@ class Test_is_primitive(unittest.TestCase): self.assertTrue(is_primitive(2)) self.assertTrue(is_primitive(2.1)) self.assertTrue(is_primitive("2.1.1")) - self.assertFalse( - is_primitive("hello paddle".encode('UTF-8')) - ) # True for python2 + self.assertFalse(is_primitive("hello paddle".encode('UTF-8'))) self.assertFalse(is_primitive(1j)) self.assertTrue(is_primitive(True)) @@ -80,7 +78,7 @@ class Test_is_primitive(unittest.TestCase): self.assertTrue(is_primitive([1, 2])) self.assertTrue(is_primitive((1.1, 2.2))) self.assertTrue(is_primitive(set([1, 2.3]))) - self.assertFalse(is_primitive(range(3))) # True for python2 + self.assertFalse(is_primitive(range(3))) self.assertFalse(is_primitive({})) self.assertFalse(is_primitive([1, 1j]))