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

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

上级 a6a4895a
......@@ -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/.+
)$
......
......@@ -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__ = []
......
......@@ -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
......
......@@ -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']
......
......@@ -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,
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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]))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册