fix msg config

Change-Id: I5d87a8f84deeedcffa11cf2a79be2a8e64c2cb70
This commit is contained in:
suhaiming 2020-12-31 01:42:20 +00:00
parent 52d46926f0
commit dedd6fb292
3 changed files with 18 additions and 33 deletions

View File

@ -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))

View File

@ -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):

View File

@ -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``"
}