Skip to content

Commit

Permalink
fix: refactor to remove typing.List and use default list annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleybonitatibus committed Nov 16, 2022
1 parent 5451546 commit b93188d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions flake8_airflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
from __future__ import annotations

import ast
from typing import Generator, Any, List
from typing import Generator, Any

AA101 = "AA101 `SubDagOperator` used, should use TaskGroups instead"
AA102 = "AA102 `BashOperator` used, potential security risk"
AA103 = "AA103 `retries` argument missing from `DAG` `default_args` constructor"


def contains_key(keys: List[ast.Constant], key: str) -> bool:
def contains_key(keys: list[ast.Constant], key: str) -> bool:
"""Check ast constants for seeing if a key exists.
Args:
keys (typing.List[ast.Constant]): Keys from Keywords
keys (list[ast.Constant]): Keys from Keywords
key (str): Key looking for
Returns:
Expand Down Expand Up @@ -87,8 +87,7 @@ def visit_Call(self, node: ast.Call) -> None:
"""
n: ast.Name = node.func
if n.id == "DAG":
kw: List[ast.keyword] = node.keywords
for k in kw:
for k in node.keywords:
if "default_args" in k.arg and not contains_key(
k.value.keys, "retries"
):
Expand Down

0 comments on commit b93188d

Please sign in to comment.