Bump pre-commit-hooks to v4.1.0 52/100252/1
authorSangwook Ha <sangwook.ha@verizon.com>
Fri, 25 Mar 2022 06:47:17 +0000 (23:47 -0700)
committerSangwook Ha <sangwook.ha@verizon.com>
Fri, 25 Mar 2022 07:12:00 +0000 (00:12 -0700)
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>
.pre-commit-config.yaml
csit/libraries/ALTO/AltoParser.py
csit/libraries/BgpRpcClient.py
csit/libraries/SwitchClasses/H3C.py
csit/libraries/SwitchClasses/ProVision.py
csit/libraries/UtilLibrary.py
csit/libraries/backuprestore/jsonpathl.py
tools/clustering/cluster-deployer/deploy.py
tools/odl-mdsal-clustering-tests/clustering-performance-test/inventory_crawler.py

index 5115ec8fcdf494bd3dbab1e5bee2fce3f66d51ea..83ee03ff3641a368f31966b38100c689407b1c89 100644 (file)
@@ -1,16 +1,18 @@
 ---
 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
     hooks:
     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'
 
       - 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:
index 86e5701af3a70bba92fd828019afb9910a489e2c..539fb82ebb8f30f39f3d2cf4edfce388a5740bf2 100644 (file)
@@ -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(
                 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("'", "")
index fb2b6fe75f7610774a72e0d0c041fb59313cbd73..4a1ba83bd8c21bd0cee833bc9d29706b3a39bc89 100644 (file)
@@ -101,5 +101,5 @@ class BgpRpcClient(object):
         """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:])]
         )
         )
index 57541d279067e91c7a2c1804c97eab6e62740dab..48d6d7ca0d4a31613f6651d8f22c719d73d4e8c6 100644 (file)
@@ -113,7 +113,7 @@ class H3C(BaseSwitch):
             # |---------------------------------(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)
index 45055573c0e714b8cc17e326da69caced352bb9b..454d3d3a75f652f4099421147404658b50c150fd 100644 (file)
@@ -155,6 +155,6 @@ class ProVision(BaseSwitch):
             # 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)
index d567b08130972dfdb5396e05ee09a0a6b9f6274f..6f65fd2061595c2be806a6bebeacd36dce56d465 100644 (file)
@@ -264,13 +264,13 @@ def isolate_controller(controllers, username, password, isolated):
     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):
@@ -314,13 +314,13 @@ def rejoin_controller(controllers, username, password, isolated):
     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):
index 302c19364392306bdf0aec0fe286ddaeaf8355b9..e5953f18e62e50ca1160fae1d8f9681fc1c45e95 100644 (file)
@@ -271,7 +271,7 @@ def jsonpath(obj, expr, result_type="VALUE", debug=0, use_eval=True):
         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
index 62cb38ab429ba95f4ff0c5ba6080522386a5b9d2..ed14b00179def672908ea05a5084f45e392a4b70 100755 (executable)
@@ -181,11 +181,11 @@ class Deployer:
         # 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
 
index 596125e3f611b4d5c4b39eea25a546ae98c89c3c..cb91908d2956368fcfd05d9a4171cb4cabd8f82a 100755 (executable)
@@ -130,7 +130,7 @@ class InventoryCrawler(object):
                     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: