diff --git a/venus/common/utils.py b/venus/common/utils.py index d9a2a99..5e61b17 100644 --- a/venus/common/utils.py +++ b/venus/common/utils.py @@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__) def request_es(url, method, data=None): http = urllib3.PoolManager(timeout=30.0) try: - if method == "GET" or method == "DELETE": + if method in ["GET", "DELETE"]: resp = http.request(method, url=url) elif method == "POST": resp = http.request(method, url=url, body=json.dumps(data)) diff --git a/venus/hacking/checks.py b/venus/hacking/checks.py index 3819dba..344c60c 100644 --- a/venus/hacking/checks.py +++ b/venus/hacking/checks.py @@ -16,7 +16,6 @@ import re from hacking import core -from venus.hacking.common import msg """ Guidelines for writing new hacking checks @@ -62,6 +61,23 @@ translated_log = re.compile( r"\(\s*_\(\s*('|\")") string_translation = re.compile(r"[^_]*_\(\s*('|\")") +msg = { + 302: "M302: assertEqual(A is not None) sentences not allowed.", + 310: "M310: timeutils.utcnow() must be used instead of datetime.%s()", + 316: "M316: assertTrue(isinstance(a, b)) sentences not allowed", + 322: "M322: Method's default argument shouldn't be mutable!", + 336: "M336: Must use a dict comprehension instead of a dict " + "constructor with a sequence of key-value pairs.", + 338: "M338: Use assertIn/NotIn(A, B) rather than " + "assertEqual(A in B, True/False) when checking " + "collection contents.", + 339: "M339: Do not use xrange().", + 340: "M340: Found use of _() without explicit import of _ !", + 352: "M352: LOG.warn is deprecated, please use LOG.warning!", + 366: "N366: You must explicitly import python's mock: " + "``from unittest import mock``" +} + @core.flake8ext def no_mutable_default_args(logical_line): diff --git a/venus/hacking/common.py b/venus/hacking/common.py deleted file mode 100644 index b83e340..0000000 --- a/venus/hacking/common.py +++ /dev/null @@ -1,31 +0,0 @@ -# -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -msg = { - 302: "M302: assertEqual(A is not None) sentences not allowed.", - 310: "M310: timeutils.utcnow() must be used instead of datetime.%s()", - 316: "M316: assertTrue(isinstance(a, b)) sentences not allowed", - 322: "M322: Method's default argument shouldn't be mutable!", - 336: "M336: Must use a dict comprehension instead of a dict " - "constructor with a sequence of key-value pairs.", - 338: "M338: Use assertIn/NotIn(A, B) rather than " - "assertEqual(A in B, True/False) when checking " - "collection contents.", - 339: "M339: Do not use xrange().", - 340: "M340: Found use of _() without explicit import of _ !", - 352: "M352: LOG.warn is deprecated, please use LOG.warning!", - 366: "N366: You must explicitly import python's mock: " - "``from unittest import mock``" -}