Skip to content

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

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

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是个 typo,指自动生成的 protobuf 相关代码文件,搜索 py2 发现的 😂

python/paddle/fluid/tests/unittests/npu/.+|
python/paddle/fluid/tests/unittests/mlu/.+
)$
Expand Down
2 changes: 0 additions & 2 deletions python/paddle/distributed/fleet/utils/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = []
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/dataloader/dataloader_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
set_flags,
)

# NOTE: queue has a different name in python2 and python3
import queue

import paddle
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/dataloader/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
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']
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/dygraph/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 6 additions & 9 deletions python/paddle/fluid/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -1412,7 +1412,7 @@ def __init__(
is_data=False,
need_check_feed=False,
belong_to_optimizer=False,
**kwargs
**kwargs,
):
self.block = block
if name is None:
Expand Down Expand Up @@ -2953,11 +2953,8 @@ def find_name(var_list, name):
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:
Expand Down Expand Up @@ -6887,7 +6884,7 @@ def __init__(
shape,
dtype,
type=core.VarDesc.VarType.LOD_TENSOR,
**kwargs
**kwargs,
):
if shape is None:
raise ValueError("The shape of Parameter should not be None")
Expand All @@ -6908,7 +6905,7 @@ def __init__(
shape=shape,
dtype=dtype,
type=type,
**kwargs
**kwargs,
)
self.trainable = kwargs.get('trainable', True)

Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/incubate/fleet/utils/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/multiprocess_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from . import core

# NOTE: queue has a different name in python2 and python3
import queue

# multi-process worker check indices queue interval, avoid
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
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
Expand Down
2 changes: 1 addition & 1 deletion tools/sampcd_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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

Expand Down
6 changes: 2 additions & 4 deletions tools/test_print_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ def test_single(self):
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))

Expand All @@ -80,7 +78,7 @@ def test_collection(self):
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]))

Expand Down