Taragolis commented on code in PR #37718:
URL: https://github.com/apache/airflow/pull/37718#discussion_r1503217854


##########
airflow/providers/fab/auth_manager/security_manager/override.py:
##########
@@ -728,7 +728,8 @@ def create_admin_standalone(self) -> tuple[str | None, str 
| None]:
         if not user_exists:
             print(f"FlaskAppBuilder Authentication Manager: Creating 
{user_name} user")
             role = self.find_role("Admin")
-            assert role is not None
+            if TYPE_CHECKING:
+                assert role is not None

Review Comment:
   ruff `S101` work well with assert in `TYPE_CHECKING` block - do not count as 
a mistake.
   bandit `B101` false positive if it within the `TYPE_CHECKING` block, and in 
addition it has severity Low, so we skip it in our bandit pre-commit hook
   
   ```console
   >> Issue: [B101:assert_used] Use of assert detected. The enclosed code will 
be removed when compiling to optimised byte code.
      Severity: Low   Confidence: High
      CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
      More Info: 
https://bandit.readthedocs.io/en/1.7.6/plugins/b101_assert_used.html
      Location: airflow/api/common/mark_tasks.py:235:20
   234                  if TYPE_CHECKING:
   235                      assert current_task.subdag
   236                  dag_runs = _create_dagruns(
   ```



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