Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further improvements to existing rules #13

Merged
merged 4 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test case for unsupported Variable.get parents types
- ignore coverage for airflint/__main__.py
  • Loading branch information
feluelle committed Jun 29, 2022
commit 4f1539227baef02237229608dd99ab7dfc9a4db9
2 changes: 1 addition & 1 deletion airflint/rules/use_jinja_variable_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _get_operator_keywords(self, reference: ast.Call) -> list[ast.keyword]:
# Direct reference without variable assignment.
return [parent]

raise AssertionError("Not implemented. Skipping..")
raise AssertionError(f"Unsupported parent type {type(parent)}. Skipping..")

def _lookup_template_fields(self, keyword: ast.keyword) -> None:
parent = self.context["ancestry"].get_parent(keyword)
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ pytest-cov = "^3.0.0"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.coverage.run]
omit = ["airflint/__main__.py"]
16 changes: 16 additions & 0 deletions tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,22 @@ def foo():
BashOperator(task_id="bar", bash_command=var)
""",
),
(
UseJinjaVariableGet,
# Test that nothing happens if the type of Variable.get Calls parent is not implemented e.g. function call
"""
from airflow.models import Variable
from airflow.operators.bash import BashOperator

BashOperator(task_id="foo", output_encoding=str(Variable.get("FOO")))
""",
"""
from airflow.models import Variable
from airflow.operators.bash import BashOperator

BashOperator(task_id="foo", output_encoding=str(Variable.get("FOO")))
""",
),
(
UseJinjaVariableGet,
# Test that Variable.get calls with deserialize_json works.
Expand Down