uranusjr commented on code in PR #33519:
URL: https://github.com/apache/airflow/pull/33519#discussion_r1299292501


##########
scripts/ci/pre_commit/pre_commit_unittest_testcase.py:
##########
@@ -29,18 +29,18 @@ def check_test_file(file: str) -> int:
     classes = [c for c in node.body if isinstance(c, ast.ClassDef)]
     for c in classes:
         # Some classes are returned as an ast.Attribute, some as an ast.Name 
object. Not quite sure why
-        parent_classes = [base.attr for base in c.bases if isinstance(base, 
ast.Attribute)]
-        parent_classes.extend([base.id for base in c.bases if isinstance(base, 
ast.Name)])
-
-        if "TestCase" in parent_classes:
-            found += 1
-            print(f"The class {c.name} inherits from TestCase, please use 
pytest instead")
-
+        for base in c.bases:
+            if (isinstance(base, ast.Attribute) and base.attr == "TestCase") 
or (
+                isinstance(base, ast.Name) and base.id == "TestCase"
+            ):
+                found += 1
+                print(f"The class {c.name} inherits from TestCase, please use 
pytest instead")

Review Comment:
   ```suggestion
           if any(
               (
                   (isinstance(base, ast.Attribute) and base.attr == "TestCase")
                   or (isinstance(base, ast.Name) and base.id == "TestCase")
               ) for base in bases
           ):
               found += 1
               print(f"The class {c.name} inherits from TestCase, please use 
pytest instead")
   ```
   
   (I’m pretty sure this indentation is wrong so please change locally and run 
it through pre-commit)



##########
scripts/ci/pre_commit/pre_commit_unittest_testcase.py:
##########
@@ -29,18 +29,18 @@ def check_test_file(file: str) -> int:
     classes = [c for c in node.body if isinstance(c, ast.ClassDef)]
     for c in classes:
         # Some classes are returned as an ast.Attribute, some as an ast.Name 
object. Not quite sure why
-        parent_classes = [base.attr for base in c.bases if isinstance(base, 
ast.Attribute)]
-        parent_classes.extend([base.id for base in c.bases if isinstance(base, 
ast.Name)])
-
-        if "TestCase" in parent_classes:
-            found += 1
-            print(f"The class {c.name} inherits from TestCase, please use 
pytest instead")
-
+        for base in c.bases:
+            if (isinstance(base, ast.Attribute) and base.attr == "TestCase") 
or (
+                isinstance(base, ast.Name) and base.id == "TestCase"
+            ):
+                found += 1
+                print(f"The class {c.name} inherits from TestCase, please use 
pytest instead")

Review Comment:
   ```suggestion
           if any(
               (
                   (isinstance(base, ast.Attribute) and base.attr == "TestCase")
                   or (isinstance(base, ast.Name) and base.id == "TestCase")
               ) for base in bases
           ):
               found += 1
               print(f"The class {c.name} inherits from TestCase, please use 
pytest instead")
   ```
   
   (I’m pretty sure this indentation is wrong so please change locally and run 
it through pre-commit)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to