Update pre-commit-hooks from v2.4.0 to v4.1.0:
https://github.com/pre-commit/pre-commit-hooks/releases
Since flake8 was removed in v4.0.0:
https://github.com/pre-commit/pre-commit-hooks/releases/tag/v4.0.0
https://github.com/pre-commit/pre-commit-hooks/pull/597
replace it with PyCQA/flake8:
https://github.com/PyCQA/flake8
https://flake8.pycqa.org/en/latest/release-notes/index.html
and address flake8 W605 issues detected by the new flake8:
https://www.flake8rules.com/rules/W605.html
Change-Id: I148b1b862b192a3e44c9ee90292df7678629d8e0
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v2.4.0 # Use the ref you want to point at
+ rev: v4.1.0 # Use the ref you want to point at
- - id: flake8
- language_version: python3
- additional_dependencies: ['flake8~=3.5.0']
- id: trailing-whitespace
# this hook will remove any blank lines at the end of a file, whereas the robot hook will add one
# so to prevent this conflict we will ignore .robot files in this trailing-whitespace hook
exclude: '\.robot'
- id: trailing-whitespace
# this hook will remove any blank lines at the end of a file, whereas the robot hook will add one
# so to prevent this conflict we will ignore .robot files in this trailing-whitespace hook
exclude: '\.robot'
+ - repo: https://github.com/PyCQA/flake8
+ rev: 4.0.1
+ hooks:
+ - id: flake8
+
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
if "dependency" in tag:
for one_dependency in tag["dependency"]:
_context_id = re.findall(
if "dependency" in tag:
for one_dependency in tag["dependency"]:
_context_id = re.findall(
- "\d{8}-\d{4}-\d{4}-\d{4}-\d{12}", one_dependency
+ r"\d{8}-\d{4}-\d{4}-\d{4}-\d{12}", one_dependency
)[0]
if _context_id == context_id:
long_resource_id = re.findall(
)[0]
if _context_id == context_id:
long_resource_id = re.findall(
- "resource-id='[a-zA-Z\-]*'", one_dependency
+ r"resource-id='[a-zA-Z\-]*'", one_dependency
)[0]
short_resource_id = re.findall("'.*'", long_resource_id)[0]
_resource_id = short_resource_id.replace("'", "")
)[0]
short_resource_id = re.findall("'.*'", long_resource_id)[0]
_resource_id = short_resource_id.replace("'", "")
"""Verifies two hex messages are equal even in case, their arguments are misplaced.
Converts hex message arguments to integers and sums them up and returns the sum."""
return sum(
"""Verifies two hex messages are equal even in case, their arguments are misplaced.
Converts hex message arguments to integers and sums them up and returns the sum."""
return sum(
- [int(x, 16) for x in re.compile("[a-f\d]{2}").findall(hex_string[32:])]
+ [int(x, 16) for x in re.compile(r"[a-f\d]{2}").findall(hex_string[32:])]
# |---------------------------------(0)---------------------------------|
# |------(1)-------||------(2)-----|
matches = re.search(
# |---------------------------------(0)---------------------------------|
# |------(1)-------||------(2)-----|
matches = re.search(
- "(.*0x)(\w+) +Connected", self.datapath_id_output_string
+ r"(.*0x)(\w+) +Connected", self.datapath_id_output_string
)
datapath_id_hex = matches.group(2)
self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)
)
datapath_id_hex = matches.group(2)
self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)
# Datapath ID : 000af0921c22bac0
# |-----------------(0)---------------------|
# |-----------(1)----------| |------(2)-----|
# Datapath ID : 000af0921c22bac0
# |-----------------(0)---------------------|
# |-----------(1)----------| |------(2)-----|
- matches = re.search("(.*: )(\w+)", self.datapath_id_output_string)
+ matches = re.search(r"(.*: )(\w+)", self.datapath_id_output_string)
datapath_id_hex = matches.group(2)
self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)
datapath_id_hex = matches.group(2)
self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)
iso_result = "pass"
for controller in controllers:
controller_regex_string = (
iso_result = "pass"
for controller in controllers:
controller_regex_string = (
- "[\s\S]*" + isolated_controller + " *" + controller + "[\s\S]*"
+ r"[\s\S]*" + isolated_controller + " *" + controller + r"[\s\S]*"
)
controller_regex = re.compile(controller_regex_string)
if not controller_regex.match(ip_tables):
iso_result = ip_tables
controller_regex_string = (
)
controller_regex = re.compile(controller_regex_string)
if not controller_regex.match(ip_tables):
iso_result = ip_tables
controller_regex_string = (
- "[\s\S]*" + controller + " *" + isolated_controller + "[\s\S]*"
+ r"[\s\S]*" + controller + " *" + isolated_controller + r"[\s\S]*"
)
controller_regex = re.compile(controller_regex_string)
if not controller_regex.match(ip_tables):
)
controller_regex = re.compile(controller_regex_string)
if not controller_regex.match(ip_tables):
iso_result = "pass"
for controller in controllers:
controller_regex_string = (
iso_result = "pass"
for controller in controllers:
controller_regex_string = (
- "[\s\S]*" + isolated_controller + " *" + controller + "[\s\S]*"
+ r"[\s\S]*" + isolated_controller + " *" + controller + r"[\s\S]*"
)
controller_regex = re.compile(controller_regex_string)
if controller_regex.match(ip_tables):
iso_result = ip_tables
controller_regex_string = (
)
controller_regex = re.compile(controller_regex_string)
if controller_regex.match(ip_tables):
iso_result = ip_tables
controller_regex_string = (
- "[\s\S]*" + controller + " *" + isolated_controller + "[\s\S]*"
+ r"[\s\S]*" + controller + " *" + isolated_controller + r"[\s\S]*"
)
controller_regex = re.compile(controller_regex_string)
if controller_regex.match(ip_tables):
)
controller_regex = re.compile(controller_regex_string)
if controller_regex.match(ip_tables):
def notvar(m):
return "'%s' not in __obj" % m.group(1)
def notvar(m):
return "'%s' not in __obj" % m.group(1)
- loc = re.sub("!@\.([a-zA-Z@_]+)", notvar, loc)
+ loc = re.sub(r"!@\.([a-zA-Z@_]+)", notvar, loc)
# replace @.name.... with __obj['name']....
# handle @.name[.name...].length
# replace @.name.... with __obj['name']....
# handle @.name[.name...].length
# Determine distribution version
distribution_name = os.path.splitext(os.path.basename(self.distribution))[0]
distribution_ver = re.search(
# Determine distribution version
distribution_name = os.path.splitext(os.path.basename(self.distribution))[0]
distribution_ver = re.search(
- "(\d+\.\d+\.\d+-\w+\Z)|"
- "(\d+\.\d+\.\d+-\w+)(-RC\d+\Z)|"
- "(\d+\.\d+\.\d+-\w+)(-RC\d+(\.\d+)\Z)|"
- "(\d+\.\d+\.\d+-\w+)(-SR\d+\Z)|"
- "(\d+\.\d+\.\d+-\w+)(-SR\d+(\.\d+)\Z)",
+ r"(\d+\.\d+\.\d+-\w+\Z)|"
+ r"(\d+\.\d+\.\d+-\w+)(-RC\d+\Z)|"
+ r"(\d+\.\d+\.\d+-\w+)(-RC\d+(\.\d+)\Z)|"
+ r"(\d+\.\d+\.\d+-\w+)(-SR\d+\Z)|"
+ r"(\d+\.\d+\.\d+-\w+)(-SR\d+(\.\d+)\Z)",
distribution_name,
) # noqa
distribution_name,
) # noqa
if re.search("openflow", inv[n]["id"]) is not None:
sinv.append(inv[n])
if re.search("openflow", inv[n]["id"]) is not None:
sinv.append(inv[n])
- sinv = sorted(sinv, key=lambda k: int(re.findall("\d+", k["id"])[0]))
+ sinv = sorted(sinv, key=lambda k: int(re.findall(r"\d+", k["id"])[0]))
for n in range(len(sinv)):
try:
for n in range(len(sinv)):
try: