未验证 提交 0edbd7a5 编写于 作者: N Nyakku Shigure 提交者: GitHub

[CodeStyle][py2] cleanup some useless comments related to py2 (#49135)

上级 a6a4895a
...@@ -5,7 +5,7 @@ exclude: | ...@@ -5,7 +5,7 @@ exclude: |
paddle/fluid/framework/fleet/heter_ps/cudf/.+| paddle/fluid/framework/fleet/heter_ps/cudf/.+|
paddle/fluid/distributed/ps/thirdparty/round_robin.h| paddle/fluid/distributed/ps/thirdparty/round_robin.h|
python/paddle/utils/gast/.+| python/paddle/utils/gast/.+|
.+_py2\.py| .+_pb2\.py|
python/paddle/fluid/tests/unittests/npu/.+| python/paddle/fluid/tests/unittests/npu/.+|
python/paddle/fluid/tests/unittests/mlu/.+ python/paddle/fluid/tests/unittests/mlu/.+
)$ )$
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
import http.server as SimpleHTTPServer import http.server as SimpleHTTPServer
import logging import logging
import threading import threading
# NOTE: HTTPServer has a different name in python2 and python3
from http.server import HTTPServer from http.server import HTTPServer
__all__ = [] __all__ = []
......
...@@ -28,7 +28,6 @@ from paddle.fluid.framework import ( ...@@ -28,7 +28,6 @@ from paddle.fluid.framework import (
set_flags, set_flags,
) )
# NOTE: queue has a different name in python2 and python3
import queue import queue
import paddle import paddle
......
...@@ -28,7 +28,6 @@ from ..multiprocess_utils import ( ...@@ -28,7 +28,6 @@ from ..multiprocess_utils import (
from ..framework import _non_static_mode, _in_eager_without_dygraph_check from ..framework import _non_static_mode, _in_eager_without_dygraph_check
from .flat import _flatten_batch from .flat import _flatten_batch
# NOTE: queue has a different name in python2 and python3
import queue import queue
__all__ = ['get_worker_info'] __all__ = ['get_worker_info']
......
...@@ -248,7 +248,6 @@ def load_dygraph(model_path, **configs): ...@@ -248,7 +248,6 @@ def load_dygraph(model_path, **configs):
) )
# 2. load layer parameters & buffers # 2. load layer parameters & buffers
# NOTE: using fluid.dygraph.guard() here will cause import error in py2
with guard(): with guard():
persistable_var_dict = _construct_params_and_buffers( persistable_var_dict = _construct_params_and_buffers(
model_prefix, model_prefix,
......
...@@ -1290,7 +1290,7 @@ def _varbase_creator( ...@@ -1290,7 +1290,7 @@ def _varbase_creator(
shape=None, shape=None,
dtype=None, dtype=None,
persistable=None, persistable=None,
**kwargs **kwargs,
): ):
if dtype is not None: if dtype is not None:
if not isinstance(dtype, core.VarDesc.VarType): if not isinstance(dtype, core.VarDesc.VarType):
...@@ -1412,7 +1412,7 @@ class Variable(metaclass=VariableMetaClass): ...@@ -1412,7 +1412,7 @@ class Variable(metaclass=VariableMetaClass):
is_data=False, is_data=False,
need_check_feed=False, need_check_feed=False,
belong_to_optimizer=False, belong_to_optimizer=False,
**kwargs **kwargs,
): ):
self.block = block self.block = block
if name is None: if name is None:
...@@ -2953,11 +2953,8 @@ class Operator: ...@@ -2953,11 +2953,8 @@ class Operator:
in_arg_names.append(arg.name) in_arg_names.append(arg.name)
else: else:
raise TypeError( raise TypeError(
"The type of '%s' in operator %s should be " f"The type of '%{in_proto.name}' in operator {type} should be "
"one of [basestring(), str, Varibale] in python2, " f"one of [str, bytes, Variable]. but received : {arg}"
"or one of [str, bytes, Variable] in python3."
"but received : %s"
% (in_proto.name, type, arg)
) )
self.desc.set_input(in_proto.name, in_arg_names) self.desc.set_input(in_proto.name, in_arg_names)
else: else:
...@@ -6887,7 +6884,7 @@ class Parameter(Variable, metaclass=ParameterMetaClass): ...@@ -6887,7 +6884,7 @@ class Parameter(Variable, metaclass=ParameterMetaClass):
shape, shape,
dtype, dtype,
type=core.VarDesc.VarType.LOD_TENSOR, type=core.VarDesc.VarType.LOD_TENSOR,
**kwargs **kwargs,
): ):
if shape is None: if shape is None:
raise ValueError("The shape of Parameter should not be None") raise ValueError("The shape of Parameter should not be None")
...@@ -6908,7 +6905,7 @@ class Parameter(Variable, metaclass=ParameterMetaClass): ...@@ -6908,7 +6905,7 @@ class Parameter(Variable, metaclass=ParameterMetaClass):
shape=shape, shape=shape,
dtype=dtype, dtype=dtype,
type=type, type=type,
**kwargs **kwargs,
) )
self.trainable = kwargs.get('trainable', True) self.trainable = kwargs.get('trainable', True)
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
import logging import logging
# NOTE: HTTPServer has a different name in python2 and python3
from http.server import HTTPServer from http.server import HTTPServer
import http.server as SimpleHTTPServer import http.server as SimpleHTTPServer
import time import time
......
...@@ -18,7 +18,6 @@ import atexit ...@@ -18,7 +18,6 @@ import atexit
from . import core from . import core
# NOTE: queue has a different name in python2 and python3
import queue import queue
# multi-process worker check indices queue interval, avoid # multi-process worker check indices queue interval, avoid
......
...@@ -64,7 +64,6 @@ import os ...@@ -64,7 +64,6 @@ import os
import multiprocessing import multiprocessing
import signal import signal
# NOTE: queue has a different name in python2 and python3
import queue import queue
# NOTE: [ avoid hanging & failed quickly ] These value is used in getting data from another process # NOTE: [ avoid hanging & failed quickly ] These value is used in getting data from another process
......
...@@ -16,7 +16,7 @@ please make sure to run in the tools path ...@@ -16,7 +16,7 @@ please make sure to run in the tools path
usage: python sample_test.py {cpu or gpu} usage: python sample_test.py {cpu or gpu}
{cpu or gpu}: running in cpu version or gpu version {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 python sampcd_processor.py cpu
......
...@@ -67,9 +67,7 @@ class Test_is_primitive(unittest.TestCase): ...@@ -67,9 +67,7 @@ class Test_is_primitive(unittest.TestCase):
self.assertTrue(is_primitive(2)) self.assertTrue(is_primitive(2))
self.assertTrue(is_primitive(2.1)) self.assertTrue(is_primitive(2.1))
self.assertTrue(is_primitive("2.1.1")) self.assertTrue(is_primitive("2.1.1"))
self.assertFalse( self.assertFalse(is_primitive("hello paddle".encode('UTF-8')))
is_primitive("hello paddle".encode('UTF-8'))
) # True for python2
self.assertFalse(is_primitive(1j)) self.assertFalse(is_primitive(1j))
self.assertTrue(is_primitive(True)) self.assertTrue(is_primitive(True))
...@@ -80,7 +78,7 @@ class Test_is_primitive(unittest.TestCase): ...@@ -80,7 +78,7 @@ class Test_is_primitive(unittest.TestCase):
self.assertTrue(is_primitive([1, 2])) self.assertTrue(is_primitive([1, 2]))
self.assertTrue(is_primitive((1.1, 2.2))) self.assertTrue(is_primitive((1.1, 2.2)))
self.assertTrue(is_primitive(set([1, 2.3]))) 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({}))
self.assertFalse(is_primitive([1, 1j])) self.assertFalse(is_primitive([1, 1j]))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册