Skip to content

Commit

Permalink
Bump pre-commit-hooks to v4.1.0
Browse files Browse the repository at this point in the history
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
pre-commit/pre-commit-hooks#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>
  • Loading branch information
sangwookha-vz committed Mar 25, 2022
1 parent a5ce791 commit bbbcc56
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 20 deletions.
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
@@ -1,16 +1,18 @@
---
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
hooks:
- 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'

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
Expand Down
4 changes: 2 additions & 2 deletions csit/libraries/ALTO/AltoParser.py
Expand Up @@ -66,11 +66,11 @@ def check_ird_configuration_entry(response, ird_resource_id, context_id, resourc
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(
"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("'", "")
Expand Down
2 changes: 1 addition & 1 deletion csit/libraries/BgpRpcClient.py
Expand Up @@ -101,5 +101,5 @@ def sum_hex_message(self, hex_string):
"""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:])]
)
2 changes: 1 addition & 1 deletion csit/libraries/SwitchClasses/H3C.py
Expand Up @@ -113,7 +113,7 @@ def update_datapath_id(self):
# |---------------------------------(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)
2 changes: 1 addition & 1 deletion csit/libraries/SwitchClasses/ProVision.py
Expand Up @@ -155,6 +155,6 @@ def update_datapath_id(self):
# 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)
8 changes: 4 additions & 4 deletions csit/libraries/UtilLibrary.py
Expand Up @@ -264,13 +264,13 @@ def isolate_controller(controllers, username, password, isolated):
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 = (
"[\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):
Expand Down Expand Up @@ -314,13 +314,13 @@ def rejoin_controller(controllers, username, password, isolated):
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 = (
"[\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):
Expand Down
2 changes: 1 addition & 1 deletion csit/libraries/backuprestore/jsonpathl.py
Expand Up @@ -271,7 +271,7 @@ def evalx(loc, obj):
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
Expand Down
10 changes: 5 additions & 5 deletions tools/clustering/cluster-deployer/deploy.py
Expand Up @@ -181,11 +181,11 @@ def deploy(self):
# 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

Expand Down
Expand Up @@ -130,7 +130,7 @@ def crawl_inventory(self):
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:
Expand Down

0 comments on commit bbbcc56

Please sign in to comment.